dcs hai 1 ano
pai
achega
4c4d2395bb

+ 13 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/model/MgrClient.java

@@ -92,6 +92,11 @@ public class MgrClient {
      */
     private String remark;
 
+    /**
+     * 状态
+     */
+    private int status;
+
 
     public long getId() {
         return id;
@@ -236,4 +241,12 @@ public class MgrClient {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public void setStatus(int status) {
+        this.status = status;
+    }
 }

+ 6 - 2
virgo.core/src/main/resources/mapper/MgrClientMapper.xml

@@ -23,13 +23,14 @@
         <result column="visitingChannels" property="visitingChannels"/>
         <result column="visitingTime" property="visitingTime"/>
         <result column="remark" property="remark"/>
+        <result column="status" property="status"/>
     </resultMap>
 
     <insert id="insert" parameterType="com.bosshand.virgo.core.model.MgrClient" useGeneratedKeys="true" keyProperty="id">
         INSERT INTO mgr_client(`organizationId`, `userId`, `name`, `type`, `person`, `phone`, `weChatAccount`, `followUpState`, `job`, `demand`, `decorationRequirements`,
-                               `customerIndustry`, `followUpPerson`, `firsTimeRoom`, `visitingChannels`, `visitingTime`, `remark`)
+                               `customerIndustry`, `followUpPerson`, `firsTimeRoom`, `visitingChannels`, `visitingTime`, `remark`, `status`)
         VALUES (#{organizationId}, #{userId}, #{name}, #{type}, #{person}, #{phone}, #{weChatAccount}, #{followUpState}, #{job}, #{demand}, #{decorationRequirements},
-                #{customerIndustry}, #{followUpPerson}, #{firsTimeRoom}, #{visitingChannels}, #{visitingTime}, #{remark})
+                #{customerIndustry}, #{followUpPerson}, #{firsTimeRoom}, #{visitingChannels}, #{visitingTime}, #{remark}, #{status})
     </insert>
 
     <delete id="delete">
@@ -53,6 +54,7 @@
             <if test="visitingChannels!=null">visitingChannels=#{visitingChannels},</if>
             <if test="visitingTime!=null">visitingTime=#{visitingTime},</if>
             <if test="remark!=null">remark=#{remark},</if>
+            <if test="status!=0">status=#{status},</if>
         </trim>
         WHERE id=#{id}
     </update>
@@ -80,6 +82,7 @@
             <if test="visitingChannels!=null">and visitingChannels=#{visitingChannels}</if>
             <if test="visitingTime!=null">and visitingTime=#{visitingTime}</if>
             <if test="remark!=null">and remark=#{remark}</if>
+            <if test="status == 0 or status == 1">and status=#{status}</if>
         </where>
     </select>
 
@@ -102,6 +105,7 @@
             <if test="p.visitingChannels!=null">and visitingChannels=#{p.visitingChannels}</if>
             <if test="p.visitingTime!=null">and visitingTime=#{p.visitingTime}</if>
             <if test="p.remark!=null">and remark=#{p.remark}</if>
+            <if test="p.status == 0 or p.status == 1">and status=#{p.status}</if>
         </where>
         limit #{currIndex} , #{pageSize}
     </select>

+ 19 - 1
virgo.manager/src/main/java/com/bosshand/virgo/controller/MessageController.java

@@ -42,7 +42,7 @@ public class MessageController {
     @ApiOperation(value = "审核消息发送", notes = "审核消息发送")
     @RequestMapping(value = "/", method = RequestMethod.POST)
     public Response pushMesssage(@RequestBody JSONObject parameter) {
-        messageService.pushMesssage(parameter);
+        messageService.pushMessage(parameter);
         return Response.ok();
     }
 
@@ -60,10 +60,28 @@ public class MessageController {
         return Response.ok();
     }
 
+    @ApiOperation(value = "详情", notes = "详情")
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.PUT)
+    public Response get(@PathVariable long id) {
+        return Response.ok(messageService.get(id));
+    }
+
     @ApiOperation(value = "根据type获取消息列表", notes = "根据type获取消息列表")
     @RequestMapping(value = "/messageType/{userId}/{messageType}", method = RequestMethod.GET)
     public Response getByUserId(@PathVariable int messageType, @PathVariable long userId) {
         return Response.ok(messageService.getMessageByUserId(messageType, userId));
     }
 
+    @ApiOperation(value = "根据type统计未读消息", notes = "根据type统计未读消息")
+    @RequestMapping(value = "/countUnread/messageType/{userId}/{messageType}", method = RequestMethod.GET)
+    public Response countUnread(@PathVariable int messageType, @PathVariable long userId) {
+        return Response.ok(messageService.count(messageType, userId, false));
+    }
+
+    @ApiOperation(value = "根据type统计已读消息", notes = "根据type统计已读消息")
+    @RequestMapping(value = "/countRead/messageType/{userId}/{messageType}", method = RequestMethod.GET)
+    public Response countRead(@PathVariable int messageType, @PathVariable long userId) {
+        return Response.ok(messageService.count(messageType, userId, true));
+    }
+
 }

+ 5 - 4
virgo.manager/src/main/java/com/bosshand/virgo/message/dao/NotificationMessageDao.java

@@ -1,10 +1,9 @@
 package com.bosshand.virgo.message.dao;
 
-import java.util.List;
-
+import com.bosshand.virgo.message.model.NotificationMessage;
 import org.apache.ibatis.annotations.Mapper;
 
-import com.bosshand.virgo.message.model.NotificationMessage;
+import java.util.List;
 
 @Mapper
 public interface NotificationMessageDao {
@@ -15,6 +14,8 @@ public interface NotificationMessageDao {
 
 	public List<NotificationMessage> getMessageByViewed(long userId, boolean viewed);
 
+	public NotificationMessage get(long id);
+
 	public int insert(NotificationMessage notificationMessage);
 
 	public int updateViewed(long id);
@@ -22,6 +23,6 @@ public interface NotificationMessageDao {
 	public int updatePushed(long id);
 
 	public List<NotificationMessage> getList();
-	
 
+    List<NotificationMessage> count(int messageType, long userId, boolean viewed);
 }

+ 7 - 5
virgo.manager/src/main/java/com/bosshand/virgo/message/model/NotificationMessage.java

@@ -28,6 +28,8 @@ public class NotificationMessage implements Serializable {
 
     String sender;
 
+    String sendUserName;
+
     boolean systemMessage;
 
     /**
@@ -135,11 +137,11 @@ public class NotificationMessage implements Serializable {
         this.json = json;
     }
 
-    @Override
-    public String toString() {
-        return "NotificationMessage [id=" + id + ", message=" + message + ", title=" + title + ", messageType="
-                + messageType + ", sentTime=" + sentTime + ", viewed=" + viewed + ", userId=" + userId + ", sender="
-                + sender + ", systemMessage=" + systemMessage + ", pushed=" + pushed + ", json=" + json + "]";
+    public String getSendUserName() {
+        return sendUserName;
     }
 
+    public void setSendUserName(String sendUserName) {
+        this.sendUserName = sendUserName;
+    }
 }

+ 46 - 7
virgo.manager/src/main/java/com/bosshand/virgo/message/service/MessageService.java

@@ -1,6 +1,8 @@
 package com.bosshand.virgo.message.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.bosshand.virgo.core.dao.MgrUserDao;
+import com.bosshand.virgo.core.model.MgrUser;
 import com.bosshand.virgo.exception.ServiceException;
 import com.bosshand.virgo.message.beetl.FlowMessageGenerator;
 import com.bosshand.virgo.message.beetl.MessageGenerator;
@@ -41,6 +43,17 @@ public class MessageService {
 	@Autowired
 	private ApiClient apiClient;
 
+	@Autowired
+	private MgrUserDao mgrUserDao;
+
+	private String getUserName(String userId) {
+		MgrUser user = mgrUserDao.getById(Long.parseLong(userId));
+		if (user != null) {
+			return user.getName();
+		}
+		return null;
+	}
+
 	public int insert(NotificationMessage notificationMessage) {
 		return notificationMessageDao.insert(notificationMessage);
 	}
@@ -49,20 +62,46 @@ public class MessageService {
 		return notificationMessageDao.updateViewed(id);
 	}
 
+	public NotificationMessage get(long id) {
+		NotificationMessage notificationMessage = notificationMessageDao.get(id);
+		notificationMessage.setSendUserName(this.getUserName(notificationMessage.getSender()));
+		return notificationMessage;
+	}
+
 	public List<NotificationMessage> getMessageByUserId(long userId) {
-		return notificationMessageDao.getMessageByUserId(userId);
+		List<NotificationMessage> list = notificationMessageDao.getMessageByUserId(userId);
+		for (NotificationMessage message : list) {
+			message.setSendUserName(this.getUserName(message.getSender()));
+		}
+		return list;
 	}
-	
+
 	public List<NotificationMessage> getMessageByUserId(int messageType, long userId) {
-		return notificationMessageDao.getMessageByMessageType(messageType, userId);
+		List<NotificationMessage> list = notificationMessageDao.getMessageByMessageType(messageType, userId);
+		for (NotificationMessage message : list) {
+			message.setSendUserName(this.getUserName(message.getSender()));
+		}
+		return list;
+	}
+
+	public List<NotificationMessage> count(int messageType, long userId, boolean viewed) {
+		List<NotificationMessage> list = notificationMessageDao.count(messageType, userId, viewed);
+		for (NotificationMessage message : list) {
+			message.setSendUserName(this.getUserName(message.getSender()));
+		}
+		return list;
 	}
 
 	public List<NotificationMessage> getMessageByViewed(long userId, boolean viewed) {
-		return notificationMessageDao.getMessageByViewed(userId, viewed);
+		List<NotificationMessage> list = notificationMessageDao.getMessageByViewed(userId, viewed);
+		for (NotificationMessage message : list) {
+			message.setSendUserName(this.getUserName(message.getSender()));
+		}
+		return list;
 	}
 
 	public void pushMessage(List<Long> receiptList, NotificationMessage message) throws ServiceException {
-		pushMesssage(receiptList, message, false);
+		pushMessage(receiptList, message, false);
 	}
 
 	public void pushMessage(List<Long> receiptList, MessageGenerator messageGenerator) throws ServiceException {
@@ -74,7 +113,7 @@ public class MessageService {
 		}
 	}
 
-	private void pushMesssage(List<Long> receiptList, NotificationMessage message, boolean sendPush) {
+	private void pushMessage(List<Long> receiptList, NotificationMessage message, boolean sendPush) {
 		if (receiptList != null && receiptList.size() > 0) {
 			receiptList.forEach(receipt -> {
 				message.setUserId(receipt);
@@ -92,7 +131,7 @@ public class MessageService {
 		
 	}
 	
-	public void pushMesssage(JSONObject json) {
+	public void pushMessage(JSONObject json) {
 		FlowMessageGenerator messageGenerator = new FlowMessageGenerator();
 		messageGenerator.setTemplateName(getTemplateName(json.getString("templateName")));
 		messageGenerator.setSender(json.getString("sender"));

+ 11 - 3
virgo.manager/src/main/resources/mapper/NotificationMessage.xml

@@ -19,10 +19,14 @@
 	</resultMap>
 	
 	<insert id="insert">
-		INSERT INTO mgr_user_message(messageType, message, sentTime, viewed, userId, sender, systemMessage, pushed, json, isCC) VALUES
-		(#{messageType}, #{message}, #{sentTime}, #{viewed}, #{userId}, #{sender}, #{systemMessage}, #{pushed}, #{json}, #{isCC})
+		INSERT INTO mgr_user_message(messageType, title, message, sentTime, viewed, userId, sender, systemMessage, pushed, json, isCC) VALUES
+		(#{messageType}, #{title}, #{message}, #{sentTime}, #{viewed}, #{userId}, #{sender}, #{systemMessage}, #{pushed}, #{json}, #{isCC})
 	</insert>
-	
+
+	<select id="get" resultMap="NotificationMessageResult">
+		SELECT * FROM mgr_user_message where id = #{id}
+	</select>
+
 	<select id="getList" resultMap="NotificationMessageResult">
 		SELECT * FROM mgr_user_message
 	</select>
@@ -39,6 +43,10 @@
 		SELECT * FROM mgr_user_message where userId = #{userId} and viewed = #{viewed} order by sentTime DESC
 	</select>
 
+	<select id="count" resultMap="NotificationMessageResult">
+		SELECT * FROM mgr_user_message where userId = #{userId} and messageType = #{messageType} and viewed = #{viewed} order by sentTime DESC
+	</select>
+
 	<update id="updateViewed">
 		UPDATE mgr_user_message set viewed = 1 where id = #{id} 
 	</update>