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 NoticeView had been completed
This commit is contained in:
@@ -67,8 +67,8 @@ public class NoticeController {
|
||||
//根据登录用户id查询所接收的公告
|
||||
@GetMapping("/self")
|
||||
@PreAuthorize("hasAuthority('notice:self:get')")
|
||||
public ResponseResult<List<Notice>> selectByUserId(Integer readStatus) {
|
||||
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus);
|
||||
public ResponseResult<List<Notice>> selectByUserId(Integer readStatus,String title, String type, String startTime, String endTime) {
|
||||
List<Notice> noticesByUserId = noticeReceiveService.selectByUserId(readStatus, title.trim(), type.trim(), startTime.trim(), endTime.trim());
|
||||
Integer code = noticesByUserId != null ? ResponseCode.DATABASE_SELECT_OK : ResponseCode.DATABASE_SELECT_ERROR;
|
||||
String msg = noticesByUserId != null ? "" : "数据查询失败,请重试!";
|
||||
return ResponseResult.build(code, msg, noticesByUserId);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
@Mapper
|
||||
public interface NoticeReceiveMapper extends BaseMapper<NoticeReceive> {
|
||||
List<Notice> selectByUserId(Long userId,Integer readStatus);
|
||||
List<Notice> selectByUserId(Long userId, Integer readStatus, String title, String type, LocalDateTime startTime, LocalDateTime endTime);
|
||||
List<Notice> selectLimitByUserId(Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.cfive.pinnacle.entity.Notice;
|
||||
import com.cfive.pinnacle.entity.NoticeReceive;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,7 +16,7 @@ import java.util.List;
|
||||
* @since 2023-04-30
|
||||
*/
|
||||
public interface INoticeReceiveService extends IService<NoticeReceive> {
|
||||
List<Notice> selectByUserId(Integer readStatus);
|
||||
List<Notice> selectByUserId(Integer readStatus, String title, String type, String startTime, String endTime);
|
||||
|
||||
List<Notice> selectLimitByUserId();
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.cfive.pinnacle.utils.WebUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -24,10 +26,16 @@ import java.util.List;
|
||||
public class NoticeReceiveServiceImpl extends ServiceImpl<NoticeReceiveMapper, NoticeReceive> implements INoticeReceiveService {
|
||||
@Autowired
|
||||
private NoticeReceiveMapper noticeReceiveMapper;
|
||||
|
||||
@Override
|
||||
public List<Notice> selectByUserId(Integer readStatus) {
|
||||
public List<Notice> selectByUserId(Integer readStatus, String title, String type, String startTime, String endTime) {
|
||||
Long userId = WebUtil.getLoginUser().getUser().getId();
|
||||
return noticeReceiveMapper.selectByUserId(userId,readStatus);
|
||||
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 noticeReceiveMapper.selectByUserId(userId, readStatus, title, type, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,12 +47,12 @@ public class NoticeReceiveServiceImpl extends ServiceImpl<NoticeReceiveMapper, N
|
||||
@Override
|
||||
public Boolean modifyNoticeIsRead(Notice notice) {
|
||||
Integer readStatus = null;
|
||||
if (null!=notice.getIsRead()){
|
||||
readStatus=notice.getIsRead()==0?1:0;
|
||||
if (null != notice.getIsRead()) {
|
||||
readStatus = notice.getIsRead() == 0 ? 1 : 0;
|
||||
}
|
||||
LambdaUpdateWrapper<NoticeReceive> luw = new LambdaUpdateWrapper<>();
|
||||
Long userId = WebUtil.getLoginUser().getUser().getId();
|
||||
luw.eq(NoticeReceive::getNoticeId, notice.getId()).eq(NoticeReceive::getUserId, userId).set(null!=readStatus,NoticeReceive::getAlreadyRead, readStatus);
|
||||
return noticeReceiveMapper.update(null,luw)>0;
|
||||
luw.eq(NoticeReceive::getNoticeId, notice.getId()).eq(NoticeReceive::getUserId, userId).set(null != readStatus, NoticeReceive::getAlreadyRead, readStatus);
|
||||
return noticeReceiveMapper.update(null, luw) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,18 @@
|
||||
<if test="null!=readStatus and readStatus>=0">
|
||||
and notice_receive.already_read=#{readStatus}
|
||||
</if>
|
||||
<if test="null!=title and title!=''">
|
||||
and instr(n.title,#{title})>0
|
||||
</if>
|
||||
<if test="null!=type and type!=''">
|
||||
and instr(type.name,#{type})>0
|
||||
</if>
|
||||
<if test="null!=startTime">
|
||||
and n.send_time >= #{startTime}
|
||||
</if>
|
||||
<if test="null != endTime">
|
||||
and n.end_time < #{endTime}
|
||||
</if>
|
||||
and notice_receive.user_id=#{userId}
|
||||
and notice_receive.deleted=0
|
||||
</where>
|
||||
|
||||
Reference in New Issue
Block a user