提交 f22ffcd7 authored 作者: xc's avatar xc

xc

上级 567be7a1
......@@ -15,4 +15,5 @@ public interface NoticeDao extends JpaRepository<Notice , Integer> {
Page<Notice> findOutBySenderAndType(String sender, int type, Pageable pageable);
Page<Notice> findOutByAddresseeLikeAndType(String addressee, int type, Pageable pageable);
List<Notice> findOutByStatusAndTypeAndLabel(int status, int type, int label);
Page<Notice> findOutByAddresseeLikeAndTypeAndStatus(String addressee, int type, Pageable pageable, int status);
}
......@@ -63,14 +63,23 @@ public class NoticeController {
}
@GetMapping("/getNoticeList")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2,status为状态,0 未读,1已读,2 全部")
@ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "account", dataType = "String"),
@ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int"),
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int")})
public ResponseEntity<Paging<Notice>> getNoticeList(@RequestParam String user, int type, int pageNum, int pageSize){
@ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "status", value = "状态", paramType = "query", required = true, dataType = "int")})
public ResponseEntity<Paging<Notice>> getNoticeList(@RequestParam String user, int type,
int pageNum, int pageSize, int status){
log.info("获取通知列表接口:{},{}", user,type);
Paging<Notice> data = noticeService.getReceiveList(user, type, pageNum, pageSize);
Paging<Notice> data = new Paging<>();
if (status == 2){
//全部
data = noticeService.getReceiveList(user, type, pageNum, pageSize);
}else {
data = noticeService.getListByStatus(user, status, pageNum, pageSize);
}
return ResponseEntity.ok(data);
}
......
......@@ -68,7 +68,7 @@ public class Notice {
@ApiModelProperty(value = "status", example = "0", dataType = "int" ,name = "通知状态",
notes = "未查看 0,已查看 1,已下载 2,默认 0")
@Column(name = "status")
private int status;
private Integer status;
/**
* 通知类型 接受 0,发送 1,草稿 2
......
......@@ -56,5 +56,17 @@ public interface NoticeService {
List<Notice> findBySender(String userId, int status, int type);
void saveNotice(Notice notice);
/**
* 获取已查看/未查看
* @param user 当前用户id
* @param status 通知状态
* @param pageNum
* @param pageSize
* @return
*/
Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize);
}
......@@ -285,5 +285,23 @@ public class NoticeServiceImpl implements NoticeService {
noticeDao.save(notice);
}
@Override
public Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize) {
try{
Pageable pageable = PageRequest.of(pageNum - 1, pageSize, Sort.Direction.DESC,"updateTime");
Page<Notice> p = noticeDao.findOutByAddresseeLikeAndTypeAndStatus(user, 0, pageable, status);
Paging<Notice> paging = new Paging<>();
paging.setData(p.getContent());
paging.setPageSize(pageSize);
paging.setPageNum(pageNum);
paging.setTotal((int)p.getTotalElements());
return paging;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论