|
|
|
@ -1,14 +1,16 @@
|
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.mq.I3CoreQueueConfig;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
@ -17,11 +19,15 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -44,21 +50,18 @@ public class SysMessageController {
|
|
|
|
|
@ApiOperation(value = "新增消息",notes = "新增消息")
|
|
|
|
|
public ResultBean insertSysMessage(SysMessage sysMessage){
|
|
|
|
|
try {
|
|
|
|
|
// 登录用户
|
|
|
|
|
SessionUser user = AuthUtil.getSessionUser();
|
|
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
// 条件校验
|
|
|
|
|
ValidatorBean.beginValid(sysMessage)
|
|
|
|
|
.notNull("messageTitle",sysMessage.getMessageTitle())
|
|
|
|
|
.notNull("messageContent",sysMessage.getMessageContent())
|
|
|
|
|
.checkNotZero("messageType",sysMessage.getMessageTypeId())
|
|
|
|
|
.notNull("messageRecipientId",sysMessage.getMessageRecipientId());
|
|
|
|
|
.checkNotZero("messageType",sysMessage.getMessageType())
|
|
|
|
|
.notNull("messageReceiversId",sysMessage.getMessageReceiversId());
|
|
|
|
|
|
|
|
|
|
// 添加初始化
|
|
|
|
|
ConvertBean.modelInitialize(sysMessage,user);
|
|
|
|
|
// 设置发件人名称
|
|
|
|
|
// sysMessage.setMessageSendId(user.getUser().getId());
|
|
|
|
|
// sysMessage.setRedSendName(user.getUser().getName());
|
|
|
|
|
sysMessage.setMessageStatusId(ImppEnumUtil.USER_MESSAGE_STATUS.UNREAD.getValue());
|
|
|
|
|
sysMessage.setMessageSendTime(sdf.format(new Date()));
|
|
|
|
|
|
|
|
|
|
sysMessageService.insertSysMessage(sysMessage);
|
|
|
|
|
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
@ -100,11 +103,7 @@ public class SysMessageController {
|
|
|
|
|
ValidatorBean.beginValid(sysMessage)
|
|
|
|
|
.notNull("messageTitle",sysMessage.getMessageTitle())
|
|
|
|
|
.notNull("messageContent",sysMessage.getMessageContent())
|
|
|
|
|
.checkNotZero("messageType",sysMessage.getMessageTypeId())
|
|
|
|
|
.notNull("messageRecipientId",sysMessage.getMessageRecipientId());
|
|
|
|
|
|
|
|
|
|
// 修改初始化
|
|
|
|
|
ConvertBean.modelUpdate(sysMessage,user);
|
|
|
|
|
.checkNotZero("messageType",sysMessage.getMessageType());
|
|
|
|
|
|
|
|
|
|
sysMessageService.updateSysMessage(sysMessage);
|
|
|
|
|
return ResultBean.success("修改成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
@ -166,23 +165,23 @@ public class SysMessageController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping("/status")
|
|
|
|
|
public ResultBean updateSysMessageStatusById(String id,Integer status){
|
|
|
|
|
try {
|
|
|
|
|
// 条件校验
|
|
|
|
|
ValidatorBean.checkNotNull(id,"id不能为空");
|
|
|
|
|
ValidatorBean.checkNotZero(status,"修改状态值不能为空");
|
|
|
|
|
|
|
|
|
|
sysMessageService.updateSysMessageStatusById(id,status);
|
|
|
|
|
return ResultBean.success("修改成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// @PutMapping("/status")
|
|
|
|
|
// public ResultBean updateSysMessageStatusById(String id,Integer status){
|
|
|
|
|
// try {
|
|
|
|
|
// // 条件校验
|
|
|
|
|
// ValidatorBean.checkNotNull(id,"id不能为空");
|
|
|
|
|
// ValidatorBean.checkNotZero(status,"修改状态值不能为空");
|
|
|
|
|
//
|
|
|
|
|
// sysMessageService.updateSysMessageStatusById(id,status);
|
|
|
|
|
// return ResultBean.success("修改成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
// }catch(ImppBusiException busExcep){
|
|
|
|
|
// LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
// return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
// }catch(Exception e){
|
|
|
|
|
// LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
// return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("/batch-delete")
|
|
|
|
|
@ApiOperation(value = "批量删除消息",notes = "批量删除消息")
|
|
|
|
@ -208,28 +207,28 @@ public class SysMessageController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PutMapping("/batch-status")
|
|
|
|
|
@ApiOperation(value = "批量切换消息状态",notes = "批量切换消息状态")
|
|
|
|
|
public ResultBean updateSysMessageStatusByIds(String[] ids,Integer status){
|
|
|
|
|
try{
|
|
|
|
|
// 条件判断
|
|
|
|
|
ValidatorBean.checkNotZero(status,"状态不能为空");
|
|
|
|
|
ids = ConvertBean.modelSafeArrayNumber(ids,true);
|
|
|
|
|
if(ids.length == 0){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("请选择需要操作的资源。")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
sysMessageService.updateSysMessageStatusByIds(ids,status);
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// @PutMapping("/batch-status")
|
|
|
|
|
// @ApiOperation(value = "批量切换消息状态",notes = "批量切换消息状态")
|
|
|
|
|
// public ResultBean updateSysMessageStatusByIds(String[] ids,Integer status){
|
|
|
|
|
// try{
|
|
|
|
|
// // 条件判断
|
|
|
|
|
// ValidatorBean.checkNotZero(status,"状态不能为空");
|
|
|
|
|
// ids = ConvertBean.modelSafeArrayNumber(ids,true);
|
|
|
|
|
// if(ids.length == 0){
|
|
|
|
|
// throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
// .setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
// .setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
// .setErrorDetail("请选择需要操作的资源。")
|
|
|
|
|
// .build();
|
|
|
|
|
// }
|
|
|
|
|
// sysMessageService.updateSysMessageStatusByIds(ids,status);
|
|
|
|
|
// return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
// }catch(ImppBusiException busExcep){
|
|
|
|
|
// LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
// return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
|
// }catch(Exception e){
|
|
|
|
|
// LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
// return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|