Przeglądaj źródła

管理员系统消息推送(列表\新增\删除\修改\推送)

limin 7 lat temu
rodzic
commit
9ff0e563de

+ 2 - 0
src/main/java/com/goafanti/common/dao/JtMessageConsumerMapper.java

@@ -74,4 +74,6 @@ public interface JtMessageConsumerMapper {
 	 * @mbggenerated  Wed Aug 29 09:46:33 CST 2018
 	 */
 	int updateByPrimaryKey(JtMessageConsumer record);
+	
+	int addBatch(List<JtMessageConsumer> list);
 }

+ 2 - 0
src/main/java/com/goafanti/common/dao/JtMessageProducerMapper.java

@@ -75,4 +75,6 @@ public interface JtMessageProducerMapper {
 	int updateByPrimaryKey(JtMessageProducer record);
 
 	int addBatch(List<JtMessageProducer> list);
+	
+	List<JtMessageProducer> getMyMessageList(String create);
 }

+ 4 - 1
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -6,12 +6,13 @@ import org.apache.ibatis.annotations.Param;
 
 import com.goafanti.app.bo.UserBasicInfo;
 import com.goafanti.common.model.Admin;
+import com.goafanti.common.model.JtMessageConsumer;
 import com.goafanti.common.model.OrganizationContactBook;
 import com.goafanti.common.model.User;
+import com.goafanti.common.model.UserExample;
 import com.goafanti.user.bo.UserBaseBo;
 import com.goafanti.user.bo.UserDownLoadBo;
 import com.goafanti.user.bo.UserPartnerDetailBo;
-import com.goafanti.common.model.UserExample;
 
 public interface UserMapper {
 	/**
@@ -108,4 +109,6 @@ public interface UserMapper {
 	
 
 	List<UserPartnerDetailBo> findUserPartner();
+	
+	List<JtMessageConsumer> getAllUser();
 }

+ 55 - 0
src/main/java/com/goafanti/common/mapper/JtMessageProducerMapper.xml

@@ -393,4 +393,59 @@
       delete_sign = #{deleteSign,jdbcType=BIT}
     where id = #{id,jdbcType=VARCHAR}
   </update>
+  
+  <!-- 获得自己发送的消息列表数据 -->
+  <select id="getMyMessageList" parameterType="java.lang.String" resultType="com.goafanti.common.model.JtMessageProducer">
+  	select 
+    id, creater, create_time as createTime, send_time as sendTime, title, body, subject, 
+    resource_id as resourceId, resource_type as resourceType, 
+    is_draft as isDraft, is_send as isSend, delete_sign as deleteSign
+    from jt_message_producer
+    where delete_sign = 0 
+    <if test="title != null">
+    <bind name="t" value="'%' + title + '%' "/>
+    and title like #{t,jdbcType=VARCHAR}
+    </if>
+    <if test="isDraft != null">
+    and is_draft = #{isDraft,jdbcType=BIT}
+    </if>
+    <if test="isSend != null">
+    and is_send = #{isSend,jdbcType=BIT}
+    </if>
+    <if test="deleteSign != null">
+    and delete_sign = #{deleteSign,jdbcType=BIT}
+    </if>
+    <if test="creater != null">
+    and creater = #{creater,jdbcType=VARCHAR}
+    </if>
+    <if test="sendStartTime != null and sendEndTime != null">
+    and send_time between #{sendStartTime,jdbcType=VARCHAR}  and #{sendEndTime,jdbcType=VARCHAR}
+    </if>
+    order by create_time desc
+    <if test="page_sql!=null">
+        ${page_sql}
+    </if>
+  </select>
+  <select id="getMyMessageCount" parameterType="java.lang.String" resultType="java.lang.Integer">
+  	select 
+    count(0)
+    from jt_message_producer
+    where delete_sign = 0 
+    <if test="title != null">
+    <bind name="t" value="'%' + title + '%' "/>
+    and title like #{t,jdbcType=VARCHAR}
+    </if>
+    <if test="isDraft != null">
+    and is_draft = #{isDraft,jdbcType=BIT}
+    </if>
+    <if test="isSend != null">
+    and is_send = #{isSend,jdbcType=BIT}
+    </if>
+    <if test="creater != null">
+    and creater = #{creater,jdbcType=VARCHAR}
+    </if>
+    <if test="sendStartTime != null and sendEndTime != null">
+    and send_time between #{sendStartTime,jdbcType=VARCHAR}  and #{sendEndTime,jdbcType=VARCHAR}
+    </if>
+  </select>
 </mapper>

+ 7 - 0
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -1174,4 +1174,11 @@
 		u.source =0 and i.expert=1
 		limit 0,50
 	</select>
+	<resultMap id="regUserMap" type="com.goafanti.common.model.JtMessageConsumer">
+    <result column="id" jdbcType="VARCHAR" property="aid" />
+  </resultMap>
+	<!-- 查找所有正常的注册用户数据 -->
+	<select id="getAllUser" resultMap="regUserMap">
+	 select id from user where status = 0 and source = 0 
+	</select>
 </mapper>

+ 113 - 13
src/main/java/com/goafanti/message/controller/AdminMessageController.java

@@ -22,10 +22,12 @@ import com.goafanti.common.error.BusinessException;
 import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.utils.DateUtils;
+import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.message.bo.MessageListBo;
 import com.goafanti.message.enums.ConsumerType;
 import com.goafanti.message.enums.RecommendType;
 import com.goafanti.message.enums.SubjectType;
+import com.goafanti.message.service.JtMessageProducerService;
 import com.goafanti.message.service.MessageService;
 
 /**
@@ -38,6 +40,8 @@ import com.goafanti.message.service.MessageService;
 public class AdminMessageController extends CertifyApiController{
 	@Resource
 	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();
-		//必填项的检查
 		if(StringUtils.isBlank(messageProducer.getTitle())){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"", "消息标题不能为空"));
 		}
@@ -301,15 +308,108 @@ public class AdminMessageController extends CertifyApiController{
 		if(null == messageProducer.getIsDraft()){
 			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;
 	}
 	
-	@RequestMapping(value="/sendMessage", method=RequestMethod.GET)
+	/**
+	 * 发送消息接口
+	 * @param messageId
+	 * @return
+	 */
+	@RequestMapping(value = "/sendMessage", method = RequestMethod.GET)
 	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;
 	}
 }

Plik diff jest za duży
+ 41 - 0
src/main/java/com/goafanti/message/service/JtMessageProducerService.java


+ 0 - 13
src/main/java/com/goafanti/message/service/MessageService.java

@@ -6,7 +6,6 @@ import java.util.Map;
 
 import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.model.JpushEasemobAccount;
-import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -161,17 +160,5 @@ public interface MessageService {
 	 */
 	JpushEasemobAccount selectSynAccByUid(String uid);
 	
-	/**
-	 * 新增系统消息
-	 * @param messageProducer
-	 * @return
-	 */
-	int addMessage(JtMessageProducer messageProducer);
 	
-	/**
-	 * 系统向注册用户发送信息
-	 * @param messageId
-	 * @return
-	 */
-	int sendMessage(String messageId);
 }

+ 101 - 0
src/main/java/com/goafanti/message/service/impl/JtMessageProducerServiceImpl.java

@@ -0,0 +1,101 @@
+package com.goafanti.message.service.impl;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.goafanti.common.dao.JtMessageConsumerMapper;
+import com.goafanti.common.dao.JtMessageProducerMapper;
+import com.goafanti.common.dao.UserMapper;
+import com.goafanti.common.model.JtMessageConsumer;
+import com.goafanti.common.model.JtMessageProducer;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.message.service.JtMessageProducerService;
+
+@Service
+public class JtMessageProducerServiceImpl  extends BaseMybatisDao<JtMessageProducerMapper> implements JtMessageProducerService{
+	@Autowired
+	private JtMessageProducerMapper jtMessageProducerMapper;
+	@Autowired
+	private UserMapper userMapper;
+	@Autowired
+	private JtMessageConsumerMapper jtMessageConsumerMapper;
+	
+
+	@Override
+	public int addMessage(JtMessageProducer messageProducer) {
+		//处理消息内容
+		messageProducer.setId(UUID.randomUUID().toString());
+		//获得当前登录用户名字
+		String create = userMapper.selectByPrimaryKey(TokenManager.getUserId()).getUsername();
+		messageProducer.setCreater(create);
+		if(null != messageProducer.getCreateTime()){
+			messageProducer.setCreateTime(new Date());
+		}
+		return jtMessageProducerMapper.insertSelective(messageProducer);
+	}
+	
+	@Override
+	public int addSendMessage(String messageId) {
+		// 获得所有正常使用的注册用户
+		List<JtMessageConsumer> list = userMapper.getAllUser();
+		Iterator<JtMessageConsumer> it = list.iterator();
+		while (it.hasNext()) {
+			JtMessageConsumer mc = (JtMessageConsumer) it.next();
+			mc.setId(UUID.randomUUID().toString());
+			mc.setMessageId(messageId);
+		}
+		JtMessageProducer messageProducer = new JtMessageProducer();
+		messageProducer.setId(messageId);
+		messageProducer.setSendTime(new Date());
+		messageProducer.setIsSend(true);
+		messageProducer.setIsDraft(false);
+		jtMessageProducerMapper.updateByPrimaryKeySelective(messageProducer);
+		return jtMessageConsumerMapper.addBatch(list);
+	}
+
+	@Override
+	public JtMessageProducer getMessageById(String messageId) {
+		return jtMessageProducerMapper.selectByPrimaryKey(messageId);
+	}
+
+	@Override
+	public int updateMessageById(JtMessageProducer messageProducer) {
+		int count = 0;
+		// 推送消息
+		if(messageProducer.getIsSend() && !messageProducer.getDeleteSign() && !messageProducer.getIsDraft()){
+			if(null == messageProducer.getSendTime()) messageProducer.setSendTime(new Date());
+			count += addSendMessage(messageProducer.getId());
+		}
+		// 修改消息
+		messageProducer.setCreateTime(null);//不修改创建时间
+		count = jtMessageProducerMapper.updateByPrimaryKeySelective(messageProducer);
+		return count;
+	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<JtMessageProducer> getMessageList(JtMessageProducer messageProducer, String sendStartTime, String sendEndTime, Integer pageNo,Integer pageSize) {
+		if(pageNo==null || pageNo<1)pageNo=1;
+		if(pageSize==null ||pageSize<1)pageSize=10; 
+		Map<String, Object> params=new HashMap<String,Object>();
+		//params.put("create", TokenManager.getUserId());
+		if(StringUtils.isNotBlank(messageProducer.getTitle()))params.put("title",messageProducer.getTitle());
+		if(null != messageProducer.getIsDraft())params.put("isDraft",messageProducer.getIsDraft());
+		if(null != messageProducer.getIsSend())params.put("isSend",messageProducer.getIsSend());
+		if(StringUtils.isNotBlank(sendStartTime))params.put("sendStartTime",sendStartTime);
+		if(StringUtils.isNotBlank(sendEndTime))params.put("sendEndTime",sendEndTime);
+		return (Pagination<JtMessageProducer>) findPage("getMyMessageList", "getMyMessageCount", params, pageNo, pageSize);
+	}
+
+
+}

+ 6 - 20
src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java

@@ -16,12 +16,13 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.dao.JpushEasemobAccountMapper;
+import com.goafanti.common.dao.JtMessageConsumerMapper;
 import com.goafanti.common.dao.JtMessageProducerMapper;
 import com.goafanti.common.dao.MessageFromSystemMapper;
 import com.goafanti.common.dao.MessageProducerMapper;
+import com.goafanti.common.dao.UserMapper;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.JpushEasemobAccount;
-import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -49,6 +50,10 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 	private JGMessageHelper jgMessageHelper;
 	@Autowired
 	private JtMessageProducerMapper jtMessageProducerMapper;
+	@Autowired
+	private UserMapper userMapper;
+	@Autowired
+	private JtMessageConsumerMapper jtMessageConsumerMapper;
 	@Override
 	public String selectSendUser(Map<Integer, String> selectMap,Integer type) {
 		if(selectMap.containsKey(ConsumerType.PERSON_CUSTOMER_RETAIL.getTypeCode())){ //客户散户
@@ -433,23 +438,4 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 		return jpushEasemobAccountMapper.insert(jea);
 	}
 
-	@Override
-	public int addMessage(JtMessageProducer messageProducer) {
-		//处理消息内容
-		messageProducer.setId(UUID.randomUUID().toString());
-		messageProducer.setCreater(TokenManager.getUserId());
-		if(null != messageProducer.getCreateTime()){
-			messageProducer.setCreateTime(new Date());
-		}
-		return jtMessageProducerMapper.insertSelective(messageProducer);
-	}
-	
-	@Override
-	public int sendMessage(String messageId) {
-		// 获得所有正常使用的注册用户
-		//List<JtMessageProducer> list = 
-		return 0;
-	}
-
-
 }

Plik diff jest za duży
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/patent.html