|
@@ -40,41 +40,35 @@ public class TNoticeController {
|
|
|
TNoticeService noticeService;
|
|
|
@ApiOperation(value = "获取公告")
|
|
|
@GetMapping("/getNotice")
|
|
|
- public ResponseModel<?> getNotice(String id) {
|
|
|
- if(StringUtils.isEmpty(id)){
|
|
|
+ public ResponseModel<?> getNotice(String adminId) {
|
|
|
+ if(StringUtils.isEmpty(adminId)){
|
|
|
return R.fail(ResponseCodesEnum.A0001,"数据有空");
|
|
|
}
|
|
|
- TAdmin admin = tAdminService.getById(id);
|
|
|
+ TAdmin admin = tAdminService.getById(adminId);
|
|
|
LambdaQueryWrapper<TNotice> query = Wrappers.lambdaQuery();
|
|
|
- if(admin.getNoticeId()!=null){
|
|
|
- Long noticeId = admin.getNoticeId();
|
|
|
- query.gt(TNotice::getId,noticeId);
|
|
|
- }
|
|
|
query.eq(TNotice::getStatus,0);
|
|
|
- query.gt(TNotice::getCreateDate,admin.getCreateDate());
|
|
|
- List<TNotice> noticeList = noticeService.list(query);
|
|
|
- if(noticeList.size()<1){
|
|
|
- return R.ok(noticeList,"没有公告");
|
|
|
- }else {
|
|
|
- return R.ok(noticeList.get(0),"获取成功");
|
|
|
+ query.orderByDesc(TNotice::getCreateDate);
|
|
|
+ List<TNotice> notices = noticeService.list(query);
|
|
|
+ if(notices == null){
|
|
|
+ return R.fail(ResponseCodesEnum.A0700,"没有公告");
|
|
|
}
|
|
|
+ TNotice tNotice = notices.get(0);
|
|
|
+ Long noticeId = admin.getNoticeId();
|
|
|
+ long time = tNotice.getCreateDate().getTime();
|
|
|
+ if(noticeId > time) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0700,"公告已读");
|
|
|
+ }
|
|
|
+ return R.ok(tNotice,"获取成功");
|
|
|
}
|
|
|
@GetMapping("/updateNotice")
|
|
|
- public ResponseModel<?> updateNotice(String adminId,String noticeId) {
|
|
|
- if(StringUtils.isEmpty(adminId)&&StringUtils.isEmpty(noticeId)){
|
|
|
+ public ResponseModel<?> updateNotice(String adminId) {
|
|
|
+ if(StringUtils.isEmpty(adminId)){
|
|
|
return R.fail(ResponseCodesEnum.A0001,"数据有空");
|
|
|
}
|
|
|
TAdmin admin = tAdminService.getById(adminId);
|
|
|
- Long adminNoticeId = admin.getNoticeId();
|
|
|
- if(adminNoticeId!=null){
|
|
|
- if(adminNoticeId<Long.valueOf(noticeId)){
|
|
|
- admin.setNoticeId(Long.valueOf(noticeId));
|
|
|
- tAdminService.updateById(admin);
|
|
|
- }
|
|
|
- }else {
|
|
|
- admin.setNoticeId(Long.valueOf(noticeId));
|
|
|
- tAdminService.updateById(admin);
|
|
|
- }
|
|
|
+ Long dateNow = System.currentTimeMillis();
|
|
|
+ admin.setNoticeId(dateNow);
|
|
|
+ tAdminService.updateById(admin);
|
|
|
return R.ok(null,"公告已读");
|
|
|
}
|
|
|
}
|