Browse Source

通知列表和搜索功能

master
laishajiang 2 years ago
parent
commit
8a46cdc83e
  1. 20
      mailbox-lan/src/main/java/com/biutag/lan/controller/NoticeController.java
  2. 59
      mailbox-lan/src/main/java/com/biutag/lan/domain/vo/NoticeVo.java
  3. 54
      mailbox-lan/src/main/java/com/biutag/lan/service/NoticeService.java
  4. 19
      mailbox-lan/src/main/java/com/biutag/lan/validate/system/NoticeSearchValidate.java

20
mailbox-lan/src/main/java/com/biutag/lan/controller/NoticeController.java

@ -5,21 +5,32 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.biutag.aop.NotPower; import com.biutag.aop.NotPower;
import com.biutag.core.AjaxResult; import com.biutag.core.AjaxResult;
import com.biutag.core.PageResult;
import com.biutag.enums.RoleEnum; import com.biutag.enums.RoleEnum;
import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.config.AdminThreadLocal;
import com.biutag.lan.domain.Mail;
import com.biutag.lan.domain.Notice; import com.biutag.lan.domain.Notice;
import com.biutag.lan.domain.Work; import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.bo.MailQuery; import com.biutag.lan.domain.bo.MailQuery;
import com.biutag.lan.domain.vo.NoticeTotalVo; import com.biutag.lan.domain.vo.NoticeTotalVo;
import com.biutag.lan.domain.vo.NoticeVo;
import com.biutag.lan.domain.vo.QueryMailVo; import com.biutag.lan.domain.vo.QueryMailVo;
import com.biutag.lan.domain.vo.WorkVo; import com.biutag.lan.domain.vo.WorkVo;
import com.biutag.lan.flow.FlowNameEnum; import com.biutag.lan.flow.FlowNameEnum;
import com.biutag.lan.service.NoticeService; import com.biutag.lan.service.NoticeService;
import com.biutag.lan.service.WorkService; import com.biutag.lan.service.WorkService;
import com.biutag.lan.validate.commons.PageValidate;
import com.biutag.lan.validate.system.DutySearchValidate;
import com.biutag.lan.validate.system.NoticeSearchValidate;
import com.biutag.lan.vo.system.DutyListedVo;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/api/notice") @RequestMapping("/api/notice")
@ -58,4 +69,13 @@ public class NoticeController {
return AjaxResult.success(count > 0); return AjaxResult.success(count > 0);
} }
@NotPower
@GetMapping("list")
public AjaxResult<Page<NoticeVo>> list(Page<Notice> page, @Validated NoticeSearchValidate searchValidate) {
Page<NoticeVo> list = noticeService.list(page, searchValidate);
return AjaxResult.success(list);
}
} }

59
mailbox-lan/src/main/java/com/biutag/lan/domain/vo/NoticeVo.java

@ -0,0 +1,59 @@
package com.biutag.lan.domain.vo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
@Accessors(chain = true)
@Setter
@Getter
public class NoticeVo {
private static final long serialVersionUID = 1L;
private Integer id;
/**
* 警号
*/
private String empNo;
/**
*
*/
private Integer roleId;
private Integer deptId;
/**
* 标题
*/
private String title;
/**
* 内容
*/
private String content;
/**
* 是否已读 Y / N
*/
private String readFlag;
/**
* 通知类型
*/
private String type;
/**
*
*/
private String mailId;
/**
* 剩余时间
*/
private Integer remainderTime;
/**
*
*/
private String createTime;
private Integer workId;
}

54
mailbox-lan/src/main/java/com/biutag/lan/service/NoticeService.java

@ -1,21 +1,44 @@
package com.biutag.lan.service; package com.biutag.lan.service;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.biutag.constants.AppConstants; import com.biutag.constants.AppConstants;
import com.biutag.core.PageResult;
import com.biutag.entity.system.Duty;
import com.biutag.entity.system.PoliceUser;
import com.biutag.enums.RoleEnum; import com.biutag.enums.RoleEnum;
import com.biutag.lan.config.AdminThreadLocal; import com.biutag.lan.config.AdminThreadLocal;
import com.biutag.lan.domain.Notice; import com.biutag.lan.domain.Notice;
import com.biutag.lan.domain.Work; import com.biutag.lan.domain.Work;
import com.biutag.lan.domain.vo.NoticeTotalVo;
import com.biutag.lan.domain.vo.NoticeVo;
import com.biutag.lan.domain.vo.WorkVo;
import com.biutag.lan.flow.Flow;
import com.biutag.lan.flow.FlowNameEnum;
import com.biutag.lan.flow.node.FirstSignFlow;
import com.biutag.lan.mapper.NoticeMapper; import com.biutag.lan.mapper.NoticeMapper;
import com.biutag.lan.validate.commons.PageValidate;
import com.biutag.lan.validate.system.NoticeSearchValidate;
import com.biutag.lan.vo.system.DutyListedVo;
import com.biutag.util.StringUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects; import java.util.Objects;
@Slf4j @Slf4j
@ -69,4 +92,35 @@ public class NoticeService extends ServiceImpl<NoticeMapper, Notice> {
return page(page, queryWrapper); return page(page, queryWrapper);
} }
public Page<NoticeVo> list(Page<Notice> page, @Validated NoticeSearchValidate searchValidate){
LambdaQueryWrapper<Notice> queryWrapper = new LambdaQueryWrapper<Notice>().eq(Notice::getReadFlag, AppConstants.NO);
Integer roleId = AdminThreadLocal.getRoleId();
if (RoleEnum.isClasses(roleId)) {
queryWrapper.eq(Notice::getRoleId, roleId).eq(Notice::getDeptId, AdminThreadLocal.getDeptId());
} else {
queryWrapper.eq(Notice::getEmpNo, AdminThreadLocal.getEmpNo());
}
if (searchValidate.getSearchStartTime()!=null&&searchValidate.getSearchEndTime()!=null){
queryWrapper.ge(Notice::getCreateTime, searchValidate.getSearchStartTime()).le(Notice::getCreateTime, searchValidate.getSearchEndTime());
}
queryWrapper.orderByDesc(Notice::getCreateTime);
List<NoticeVo> list = new LinkedList<>();
Page<Notice> NoticePage = baseMapper.selectPage(page,queryWrapper);
for (Notice item : NoticePage.getRecords()){
NoticeVo vo = new NoticeVo();
BeanUtils.copyProperties(item, vo);
vo.setCreateTime(item.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
list.add(vo);
}
Page<NoticeVo> NoticePageVo = new Page<>();
NoticePageVo.setRecords(list);
NoticePageVo.setTotal(NoticePage.getTotal());
NoticePageVo.setCurrent(NoticePage.getCurrent());
NoticePageVo.setSize(NoticePage.getSize());
NoticePageVo.setPages(NoticePage.getPages());
return NoticePageVo;
}
} }

19
mailbox-lan/src/main/java/com/biutag/lan/validate/system/NoticeSearchValidate.java

@ -0,0 +1,19 @@
package com.biutag.lan.validate.system;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
@ApiModel("通知搜素参数")
public class NoticeSearchValidate implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "搜索时间")
private String searchStartTime;
@ApiModelProperty(value = "搜索时间")
private String searchEndTime;
}
Loading…
Cancel
Save