Parcourir la source

消息推送APP

wanghui il y a 8 ans
Parent
commit
49face8344

+ 0 - 1
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -17,7 +17,6 @@ import com.goafanti.common.dao.AdminLocationMapper;
 import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.UserRoleMapper;
 import com.goafanti.common.model.Admin;
-import com.goafanti.common.model.AdminLocation;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;

+ 2 - 2
src/main/java/com/goafanti/app/controller/AppApiController.java

@@ -71,13 +71,13 @@ public class AppApiController extends BaseApiController {
 	}
 	
 	@RequestMapping(value = "/listMessage", method = RequestMethod.GET)
-	public Result listMessage(Integer subject,Integer sourceType){
+	public Result listMessage(Integer subject,Integer sourceType,Integer pageNo,Integer pageSize){
 		Result res = new Result();
 		if(null == subject){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "必须指定消息类型"));
 			return res;
 		}
-		res.setData(messageServiceImpl.listPersonalMessage(subject,sourceType));
+		res.setData(messageServiceImpl.listPersonalMessage(subject,sourceType,pageNo,pageSize));
 		return res;
 	}
 	

+ 0 - 9
src/main/java/com/goafanti/common/dao/MessageFromSystemMapper.java

@@ -155,13 +155,4 @@ public interface MessageFromSystemMapper {
 	 */
 	IndexBo selectMessageWithGroup(@Param("uid")String uid);
 
-	/**
-	 * 查询个人消息列表
-	 * @param subject
-	 * @param sourceType
-	 * @param uid
-	 * @return
-	 */
-	List<MessageFromSystem> listPersonalMessage(@Param("subject")Integer subject,@Param("sourceType")Integer sourceType,@Param("uid")String uid);
-	
 }

+ 21 - 2
src/main/java/com/goafanti/common/mapper/MessageFromSystemMapper.xml

@@ -572,7 +572,7 @@
 		) y
    </select>
    
-   <select id="listPersonalMessage" resultMap="BaseResultMap">
+   <select id="listPersonalMessageByPage" resultMap="BaseResultMap">
 		select
 			b.title,b.create_time,b.subject
 		from
@@ -587,6 +587,25 @@
 			<if test="resourceType != null">
 				and b.resource_type = #{resourceType,jdbcType=INTEGER}
 			</if>
+			<if test="page_sql!=null">
+				${page_sql}
+			</if>
+   </select>
+	
+   <select id="listPersonalMessageCount" resultType="java.lang.Integer">
+   		select
+			count(0)
+		from
+			message_consumer a left join message_from_system b on
+			a.message_id = b.id
+		where
+			a.consumer_id = #{uid,jdbcType=VARCHAR}
+			and a.delete_sign = false
+			<if test="subject != null">
+				and b.subject = #{subject,jdbcType=INTEGER}
+			</if>
+			<if test="resourceType != null">
+				and b.resource_type = #{resourceType,jdbcType=INTEGER}
+			</if>
    </select>
-
 </mapper>

+ 1 - 1
src/main/java/com/goafanti/message/JGMessageHelper.java

@@ -93,7 +93,7 @@ public class JGMessageHelper implements InitializingBean, DisposableBean{
 					.setTitle(mb.getMessageTitle())
 					.setMsgContent(mb.getMessageBody())
 					.addExtra(MESSAGE_ID,mb.getMessageId())
-					.addExtra(RESOURCE_ID, mb.getResourceId())
+					.addExtra(RESOURCE_ID,mb.getResourceId())
 					.build())
 			.build());
 		send(ma);

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

@@ -8,6 +8,7 @@ import com.goafanti.app.bo.IndexBo;
 import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
+import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.message.bo.MessageBo;
 
 public interface MessageService {
@@ -132,7 +133,7 @@ public interface MessageService {
 	 * @param sourceType 推荐类型
 	 * @return
 	 */
-	List<MessageFromSystem> listPersonalMessage(Integer subject,Integer sourceType);
+	Pagination<MessageFromSystem> listPersonalMessage(Integer subject,Integer sourceType,Integer pageNo,Integer pageSize);
 	
 	/**
 	 * 查看消息详情

+ 11 - 3
src/main/java/com/goafanti/message/service/impl/MessageServiceImpl.java

@@ -3,6 +3,7 @@ package com.goafanti.message.service.impl;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -20,6 +21,8 @@ import com.goafanti.common.model.MessageConsumer;
 import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageProducer;
 import com.goafanti.common.model.User;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
 import com.goafanti.message.bo.MessageBo;
 import com.goafanti.message.enums.ConsumerType;
@@ -28,7 +31,7 @@ import com.goafanti.message.enums.SubjectType;
 import com.goafanti.message.service.MessageService;
 
 @Service
-public class MessageServiceImpl implements MessageService{
+public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper> implements MessageService{
 	@Autowired
 	private MessageFromSystemMapper messageFromSystemMapper;
 	@Autowired
@@ -282,10 +285,15 @@ public class MessageServiceImpl implements MessageService{
 		return null;
 	}
 
+	@SuppressWarnings("unchecked")
 	@Override
-	public List<MessageFromSystem> listPersonalMessage(Integer subject, Integer sourceType) {
+	public Pagination<MessageFromSystem> listPersonalMessage(Integer subject, Integer sourceType,Integer pageNo,Integer pageSize) {
 		if(subject == SubjectType.KE_HU.getTypeCode() || subject == SubjectType.TUI_JIAN.getTypeCode()){
-			return messageFromSystemMapper.listPersonalMessage(subject, sourceType,TokenManager.getUserId()); 
+			Map<String,Object> params = new HashMap<String, Object>();
+			if(null != subject) params.put("subject", subject);
+			if(null != sourceType) params.put("sourceType", sourceType);
+			params.put("uid", TokenManager.getUserId());
+			return (Pagination<MessageFromSystem>)findPage("listPersonalMessageByPage", "listPersonalMessageCount", params, pageNo, pageSize);
 		}
 		return null;
 	}