dcs 1 年之前
父節點
當前提交
c89576ac5b

+ 2 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/shiro/VirgoAuthenticationFilter.java

@@ -93,6 +93,8 @@ public class VirgoAuthenticationFilter extends AuthenticatingFilter {
 				} else {
 					//注册
 					MgrUser u = new MgrUser();
+					u.setPortrait(CodeCache.DefaultPortrait);
+					u.setName(CodeCache.DefaultName);
 					u.setPhone(phone);
 					mgrUserService.wxRegister(u);
 					CodeCache.setKey(phone, CodeCache.DefaultPhoneCode);

+ 4 - 0
virgo.core/src/main/java/com/bosshand/virgo/core/utils/CodeCache.java

@@ -14,6 +14,10 @@ public class CodeCache {
 
     public static final String DefaultPhoneCode = "888888";
 
+    public static final String DefaultName = "微信用户";
+
+    public static final String DefaultPortrait = "https://file-node.oss-cn-shanghai.aliyuncs.com/youji/78063ded24ba44f6b56e0dc812cf94a0";
+
     private static Logger logger = LoggerFactory.getLogger(CodeCache.class);
 
     private static LoadingCache<String, String> localCache =

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

@@ -61,7 +61,7 @@ public class MessageController {
     }
 
     @ApiOperation(value = "详情", notes = "详情")
-    @RequestMapping(value = "/get/{id}", method = RequestMethod.PUT)
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {
         return Response.ok(messageService.get(id));
     }

+ 5 - 32
virgo.manager/src/main/java/com/bosshand/virgo/message/service/MessageService.java

@@ -2,7 +2,6 @@ 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;
@@ -46,14 +45,6 @@ public class MessageService {
 	@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);
 	}
@@ -63,41 +54,23 @@ public class MessageService {
 	}
 
 	public NotificationMessage get(long id) {
-		NotificationMessage notificationMessage = notificationMessageDao.get(id);
-		notificationMessage.setSendUserName(this.getUserName(notificationMessage.getSender()));
-		return notificationMessage;
+		return notificationMessageDao.get(id);
 	}
 
 	public List<NotificationMessage> getMessageByUserId(long userId) {
-		List<NotificationMessage> list = notificationMessageDao.getMessageByUserId(userId);
-		for (NotificationMessage message : list) {
-			message.setSendUserName(this.getUserName(message.getSender()));
-		}
-		return list;
+		return notificationMessageDao.getMessageByUserId(userId);
 	}
 
 	public List<NotificationMessage> getMessageByUserId(int messageType, long userId) {
-		List<NotificationMessage> list = notificationMessageDao.getMessageByMessageType(messageType, userId);
-		for (NotificationMessage message : list) {
-			message.setSendUserName(this.getUserName(message.getSender()));
-		}
-		return list;
+		return notificationMessageDao.getMessageByMessageType(messageType, userId);
 	}
 
 	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;
+		return notificationMessageDao.count(messageType, userId, viewed);
 	}
 
 	public List<NotificationMessage> getMessageByViewed(long userId, boolean viewed) {
-		List<NotificationMessage> list = notificationMessageDao.getMessageByViewed(userId, viewed);
-		for (NotificationMessage message : list) {
-			message.setSendUserName(this.getUserName(message.getSender()));
-		}
-		return list;
+		return notificationMessageDao.getMessageByViewed(userId, viewed);
 	}
 
 	public void pushMessage(List<Long> receiptList, NotificationMessage message) throws ServiceException {

+ 16 - 6
virgo.manager/src/main/resources/mapper/NotificationMessage.xml

@@ -16,35 +16,45 @@
 		<result column="pushed" property="pushed" />
 		<result column="json" property="json" />
 		<result column="isCC" property="isCC" />
+		<result column="sendUserName" property="sendUserName" />
 	</resultMap>
 	
+	<sql id="query">
+		SELECT *, b.name as sendUserName FROM mgr_user_message a LEFT JOIN mgr_user b on a.sender = b.id
+	</sql>
+	
 	<insert id="insert">
 		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}
+		<include refid="query"/>
+		where a.id = #{id}
 	</select>
 
 	<select id="getList" resultMap="NotificationMessageResult">
-		SELECT * FROM mgr_user_message
+		<include refid="query"/>
 	</select>
 
 	<select id="getMessageByUserId" resultMap="NotificationMessageResult">
-		SELECT * FROM mgr_user_message where userId = #{userId} order by sentTime DESC
+		<include refid="query"/>
+		where a.userId = #{userId} order by a.sentTime DESC
 	</select>
 	
 	<select id="getMessageByMessageType" resultMap="NotificationMessageResult">
-		SELECT * FROM mgr_user_message where userId = #{userId} and messageType = #{messageType} order by sentTime DESC
+		<include refid="query"/>
+		where a.userId = #{userId} and a.messageType = #{messageType} order by a.sentTime DESC
 	</select>
 	
 	<select id="getMessageByViewed" resultMap="NotificationMessageResult">
-		SELECT * FROM mgr_user_message where userId = #{userId} and viewed = #{viewed} order by sentTime DESC
+		<include refid="query"/>
+		where a.userId = #{userId} and a.viewed = #{viewed} order by a.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
+		<include refid="query"/>
+		where a.userId = #{userId} and a.messageType = #{messageType} and a.viewed = #{viewed} order by a.sentTime DESC
 	</select>
 
 	<update id="updateViewed">