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

@@ -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;
}
}