增加全部设置未已读的功能的接口

This commit is contained in:
季圣华
2021-12-14 22:45:07 +08:00
parent b319148049
commit 8c54806ee5
2 changed files with 41 additions and 0 deletions

View File

@@ -130,4 +130,26 @@ public class MsgController {
} }
return res; return res;
} }
/**
* 全部设置未已读
* @param request
* @return
* @throws Exception
*/
@PostMapping("/readAllMsg")
@ApiOperation(value = "全部设置未已读")
public BaseResponseInfo readAllMsg(HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
msgService.readAllMsg();
res.code = 200;
res.data = "操作成功!";
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
} }

View File

@@ -298,4 +298,23 @@ public class MsgService {
} }
return msgCount; return msgCount;
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void readAllMsg() throws Exception{
try{
User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
Msg msg = new Msg();
msg.setStatus("2");
MsgExample example = new MsgExample();
example.createCriteria();
msgMapper.updateByExampleSelective(msg, example);
}
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_WRITE_FAIL_CODE, ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
ExceptionConstants.DATA_WRITE_FAIL_MSG);
}
}
} }