禁止超管读取消息

This commit is contained in:
季圣华
2021-12-17 00:09:54 +08:00
parent e048075538
commit 76f3ac76d7

View File

@@ -80,11 +80,14 @@ public class MsgService {
public List<MsgEx> select(String name, int offset, int rows)throws Exception { public List<MsgEx> select(String name, int offset, int rows)throws Exception {
List<MsgEx> list=null; List<MsgEx> list=null;
try{ try{
list = msgMapperEx.selectByConditionMsg(name, offset, rows); User userInfo = userService.getCurrentUser();
if (null != list) { if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
for (MsgEx msgEx : list) { list = msgMapperEx.selectByConditionMsg(name, offset, rows);
if(msgEx.getCreateTime() != null) { if (null != list) {
msgEx.setCreateTimeStr(getCenternTime(msgEx.getCreateTime())); for (MsgEx msgEx : list) {
if (msgEx.getCreateTime() != null) {
msgEx.setCreateTimeStr(getCenternTime(msgEx.getCreateTime()));
}
} }
} }
} }
@@ -100,7 +103,10 @@ public class MsgService {
public Long countMsg(String name)throws Exception { public Long countMsg(String name)throws Exception {
Long result=null; Long result=null;
try{ try{
result=msgMapperEx.countsByMsg(name); User userInfo = userService.getCurrentUser();
if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
result = msgMapperEx.countsByMsg(name);
}
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -226,20 +232,23 @@ public class MsgService {
public List<MsgEx> getMsgByStatus(String status)throws Exception { public List<MsgEx> getMsgByStatus(String status)throws Exception {
List<MsgEx> resList=new ArrayList<>(); List<MsgEx> resList=new ArrayList<>();
try{ try{
MsgExample example = new MsgExample(); User userInfo = userService.getCurrentUser();
example.createCriteria().andStatusEqualTo(status).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
List<Msg> list = msgMapper.selectByExample(example); MsgExample example = new MsgExample();
if (null != list) { example.createCriteria().andStatusEqualTo(status).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
for (Msg msg : list) { List<Msg> list = msgMapper.selectByExample(example);
if(msg.getCreateTime() != null) { if (null != list) {
MsgEx msgEx = new MsgEx(); for (Msg msg : list) {
msgEx.setId(msg.getId()); if (msg.getCreateTime() != null) {
msgEx.setMsgTitle(msg.getMsgTitle()); MsgEx msgEx = new MsgEx();
msgEx.setMsgContent(msg.getMsgContent()); msgEx.setId(msg.getId());
msgEx.setStatus(msg.getStatus()); msgEx.setMsgTitle(msg.getMsgTitle());
msgEx.setType(msg.getType()); msgEx.setMsgContent(msg.getMsgContent());
msgEx.setCreateTimeStr(Tools.parseDateToStr(msg.getCreateTime())); msgEx.setStatus(msg.getStatus());
resList.add(msgEx); msgEx.setType(msg.getType());
msgEx.setCreateTimeStr(Tools.parseDateToStr(msg.getCreateTime()));
resList.add(msgEx);
}
} }
} }
} }
@@ -273,7 +282,9 @@ public class MsgService {
Long result=null; Long result=null;
try{ try{
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
result=msgMapperEx.getMsgCountByStatus(status, userInfo.getId()); if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
result = msgMapperEx.getMsgCountByStatus(status, userInfo.getId());
}
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -286,10 +297,13 @@ public class MsgService {
public Integer getMsgCountByType(String type)throws Exception { public Integer getMsgCountByType(String type)throws Exception {
int msgCount = 0; int msgCount = 0;
try{ try{
MsgExample example = new MsgExample(); User userInfo = userService.getCurrentUser();
example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); if(!BusinessConstants.DEFAULT_MANAGER.equals(userInfo.getLoginName())) {
List<Msg> list = msgMapper.selectByExample(example); MsgExample example = new MsgExample();
msgCount = list.size(); example.createCriteria().andTypeEqualTo(type).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Msg> list = msgMapper.selectByExample(example);
msgCount = list.size();
}
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e); ExceptionConstants.DATA_READ_FAIL_CODE, ExceptionConstants.DATA_READ_FAIL_MSG,e);