1
0
mirror of https://github.com/FatttSnake/Pinnacle-OA.git synced 2026-04-05 23:11:24 +08:00

senderName filter and selectByTitile completed

This commit is contained in:
cccccyb
2023-05-03 01:03:00 +08:00
parent 42dd714ed1
commit 90aad35eb4
11 changed files with 257 additions and 123 deletions

View File

@@ -40,13 +40,20 @@ public class NoticeController {
//添加公告
@GetMapping
public ResponseResult selectAllNotice() {
List<Notice> noticeList = noticeService.selectAllNotice();
Integer code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
public ResponseResult selectAllNotice(String title) {
List<Notice> noticeList;
if (title == null) {
noticeList = noticeService.selectAllNotice();
} else {
noticeList = noticeService.selectByTitle(title);
}
int code = noticeList != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
String msg = noticeList != null ? "" : "数据查询失败,请尝试!";
return ResponseResult.build(code, msg, noticeList);
}
@PostMapping
public ResponseResult updateNotice(@RequestBody Notice notice) {
notice.setId(null); //清除id使新插入的数据id自增

View File

@@ -18,5 +18,7 @@ public interface INoticeService extends IService<Notice> {
List<Notice> selectAllNotice();
List<Notice> selectByTitle(String title);
Boolean deleteById(Long nid);
}

View File

@@ -5,6 +5,8 @@ import com.cfive.pinnacle.entity.Notice;
import com.cfive.pinnacle.entity.NoticeReceive;
import com.cfive.pinnacle.mapper.NoticeMapper;
import com.cfive.pinnacle.mapper.NoticeReceiveMapper;
import com.cfive.pinnacle.mapper.NoticeTypeMapper;
import com.cfive.pinnacle.mapper.UserMapper;
import com.cfive.pinnacle.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +27,12 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
@Autowired
NoticeMapper noticeMapper;
@Autowired
NoticeTypeMapper noticeTypeMapper;
@Autowired
UserMapper userMapper;
@Autowired
NoticeReceiveMapper noticeReceiveMapper;
@Override
public Notice selectByNoticeId(Long nid) {
return noticeMapper.selectByNoticeId(nid);
@@ -36,16 +43,29 @@ public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> impleme
return noticeMapper.selectAllNotice();
}
@Override
public List<Notice> selectByTitle(String title) {
LambdaQueryWrapper<Notice> lqw = new LambdaQueryWrapper<>();
lqw.like(Notice::getTitle, title);
List<Notice> notices = noticeMapper.selectList(lqw);
for (Notice n : notices
) {
n.setSender(userMapper.selectById(n.getSenderId()));
n.setNoticeType(noticeTypeMapper.selectById(n.getTypeId()));
}
return notices;
}
@Override
public Boolean deleteById(Long nid) {
LambdaQueryWrapper<NoticeReceive> lqw = new LambdaQueryWrapper<>();
lqw.eq(NoticeReceive::getNoticeId, nid);
List<NoticeReceive> noticeReceives = noticeReceiveMapper.selectList(lqw);
for (NoticeReceive nrc:
noticeReceives) {
for (NoticeReceive nrc :
noticeReceives) {
noticeReceiveMapper.deleteById(nrc.getId());
}
return noticeMapper.deleteById(nid)>0;
return noticeMapper.deleteById(nid) > 0;
}
}

View File

@@ -43,7 +43,7 @@
n.version nve,
type.id typeId,
name,
enable,
type.enable,
type.deleted typeDe,
type.version typeVe
from t_user u,

View File

@@ -39,7 +39,7 @@ public class NoticeTest {
@Test
void selectAllTest() {
ResponseResult noticeList = noticeController.selectAllNotice();
ResponseResult noticeList = noticeController.selectAllNotice(null);
System.out.println(noticeList.getData());
}