|
@@ -22,10 +22,12 @@ import com.goafanti.common.error.BusinessException;
|
|
|
import com.goafanti.common.model.JtMessageProducer;
|
|
import com.goafanti.common.model.JtMessageProducer;
|
|
|
import com.goafanti.common.model.MessageFromSystem;
|
|
import com.goafanti.common.model.MessageFromSystem;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
|
|
+import com.goafanti.core.shiro.token.TokenManager;
|
|
|
import com.goafanti.message.bo.MessageListBo;
|
|
import com.goafanti.message.bo.MessageListBo;
|
|
|
import com.goafanti.message.enums.ConsumerType;
|
|
import com.goafanti.message.enums.ConsumerType;
|
|
|
import com.goafanti.message.enums.RecommendType;
|
|
import com.goafanti.message.enums.RecommendType;
|
|
|
import com.goafanti.message.enums.SubjectType;
|
|
import com.goafanti.message.enums.SubjectType;
|
|
|
|
|
+import com.goafanti.message.service.JtMessageProducerService;
|
|
|
import com.goafanti.message.service.MessageService;
|
|
import com.goafanti.message.service.MessageService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -38,6 +40,8 @@ import com.goafanti.message.service.MessageService;
|
|
|
public class AdminMessageController extends CertifyApiController{
|
|
public class AdminMessageController extends CertifyApiController{
|
|
|
@Resource
|
|
@Resource
|
|
|
private MessageService messageService;
|
|
private MessageService messageService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JtMessageProducerService jtMessageProducerService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 进入创建系统消息
|
|
* 进入创建系统消息
|
|
@@ -283,15 +287,18 @@ public class AdminMessageController extends CertifyApiController{
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 新增消息接口
|
|
|
|
|
- * @param messageProducer
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @RequestMapping(value="/addMessage", method=RequestMethod.GET)
|
|
|
|
|
- public Result addMessage(JtMessageProducer messageProducer){
|
|
|
|
|
|
|
+ //消息编号检查
|
|
|
|
|
+ private Result checkMessageId(String messageId){
|
|
|
|
|
+ Result res = new Result();
|
|
|
|
|
+ if(StringUtils.isBlank(messageId)){
|
|
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息编号不能为空"));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //消息数据检查
|
|
|
|
|
+ private Result checkMessage(JtMessageProducer messageProducer){
|
|
|
Result res = new Result();
|
|
Result res = new Result();
|
|
|
- //必填项的检查
|
|
|
|
|
if(StringUtils.isBlank(messageProducer.getTitle())){
|
|
if(StringUtils.isBlank(messageProducer.getTitle())){
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息标题不能为空"));
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息标题不能为空"));
|
|
|
}
|
|
}
|
|
@@ -301,15 +308,108 @@ public class AdminMessageController extends CertifyApiController{
|
|
|
if(null == messageProducer.getIsDraft()){
|
|
if(null == messageProducer.getIsDraft()){
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息是否为草稿没指定"));
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息是否为草稿没指定"));
|
|
|
}
|
|
}
|
|
|
- if (res.getError().isEmpty()) {
|
|
|
|
|
- //新增消息
|
|
|
|
|
- res.setData(messageService.addMessage(messageProducer));
|
|
|
|
|
|
|
+ if(null == messageProducer.getIsSend()){
|
|
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息是否要发送没指定"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if(null == messageProducer.getDeleteSign()){
|
|
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息是否为删除没指定"));
|
|
|
}
|
|
}
|
|
|
return res;
|
|
return res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @RequestMapping(value="/sendMessage", method=RequestMethod.GET)
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送消息接口
|
|
|
|
|
+ * @param messageId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/sendMessage", method = RequestMethod.GET)
|
|
|
public Result sendMessage(String messageId){
|
|
public Result sendMessage(String messageId){
|
|
|
- return null;
|
|
|
|
|
|
|
+ Result res = checkMessageId(messageId);
|
|
|
|
|
+ if (res.getError().isEmpty()) {
|
|
|
|
|
+ //发送消息
|
|
|
|
|
+ res.setData(jtMessageProducerService.addSendMessage(messageId));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获得单个消息数据接口
|
|
|
|
|
+ * @param messageId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value="/getMessageById", method = RequestMethod.GET)
|
|
|
|
|
+ public Result getMessageById(String messageId){
|
|
|
|
|
+ Result res = checkMessageId(messageId);
|
|
|
|
|
+ if (res.getError().isEmpty()) {
|
|
|
|
|
+ //查看消息
|
|
|
|
|
+ res.setData(jtMessageProducerService.getMessageById(messageId));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改消息接口
|
|
|
|
|
+ * @param messageProducer
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value="/updMessageById", method = RequestMethod.POST)
|
|
|
|
|
+ public Result updMessageById(JtMessageProducer messageProducer, String messageSendTime){
|
|
|
|
|
+ Result res = checkMessageId(messageProducer.getId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ messageProducer.setSendTime(DateUtils.parseDate(messageSendTime,AFTConstants.YYYYMMDDHHMMSS));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ messageProducer.setSendTime(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (res.getError().isEmpty()) {
|
|
|
|
|
+ //查看消息
|
|
|
|
|
+ res.setData(jtMessageProducerService.updateMessageById(messageProducer));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获得消息列表
|
|
|
|
|
+ * @param messageProducer
|
|
|
|
|
+ * @param sendStartTime
|
|
|
|
|
+ * @param sendEndTime
|
|
|
|
|
+ * @param pageNo
|
|
|
|
|
+ * @param pageSize
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value="/getMessageList", method = RequestMethod.GET)
|
|
|
|
|
+ public Result getMessageList(JtMessageProducer messageProducer,String sendStartTime, String sendEndTime, Integer pageNo,Integer pageSize ){
|
|
|
|
|
+ Result res = new Result();
|
|
|
|
|
+ if(StringUtils.isBlank(TokenManager.getUserId())){
|
|
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "登录数据失效"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (res.getError().isEmpty()) {
|
|
|
|
|
+ //查看消息列表
|
|
|
|
|
+ res.setData(jtMessageProducerService.getMessageList(messageProducer, sendStartTime, sendEndTime, pageNo, pageSize ));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 新增消息接口
|
|
|
|
|
+ * @param messageProducer
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value="/createMyMessage", method = RequestMethod.POST)
|
|
|
|
|
+ public Result createMyMessage(JtMessageProducer messageProducer, String messageCreateTime){
|
|
|
|
|
+ try {
|
|
|
|
|
+ messageProducer.setCreateTime(DateUtils.parseDate(messageCreateTime,AFTConstants.YYYYMMDDHHMMSS));
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ messageProducer.setCreateTime(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ Result res = checkMessage(messageProducer);
|
|
|
|
|
+ if(StringUtils.isBlank(TokenManager.getUserId())){
|
|
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "登录数据失效"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (res.getError().isEmpty()) {
|
|
|
|
|
+ //新增消息
|
|
|
|
|
+ res.setData(jtMessageProducerService.addMessage(messageProducer));
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|