Sfoglia il codice sorgente

消息后台列表分页

wanghui 8 anni fa
parent
commit
747a9daf30

+ 2 - 2
src/main/java/com/goafanti/admin/controller/AdminMessageController.java

@@ -182,7 +182,7 @@ public class AdminMessageController extends CertifyApiController{
 	 * @return
 	 */
 	@RequestMapping(value = "/listSystemMessage", method = RequestMethod.GET)
-	public Result listSystemMessage(Integer isDraft,Integer subject){
+	public Result listSystemMessage(Integer isDraft,Integer subject,Integer page,Integer pageNo,Integer pageSize){
 		Result res = new Result();
 		if(null == isDraft){
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "消息发送状态不能未空"));
@@ -192,7 +192,7 @@ public class AdminMessageController extends CertifyApiController{
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "消息类型不能为空"));
 			return res;
 		}*/
-		res.setData(messageServiceImpl.listSystemMessage(isDraft, subject));
+		res.setData(messageServiceImpl.listSystemMessage(isDraft, subject,pageNo,pageSize));
 		return res;
 	}
 	

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

@@ -6,7 +6,6 @@ import com.goafanti.common.model.MessageFromSystem;
 import com.goafanti.common.model.MessageFromSystemExample;
 import com.goafanti.common.model.MessageProducer;
 import com.goafanti.message.bo.MessageBo;
-import com.goafanti.message.bo.MessageListBo;
 
 import java.util.Date;
 import java.util.List;
@@ -142,14 +141,6 @@ public interface MessageFromSystemMapper {
 	List<MessageFromSystem> selectRecommendTarget(@Param("sql")String sql);
 
 	/**
-	 * 后台查看消息列表
-	 * @param isDraft
-	 * @param subject 消息类型
-	 * @return
-	 */
-	List<MessageListBo> listSystemMessage(@Param("isDraft")Integer isDraft,@Param("subject")Integer subject);
-
-	/**
 	 * APP首页消息
 	 * @param id (user_id or admin_id)
 	 * @return

+ 31 - 3
src/main/java/com/goafanti/common/mapper/MessageFromSystemMapper.xml

@@ -487,7 +487,7 @@
    	 	#{sql,jdbcType=VARCHAR}
    </select>
    
-   <select id="listSystemMessage"  resultMap="com.goafanti.message.bo.MessageListBo">
+   <select id="listSystemMessageByPage"  resultMap="com.goafanti.message.bo.MessageListBo">
 		select
 			a.id as messageId,
 			date_format(a.create_time,'%Y-%m-%d %H:%I:%S') as createTime,
@@ -500,9 +500,37 @@
 		from
 			message_from_system a
 		where 1= 1
-		<if test="subject != null">
-			and a.subject = #{subject,jdbcType=INTEGER}
+		<choose>
+			<when test="subject = 01">
+				and a.subject != 2
+			</when>
+			<when test="subject = 2">
+				and a.subject = 2
+			</when>
+		</choose>
+		<if test="isDraft != null">
+			and a.is_draft = #{isDraft,jdbcType=INTEGER}
+		</if>
+			and a.delete_sign = false 
+		<if test="page_sql!=null">
+				${page_sql}
 		</if>
+   </select>
+   
+   <select id="listSystemMessageCount" resultType="java.lang.Integer">
+   		select
+			count(0)
+		from
+			message_from_system a
+		where 1= 1
+		<choose>
+			<when test="subject = 01">
+				and a.subject != 2
+			</when>
+			<when test="subject = 2">
+				and a.subject = 2
+			</when>
+		</choose>
 		<if test="isDraft != null">
 			and a.is_draft = #{isDraft,jdbcType=INTEGER}
 		</if>

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

@@ -105,7 +105,7 @@ public interface MessageService {
 	 * @param isDraft
 	 * @return
 	 */
-	List<MessageListBo> listSystemMessage(Integer isDraft,Integer subject);
+	Pagination<MessageListBo> listSystemMessage(Integer isDraft,Integer subject,Integer pageNo,Integer pageSize);
 	
 	/**
 	 * 更新消息

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

@@ -250,9 +250,13 @@ public class MessageServiceImpl  extends BaseMybatisDao<MessageFromSystemMapper>
 		return messageFromSystemMapper.updateMessageConsumer(messageId, TokenManager.getUserId() , new Date());
 	}
 
+	@SuppressWarnings("unchecked")
 	@Override
-	public List<MessageListBo> listSystemMessage(Integer isDraft,Integer subject) {
-		return messageFromSystemMapper.listSystemMessage(isDraft,subject);
+	public Pagination<MessageListBo> listSystemMessage(Integer isDraft,Integer subject,Integer pageNo,Integer pageSize) {
+		Map<String,Object> params = new HashMap<String,Object>();
+		params.put("isDraft", isDraft);
+		params.put("subject", subject);
+		return (Pagination<MessageListBo>)findPage("listSystemMessageByPage", "listSystemMessageCount", params, pageNo, pageSize);
 	}
 
 	@Override