Bladeren bron

message list 分页

傅行帆 6 jaren geleden
bovenliggende
commit
acc2c6db41

+ 6
- 0
CODE/smart-community/app-api/pom.xml Bestand weergeven

71
 			<version>1.3.2</version>
71
 			<version>1.3.2</version>
72
 		</dependency>
72
 		</dependency>
73
 
73
 
74
+		<dependency>
75
+			<groupId>com.github.pagehelper</groupId>
76
+			<artifactId>pagehelper-spring-boot-starter</artifactId>
77
+			<version>1.2.3</version>
78
+		</dependency>
79
+
74
 		<dependency>
80
 		<dependency>
75
 			<groupId>mysql</groupId>
81
 			<groupId>mysql</groupId>
76
 			<artifactId>mysql-connector-java</artifactId>
82
 			<artifactId>mysql-connector-java</artifactId>

+ 0
- 6
CODE/smart-community/app-api/src/main/java/com/community/huiju/common/code/impl/PhoneCodeImpl.java Bestand weergeven

1
 package com.community.huiju.common.code.impl;
1
 package com.community.huiju.common.code.impl;
2
 
2
 
3
-import com.alibaba.fastjson.JSONObject;
4
 import com.community.commom.constant.Constant;
3
 import com.community.commom.constant.Constant;
5
-import com.community.commom.utils.HttpClientUtils;
6
 import com.community.huiju.common.code.ICode;
4
 import com.community.huiju.common.code.ICode;
7
-import com.community.huiju.common.code.entity.CodeEntity;
8
-import lombok.extern.log4j.Log4j;
9
 import lombok.extern.slf4j.Slf4j;
5
 import lombok.extern.slf4j.Slf4j;
10
 import okhttp3.*;
6
 import okhttp3.*;
11
 import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
13
-import org.springframework.util.LinkedMultiValueMap;
14
-import org.springframework.util.MultiValueMap;
15
 import org.springframework.web.client.RestTemplate;
9
 import org.springframework.web.client.RestTemplate;
16
 
10
 
17
 import java.io.IOException;
11
 import java.io.IOException;

+ 32
- 4
CODE/smart-community/app-api/src/main/java/com/community/huiju/controller/MessageController.java Bestand weergeven

1
 package com.community.huiju.controller;
1
 package com.community.huiju.controller;
2
 
2
 
3
+import com.community.commom.constant.Constant;
3
 import com.community.commom.mode.ResponseBean;
4
 import com.community.commom.mode.ResponseBean;
4
 import com.community.huiju.model.ToCommunities;
5
 import com.community.huiju.model.ToCommunities;
6
+import com.community.huiju.model.TpMessage;
5
 import com.community.huiju.service.MessageServiceI;
7
 import com.community.huiju.service.MessageServiceI;
6
 import io.swagger.annotations.Api;
8
 import io.swagger.annotations.Api;
7
 import io.swagger.annotations.ApiImplicitParam;
9
 import io.swagger.annotations.ApiImplicitParam;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import org.springframework.beans.factory.annotation.Autowired;
12
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.cloud.context.config.annotation.RefreshScope;
13
 import org.springframework.cloud.context.config.annotation.RefreshScope;
14
+import org.springframework.web.bind.annotation.PathVariable;
12
 import org.springframework.web.bind.annotation.RequestMapping;
15
 import org.springframework.web.bind.annotation.RequestMapping;
13
 import org.springframework.web.bind.annotation.RequestMethod;
16
 import org.springframework.web.bind.annotation.RequestMethod;
14
 import org.springframework.web.bind.annotation.RequestParam;
17
 import org.springframework.web.bind.annotation.RequestParam;
30
 	@Autowired
33
 	@Autowired
31
 	private MessageServiceI messageService;
34
 	private MessageServiceI messageService;
32
 	
35
 	
33
-	@ApiOperation(value = "根据小区名获取小区列表", notes = "根据小区名获取小区列表")
34
-	@RequestMapping(value = "/message/total",method = RequestMethod.GET)
35
-	public ResponseBean getMessageTotal(){
36
+	@ApiOperation(value = "按小区获取消息总数", notes = "按小区获取个人消息总数")
37
+	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id") })
38
+	@RequestMapping(value = "/message/{communityId}/total",method = RequestMethod.GET)
39
+	public ResponseBean getMessageTotal(@PathVariable Integer communityId){
36
 		ResponseBean responseBean = new ResponseBean();
40
 		ResponseBean responseBean = new ResponseBean();
37
-		Map<String,Object> totalMap = messageService.getMessageTotal();
41
+		Map<String,Object> totalMap = messageService.getMessageTotal(communityId);
38
 		responseBean.addSuccess(totalMap);
42
 		responseBean.addSuccess(totalMap);
39
 		return responseBean;
43
 		return responseBean;
40
 	}
44
 	}
45
+	
46
+	@ApiOperation(value = "按小区获取分页消息", notes = "按小区获取分页消息")
47
+	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
48
+			@ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
49
+			@ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度")})
50
+	@RequestMapping(value = "/message/{communityId}/news",method = RequestMethod.GET)
51
+	public ResponseBean getNews(@PathVariable Integer communityId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){
52
+		ResponseBean responseBean = new ResponseBean();
53
+		List<TpMessage> newsList = messageService.getMessages(communityId,pageNum,pageSize, Constant.MODEL_TYPE_NEWS);
54
+		responseBean.addSuccess(newsList);
55
+		return responseBean;
56
+	}
57
+	
58
+	@ApiOperation(value = "按小区获取分页待办", notes = "按小区获取分页待办")
59
+	@ApiImplicitParams({ @ApiImplicitParam(paramType = "path", dataType = "String", name = "communityId", value = "小区Id"),
60
+			@ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageNum", value = "分页第几页"),
61
+			@ApiImplicitParam(paramType = "query", dataType = "integer", name = "pageSize", value = "分页每页长度")})
62
+	@RequestMapping(value = "/message/{communityId}/upcoming",method = RequestMethod.GET)
63
+	public ResponseBean getUpcoming(@PathVariable Integer communityId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){
64
+		ResponseBean responseBean = new ResponseBean();
65
+		List<TpMessage> upcomingList = messageService.getMessages(communityId,pageNum,pageSize,Constant.MODEL_TYPE_UPCOMING);
66
+		responseBean.addSuccess(upcomingList);
67
+		return responseBean;
68
+	}
41
 }
69
 }

+ 4
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpMessageMapper.java Bestand weergeven

4
 import org.apache.ibatis.annotations.Mapper;
4
 import org.apache.ibatis.annotations.Mapper;
5
 import org.apache.ibatis.annotations.Param;
5
 import org.apache.ibatis.annotations.Param;
6
 
6
 
7
+import java.util.List;
7
 import java.util.Map;
8
 import java.util.Map;
8
 
9
 
9
 @Mapper
10
 @Mapper
20
 
21
 
21
     int updateByPrimaryKey(TpMessage record);
22
     int updateByPrimaryKey(TpMessage record);
22
     
23
     
23
-    Map<String, Object> getMessageTotal(@Param(value="userId") Integer userId);
24
+    Map<String, Object> getMessageTotal(@Param(value = "userId") Integer userId,@Param(value = "communityId") Integer communityId);
25
+    
26
+    List<TpMessage> getMessages(@Param(value = "userId") Integer userId,@Param(value = "communityId") Integer communityId, @Param(value = "modelType") Integer modelType);
24
 }
27
 }

+ 19
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/MessageServiceI.java Bestand weergeven

1
 package com.community.huiju.service;
1
 package com.community.huiju.service;
2
 
2
 
3
+import com.community.huiju.model.TpMessage;
4
+
5
+import java.util.List;
3
 import java.util.Map;
6
 import java.util.Map;
4
 
7
 
5
 public interface MessageServiceI {
8
 public interface MessageServiceI {
6
-	Map<String, Object> getMessageTotal();
9
+	/**
10
+	 * 获取消息数量
11
+	 * @param communityId
12
+	 * @return
13
+	 */
14
+	Map<String, Object> getMessageTotal(Integer communityId);
15
+	
16
+	/**
17
+	 * 分页获取消息或待办
18
+	 * @param communityId
19
+	 * @param pageNum
20
+	 * @param pageSize
21
+	 * @param modelType
22
+	 * @return
23
+	 */
24
+	List<TpMessage> getMessages(Integer communityId, Integer pageNum, Integer pageSize,Integer modelType);
7
 }
25
 }

+ 30
- 2
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/MessageServiceImpl.java Bestand weergeven

1
 package com.community.huiju.service.impl;
1
 package com.community.huiju.service.impl;
2
 
2
 
3
 import com.community.huiju.dao.TpMessageMapper;
3
 import com.community.huiju.dao.TpMessageMapper;
4
+import com.community.huiju.model.TpMessage;
4
 import com.community.huiju.service.MessageServiceI;
5
 import com.community.huiju.service.MessageServiceI;
6
+import com.github.pagehelper.PageHelper;
5
 import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.beans.factory.annotation.Autowired;
6
 import org.springframework.stereotype.Service;
8
 import org.springframework.stereotype.Service;
7
 
9
 
10
+import java.util.List;
8
 import java.util.Map;
11
 import java.util.Map;
9
 
12
 
10
 /**
13
 /**
17
 	@Autowired
20
 	@Autowired
18
 	private TpMessageMapper tpMessageMapper;
21
 	private TpMessageMapper tpMessageMapper;
19
 	
22
 	
23
+	/**
24
+	 * 获取消息数量
25
+	 * @param communityId
26
+	 * @return
27
+	 */
20
 	@Override
28
 	@Override
21
-	public Map<String, Object> getMessageTotal() {
29
+	public Map<String, Object> getMessageTotal(Integer communityId) {
22
 		Integer userId = 1;
30
 		Integer userId = 1;
23
-		return tpMessageMapper.getMessageTotal(userId);
31
+		return tpMessageMapper.getMessageTotal(userId,communityId);
32
+	}
33
+	
34
+	/**
35
+	 * 分页获取消息或待办
36
+	 * @param communityId
37
+	 * @param pageNum
38
+	 * @param pageSize
39
+	 * @param modelType
40
+	 * @return
41
+	 */
42
+	@Override
43
+	public List<TpMessage> getMessages(Integer communityId, Integer pageNum, Integer pageSize,Integer modelType) {
44
+		Integer userId = 1;
45
+		pageNum = null == pageNum ? 1 : pageNum;
46
+		pageSize = null == pageSize ? 10 : pageSize;
47
+		//使用分页插件
48
+		PageHelper.startPage(pageNum, pageSize);
49
+		// 获取数据
50
+		List<TpMessage> messageList = tpMessageMapper.getMessages(userId,communityId, modelType);
51
+		return messageList;
24
 	}
52
 	}
25
 }
53
 }

+ 11
- 1
CODE/smart-community/app-api/src/main/resources/application.yml Bestand weergeven

6
 ## Mybatis
6
 ## Mybatis
7
 mybatis:
7
 mybatis:
8
   typeAliasesPackage: com.community.huiju.model
8
   typeAliasesPackage: com.community.huiju.model
9
-  mapperLocations: classpath:mapper/*.xml
9
+  mapperLocations: classpath:mapper/*.xml
10
+# 分页配置
11
+pagehelper:
12
+  helper-dialect: mysql
13
+  reasonable: true
14
+  support-methods-arguments: true
15
+  params: count=countSql
16
+# 打印sql
17
+logging:
18
+  level:
19
+    com.community.huiju.dao: debug

+ 16
- 1
CODE/smart-community/app-api/src/main/resources/mapper/TpMessageMapper.xml Bestand weergeven

233
     where id = #{id,jdbcType=INTEGER}
233
     where id = #{id,jdbcType=INTEGER}
234
   </update>
234
   </update>
235
 
235
 
236
-  <select id="getMessageTotal" resultType="map" parameterType="java.lang.Integer" >
236
+  <select id="getMessageTotal" resultType="map">
237
     SELECT
237
     SELECT
238
         count( CASE WHEN model_type = 1 AND read_status = 0 THEN 1 ELSE NULL END ) AS messageTotal,
238
         count( CASE WHEN model_type = 1 AND read_status = 0 THEN 1 ELSE NULL END ) AS messageTotal,
239
         count( CASE WHEN model_type = 2 THEN 1 ELSE NULL END ) AS toDoTotal
239
         count( CASE WHEN model_type = 2 THEN 1 ELSE NULL END ) AS toDoTotal
241
         tp_message
241
         tp_message
242
     WHERE
242
     WHERE
243
         uuid_type = 1
243
         uuid_type = 1
244
+        AND community_id = #{communityId,jdbcType=INTEGER}
244
         AND uuid = #{userId,jdbcType=INTEGER}
245
         AND uuid = #{userId,jdbcType=INTEGER}
245
         AND STATUS = 1
246
         AND STATUS = 1
246
         AND advice_type = 1
247
         AND advice_type = 1
247
   </select>
248
   </select>
249
+
250
+  <select id="getMessages" resultMap="BaseResultMap">
251
+    SELECT
252
+      <include refid="Base_Column_List" />
253
+    FROM
254
+        tp_message
255
+    WHERE
256
+        uuid_type = 1
257
+        AND community_id = #{communityId,jdbcType=INTEGER}
258
+        AND uuid = #{userId,jdbcType=INTEGER}
259
+        AND STATUS = 1
260
+        AND advice_type = 1
261
+        AND model_type = #{modelType,jdbcType=INTEGER}
262
+  </select>
248
 </mapper>
263
 </mapper>

+ 6
- 2
CODE/smart-community/community-common/src/main/java/com/community/commom/constant/Constant.java Bestand weergeven

23
 
23
 
24
     /** 请求发送验证码的远程服务器地址 **/
24
     /** 请求发送验证码的远程服务器地址 **/
25
     public static final String REQUEST_URL = "http://micservice.ycjcjy.com/sms";
25
     public static final String REQUEST_URL = "http://micservice.ycjcjy.com/sms";
26
-
27
-
26
+    
27
+    /** 住户APP端消息 **/
28
+    public static final Integer MODEL_TYPE_NEWS = 1;
29
+    
30
+    /** 住户APP端待办 **/
31
+    public static final Integer MODEL_TYPE_UPCOMING = 2;
28
 }
32
 }

BIN
CODE/smart-community/community-common/target/classes/com/community/commom/constant/Constant.class Bestand weergeven