mirror of
https://github.com/FatttSnake/Pinnacle-OA.git
synced 2026-04-05 23:11:24 +08:00
add the function of fuzzy query in the page of NoticeTypeManage
This commit is contained in:
@@ -2,6 +2,7 @@ package com.cfive.pinnacle.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import com.cfive.pinnacle.entity.NoticeType;
|
||||
import com.cfive.pinnacle.entity.common.ResponseCode;
|
||||
import com.cfive.pinnacle.entity.common.ResponseResult;
|
||||
@@ -55,17 +56,15 @@ public class NoticeTypeController {
|
||||
//分页查询所有公告类型
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("hasAuthority('notice:type:get')")
|
||||
public ResponseResult<List<NoticeType>> selectPageTypeList(Integer currentPage, Integer pageSize){
|
||||
Page<NoticeType> noticeTypePage=new Page<>();
|
||||
public ResponseResult<List<NoticeType>> selectPageTypeList(Integer currentPage, Integer pageSize,String name,Integer enable){
|
||||
Page<NoticeType> noticeTypePage;
|
||||
if (null != currentPage && null != pageSize) {
|
||||
noticeTypePage.setCurrent(currentPage.intValue());
|
||||
noticeTypePage.setSize(pageSize.intValue());
|
||||
noticeTypePage = PageDTO.of(currentPage, pageSize);
|
||||
} else {
|
||||
// 不进行分页
|
||||
noticeTypePage.setCurrent(1);
|
||||
noticeTypePage.setSize(-1);
|
||||
noticeTypePage = PageDTO.of(1, -1);
|
||||
}
|
||||
IPage<NoticeType> selectPageTypeList = noticeTypeService.selectPageTypeList(noticeTypePage);
|
||||
IPage<NoticeType> selectPageTypeList = noticeTypeService.selectPageTypeList(noticeTypePage,name.trim(),enable);
|
||||
Integer code = selectPageTypeList.getRecords() != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||
String msg = selectPageTypeList.getRecords() != null ? String.valueOf(selectPageTypeList.getTotal()) : "数据查询失败,请重试!";
|
||||
return ResponseResult.build(code, msg, selectPageTypeList.getRecords());
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public interface INoticeTypeService extends IService<NoticeType> {
|
||||
List<NoticeType> selectTypeList();
|
||||
|
||||
IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page);
|
||||
IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page,String name,Integer enable);
|
||||
List<NoticeType> selectEnableTypeList();
|
||||
|
||||
Boolean updateTypeEnableById(Long typeId, Integer enable);
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.cfive.pinnacle.utils.WebUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -44,39 +45,38 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime,List<Long> userIdList) {
|
||||
LocalDateTime start=null,end=null;
|
||||
if (startTime!=""&&endTime!=""){
|
||||
start= LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
public IPage<Notice> selectPageNotice(IPage<Notice> page, String title, String type, String startTime, String endTime, List<Long> userIdList) {
|
||||
LocalDateTime start = null, end = null;
|
||||
if (startTime != "" && endTime != "") {
|
||||
start = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
end = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
return noticeMapper.selectPageNotice(page, title, type, start, end,userIdList);
|
||||
return noticeMapper.selectPageNotice(page, title, type, start, end, userIdList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteById(Long nid) {
|
||||
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(NoticeReceive::getNoticeId, nid);
|
||||
boolean flag = noticeReceiveMapper.delete(lqw) > 0;
|
||||
return flag && noticeMapper.deleteById(nid) > 0;
|
||||
noticeReceiveMapper.delete(lqw);
|
||||
return noticeMapper.deleteById(nid) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteBatchByIds(List<Long> noticeIds) {
|
||||
boolean flag = false;
|
||||
for (Long nid :
|
||||
noticeIds) {
|
||||
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(NoticeReceive::getNoticeId, nid);
|
||||
flag = noticeReceiveMapper.delete(lqw) > 0;
|
||||
if (!flag) {
|
||||
break;
|
||||
}
|
||||
noticeReceiveMapper.delete(lqw);
|
||||
}
|
||||
return flag && noticeMapper.deleteBatchIds(noticeIds) > 0;
|
||||
return noticeMapper.deleteBatchIds(noticeIds) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateNotice(Notice notice) {
|
||||
noticeMapper.update(null, new UpdateWrapper<Notice>().eq("id", notice.getId()).set("old", 1)); //修改原始数据
|
||||
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
|
||||
@@ -96,8 +96,9 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean addNotice(Notice notice) {
|
||||
boolean noticeFlag, noticeRecFlag = false;
|
||||
boolean noticeFlag;
|
||||
notice.setSenderId(WebUtil.getLoginUser().getUser().getId());
|
||||
// notice.setSenderId(1652714496280469506L);
|
||||
noticeFlag = noticeMapper.insert(notice) > 0;
|
||||
@@ -108,15 +109,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
|
||||
NoticeReceive noticeReceive = new NoticeReceive();
|
||||
noticeReceive.setNoticeId(noticeId);
|
||||
noticeReceive.setUserId(receiveId);
|
||||
noticeRecFlag = noticeReceiveMapper.insert(noticeReceive) > 0;
|
||||
if (!noticeRecFlag) {
|
||||
break;
|
||||
}
|
||||
noticeReceiveMapper.insert(noticeReceive);
|
||||
}
|
||||
} else {
|
||||
noticeFlag = false;
|
||||
}
|
||||
return noticeFlag && noticeRecFlag;
|
||||
return noticeFlag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.cfive.pinnacle.service.INoticeTypeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,6 +25,7 @@ import java.util.List;
|
||||
public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeType> implements INoticeTypeService {
|
||||
@Autowired
|
||||
NoticeTypeMapper noticeTypeMapper;
|
||||
|
||||
@Override
|
||||
public List<NoticeType> selectTypeList() {
|
||||
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();
|
||||
@@ -32,8 +34,10 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page) {
|
||||
public IPage<NoticeType> selectPageTypeList(IPage<NoticeType> page, String name, Integer enable) {
|
||||
LambdaQueryWrapper<NoticeType> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.like(null != name && name != "", NoticeType::getName, name);
|
||||
lqw.eq(null != enable && enable != -1, NoticeType::getEnable, enable);
|
||||
lqw.orderByDesc(NoticeType::getId);
|
||||
return noticeTypeMapper.selectPage(page, lqw);
|
||||
}
|
||||
@@ -48,31 +52,32 @@ public class NoticeTypeServiceImpl extends ServiceImpl<NoticeTypeMapper, NoticeT
|
||||
|
||||
@Override
|
||||
public Boolean updateTypeEnableById(Long typeId, Integer enable) {
|
||||
if ((null==typeId)||(null==enable)){
|
||||
if ((null == typeId) || (null == enable)) {
|
||||
return false;
|
||||
}
|
||||
LambdaUpdateWrapper<NoticeType> luw = new LambdaUpdateWrapper<>();
|
||||
luw.eq(null!=typeId,NoticeType::getId, typeId).set(null!=enable,NoticeType::getEnable,enable);
|
||||
return noticeTypeMapper.update(null, luw)>0;
|
||||
luw.eq(null != typeId, NoticeType::getId, typeId).set(null != enable, NoticeType::getEnable, enable);
|
||||
return noticeTypeMapper.update(null, luw) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addNoticeType(NoticeType noticeType) {
|
||||
return noticeTypeMapper.insert(noticeType)>0;
|
||||
return noticeTypeMapper.insert(noticeType) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateNoticeType(NoticeType noticeType) {
|
||||
return noticeTypeMapper.updateById(noticeType)>0;
|
||||
return noticeTypeMapper.updateById(noticeType) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteNoticeTypeById(Long typeId) {
|
||||
return noticeTypeMapper.deleteById(typeId)>0;
|
||||
return noticeTypeMapper.deleteById(typeId) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean deleteBatchByTypeIds(List<Long> typeIds) {
|
||||
return noticeTypeMapper.deleteBatchIds(typeIds)>0;
|
||||
return noticeTypeMapper.deleteBatchIds(typeIds) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user