Переглянути джерело

Merge remote-tracking branch 'origin/master' into test

Conflicts:
	src/main/java/com/goafanti/common/dao/JtMessageConsumerMapper.java
	src/main/java/com/goafanti/common/dao/UserMapper.java
	src/main/java/com/goafanti/common/mapper/UserMapper.xml
	src/main/java/com/goafanti/message/service/MessageService.java
	src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java
limin 7 роки тому
батько
коміт
4e7359e833

+ 3 - 2
GeneratorConfig.xml

@@ -5,11 +5,12 @@
   <!-- <classPathEntry location="E:/mysql-connector-java-5.1.46.jar" /> -->
   <context id="context1">	
  	<property name="javaFileEncoding" value="UTF-8"/>
-    <jdbcConnection connectionURL="jdbc:mysql://192.168.1.213:3306/aft" 
+    <jdbcConnection connectionURL="jdbc:mysql://192.168.0.17:3306/aft" 
     	driverClass="com.mysql.jdbc.Driver" password="123456" userId="dev" />
    <javaModelGenerator targetPackage="com.goafanti.common.model" targetProject="jitao-server" />
    <sqlMapGenerator targetPackage="com.goafanti.common.mapper" targetProject="jitao-server" />
    <javaClientGenerator targetPackage="com.goafanti.common.dao" targetProject="jitao-server" type="XMLMAPPER" />
-   <table schema="aft" tableName="jt_consult_order"/>
+   <table schema="aft" tableName="jt_message_producer"/>
+   <table schema="aft" tableName="jt_message_consumer"/>
   </context>
 </generatorConfiguration>

+ 3 - 1
src/main/java/com/goafanti/common/dao/JtMessageConsumerMapper.java

@@ -78,4 +78,6 @@ public interface JtMessageConsumerMapper {
 	int updateByPrimaryKey(JtMessageConsumer record);
 
 	AppMessageBo selectById(String id);
-}
+	
+	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);
 }

+ 5 - 2
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 {
 	/**
@@ -110,4 +111,6 @@ public interface UserMapper {
 	List<UserPartnerDetailBo> findUserPartner();
 
 	Integer selectByMobieAndTypeCount(String mobile);
-}
+	
+	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>

+ 10 - 1
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -1181,4 +1181,13 @@
     from user
     where mobile = #{0} and source = 0
   </select>
-</mapper>
+
+  <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;
 	}
 }

Різницю між файлами не показано, бо вона завелика
+ 41 - 0
src/main/java/com/goafanti/message/service/JtMessageProducerService.java


+ 2 - 14
src/main/java/com/goafanti/message/service/MessageService.java

@@ -6,8 +6,6 @@ import java.util.Map;
 
 import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.model.JpushEasemobAccount;
-import com.goafanti.common.model.JtMessageConsumer;
-import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -162,20 +160,10 @@ public interface MessageService {
 	 * @return
 	 */
 	JpushEasemobAccount selectSynAccByUid(String uid);
+
 	 Pagination<AppMessageBo> applistMessage(Integer pageNo, Integer pageSize);
 	 AppMessageBo updateAppReadMessage(String id);
 		
-	/**
-	 * 新增系统消息
-	 * @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);
+	}
+
+
+}

+ 1 - 16
src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java

@@ -1,6 +1,5 @@
 package com.goafanti.message.service.impl;
 
-import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -9,7 +8,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +23,6 @@ import com.goafanti.common.dao.MessageProducerMapper;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.JpushEasemobAccount;
 import com.goafanti.common.model.JtMessageConsumer;
-import com.goafanti.common.model.JtMessageProducer;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
@@ -461,18 +458,6 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 		return jtMessageConsumerMapper.selectById(id);
 	}
 
-	@Override
-	public int addMessage(JtMessageProducer messageProducer) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	@Override
-	public int sendMessage(String messageId) {
-		// TODO Auto-generated method stub
-		return 0;
-	}
-
-	
+	
 
 }

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
src/main/webapp/WEB-INF/views/portal/service/patent.html