Commit 15e6454e4364771b77befb4368d98f1ba8cdec66
1 parent
0d5048da1d
Exists in
master
and in
1 other branch
platform permission
add return pageinfo
Showing 5 changed files with 97 additions and 31 deletions
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
- platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
- platform-common/src/main/java/com/lyms/platform/common/constants/ErrorCodeConstants.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FrontEndResult.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
View file @
15e6454
1 | +package com.lyms.platform.biz.param; | |
2 | + | |
3 | +import com.lyms.platform.common.dao.BaseQuery; | |
4 | + | |
5 | +/** | |
6 | + * Created by Zhang.Rui on 2016/4/14. | |
7 | + */ | |
8 | +public class CommunityQuery extends BaseQuery { | |
9 | + private String keyword; | |
10 | + | |
11 | + public String getKeyword() { | |
12 | + return keyword; | |
13 | + } | |
14 | + | |
15 | + public void setKeyword(String keyword) { | |
16 | + this.keyword = keyword; | |
17 | + } | |
18 | +} |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
15e6454
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | |
3 | 3 | import java.util.List; |
4 | 4 | |
5 | +import com.lyms.platform.biz.param.CommunityQuery; | |
5 | 6 | import com.lyms.platform.common.dao.BaseQuery; |
6 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
7 | 8 | import org.aspectj.apache.bcel.generic.RET; |
8 | 9 | |
... | ... | @@ -46,10 +47,10 @@ |
46 | 47 | } |
47 | 48 | |
48 | 49 | //查询区域 |
49 | - public List<CommunityConfig> queryArea(String keyword, Integer page, Integer limit) { | |
50 | + public List<CommunityConfig> queryArea(CommunityQuery communityQuery) { | |
50 | 51 | MongoCondition mongoCondition = MongoCondition.newInstance(); |
51 | - if(null != keyword) { | |
52 | - mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", keyword, MongoOper.LIKE), new MongoCondition("parentId", keyword, MongoOper.LIKE), new MongoCondition("id", keyword, MongoOper.IS)}); | |
52 | + if(null != communityQuery.getKeyword()) { | |
53 | + mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("parentId", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("id", communityQuery.getKeyword(), MongoOper.IS)}); | |
53 | 54 | } |
54 | 55 | mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS).and("type", 1, MongoOper.IS)); |
55 | 56 | |
... | ... | @@ -57,9 +58,7 @@ |
57 | 58 | MongoQuery mongoQuery = mongoCondition.toMongoQuery(); |
58 | 59 | BaseQuery baseQuery = new BaseQuery(); |
59 | 60 | |
60 | - if(null != page && null != limit) { | |
61 | - baseQuery.setPage(page); | |
62 | - baseQuery.setLimit(limit); | |
61 | + if(null != communityQuery.getLimit()) { | |
63 | 62 | baseQuery.mysqlBuild((int) communityConfigDao.queryCount(mongoQuery)); |
64 | 63 | mongoQuery.start(baseQuery.getOffset()).end(baseQuery.getLimit()); |
65 | 64 | } |
66 | 65 | |
67 | 66 | |
68 | 67 | |
... | ... | @@ -68,22 +67,18 @@ |
68 | 67 | } |
69 | 68 | |
70 | 69 | //查询小区 |
71 | - public List<CommunityConfig> queryCommunity(String keyword, Integer page, Integer limit) { | |
70 | + public List<CommunityConfig> queryCommunity(CommunityQuery communityQuery) { | |
72 | 71 | MongoCondition mongoCondition = MongoCondition.newInstance(); |
73 | - if(null != keyword) { | |
74 | - mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", keyword, MongoOper.LIKE), new MongoCondition("gxxq", keyword, MongoOper.LIKE)}); | |
72 | + if(null != communityQuery.getKeyword()) { | |
73 | + mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("gxxq", communityQuery.getKeyword(), MongoOper.LIKE)}); | |
75 | 74 | } |
76 | 75 | mongoCondition.andCondition(new MongoCondition("yn", YnEnums.YES.getId(), MongoOper.IS).and("type", 1, MongoOper.IS)); |
77 | 76 | |
78 | - | |
79 | 77 | MongoQuery mongoQuery = mongoCondition.toMongoQuery(); |
80 | - BaseQuery baseQuery = new BaseQuery(); | |
81 | - | |
82 | - if(null != page && null != limit) { | |
83 | - baseQuery.setPage(page); | |
84 | - baseQuery.setLimit(limit); | |
85 | - baseQuery.mysqlBuild((int) communityConfigDao.queryCount(mongoQuery)); | |
86 | - mongoQuery.start(baseQuery.getOffset()).end(baseQuery.getLimit()); | |
78 | + communityQuery.setNeed("true"); | |
79 | + if(communityQuery.getNeed().equals("true")) { | |
80 | + communityQuery.mysqlBuild((int) communityConfigDao.queryCount(mongoQuery)); | |
81 | + mongoQuery.start(communityQuery.getOffset()).end(communityQuery.getLimit()); | |
87 | 82 | } |
88 | 83 | |
89 | 84 | return communityConfigDao.queryArea(mongoQuery); |
platform-common/src/main/java/com/lyms/platform/common/constants/ErrorCodeConstants.java
View file @
15e6454
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
15e6454
... | ... | @@ -4,6 +4,8 @@ |
4 | 4 | |
5 | 5 | import javax.validation.Valid; |
6 | 6 | |
7 | +import com.lyms.platform.biz.param.CommunityQuery; | |
8 | +import com.lyms.platform.operate.web.result.FrontEndResult; | |
7 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 10 | import org.springframework.stereotype.Controller; |
9 | 11 | import org.springframework.web.bind.annotation.PathVariable; |
... | ... | @@ -84,8 +86,8 @@ |
84 | 86 | //查询小区 |
85 | 87 | @RequestMapping(value = "queryCommunity", method = RequestMethod.GET) |
86 | 88 | @ResponseBody |
87 | - public BaseListResponse queryCommunity(String keyword, Integer page, Integer limit ) { | |
88 | - List<CommunityConfig> communityConfigList = communityConfigService.queryCommunity(keyword, page, limit); | |
89 | + public FrontEndResult queryCommunity(CommunityQuery communityQuery) { | |
90 | + List<CommunityConfig> communityConfigList = communityConfigService.queryCommunity(communityQuery); | |
89 | 91 | |
90 | 92 | if(null != communityConfigList) { |
91 | 93 | for(CommunityConfig communityConfig : communityConfigList) { |
92 | 94 | |
... | ... | @@ -96,12 +98,9 @@ |
96 | 98 | communityConfig.setParent(new CommunityConfig("0", "root")); |
97 | 99 | } |
98 | 100 | } |
99 | - return new BaseListResponse().setData(communityConfigList) | |
100 | - .setErrorcode(ErrorCodeConstants.SUCCESS) | |
101 | - .setErrormsg("查询成功!"); | |
101 | + return FrontEndResult.ini().setData(communityConfigList).setPageInfo(communityQuery.getPageInfo()).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("查询成功"); | |
102 | 102 | } |
103 | - return new BaseListResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR) | |
104 | - .setErrormsg("没有数据"); | |
103 | + return FrontEndResult.ini(ErrorCodeConstants.NO_DATA, "没有数据"); | |
105 | 104 | |
106 | 105 | } |
107 | 106 | |
... | ... | @@ -150,8 +149,8 @@ |
150 | 149 | //查询区域 |
151 | 150 | @RequestMapping(value = "communityConfig", method = RequestMethod.GET) |
152 | 151 | @ResponseBody |
153 | - public BaseListResponse queryArea(String keyword, Integer page, Integer limit ) { | |
154 | - List<CommunityConfig> communityConfigList = communityConfigService.queryArea(keyword, page, limit); | |
152 | + public FrontEndResult queryArea(CommunityQuery communityQuery) { | |
153 | + List<CommunityConfig> communityConfigList = communityConfigService.queryArea(communityQuery); | |
155 | 154 | |
156 | 155 | if(null != communityConfigList) { |
157 | 156 | for(CommunityConfig communityConfig : communityConfigList) { |
158 | 157 | |
... | ... | @@ -162,12 +161,9 @@ |
162 | 161 | communityConfig.setParent(new CommunityConfig("0", "root")); |
163 | 162 | } |
164 | 163 | } |
165 | - return new BaseListResponse().setData(communityConfigList) | |
166 | - .setErrorcode(ErrorCodeConstants.SUCCESS) | |
167 | - .setErrormsg("查询成功!"); | |
164 | + return FrontEndResult.ini().setData(communityConfigList).setPageInfo(communityQuery.getPageInfo()).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
168 | 165 | } |
169 | - return new BaseListResponse().setErrorcode(ErrorCodeConstants.SYSTEM_ERROR) | |
170 | - .setErrormsg("没有数据"); | |
166 | + return FrontEndResult.ini(ErrorCodeConstants.NO_DATA, "没有数据"); | |
171 | 167 | |
172 | 168 | } |
173 | 169 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/FrontEndResult.java
View file @
15e6454
1 | +package com.lyms.platform.operate.web.result; | |
2 | + | |
3 | +import com.lyms.platform.common.base.PageInfo; | |
4 | +import com.lyms.platform.common.dao.BaseQuery; | |
5 | +import com.lyms.platform.common.result.BaseResponse; | |
6 | + | |
7 | +import java.util.List; | |
8 | + | |
9 | +/** | |
10 | + * Created by Zhang.Rui on 2016/4/14. | |
11 | + */ | |
12 | +public class FrontEndResult extends BaseResponse { | |
13 | + private List data; | |
14 | + private PageInfo pageInfo; | |
15 | + | |
16 | + public List getData() { | |
17 | + return data; | |
18 | + } | |
19 | + | |
20 | + public FrontEndResult setData(List data) { | |
21 | + this.data = data; | |
22 | + return this; | |
23 | + } | |
24 | + | |
25 | + public FrontEndResult setErrormsg(String errormsg) { | |
26 | + return (FrontEndResult) super.setErrormsg(errormsg); | |
27 | + } | |
28 | + | |
29 | + public FrontEndResult setErrorcode(int errorcode) { | |
30 | + return (FrontEndResult) super.setErrorcode(errorcode); | |
31 | + } | |
32 | + | |
33 | + public PageInfo getPageInfo() { | |
34 | + return pageInfo; | |
35 | + } | |
36 | + | |
37 | + public FrontEndResult setPageInfo(PageInfo pageInfo) { | |
38 | + this.pageInfo = pageInfo; | |
39 | + return this; | |
40 | + } | |
41 | + | |
42 | + public static FrontEndResult ini(int code, String msg) { | |
43 | + FrontEndResult frontEndResult = new FrontEndResult(); | |
44 | + frontEndResult.setErrormsg(msg); | |
45 | + frontEndResult.setErrorcode(code); | |
46 | + return frontEndResult; | |
47 | + } | |
48 | + | |
49 | + public static FrontEndResult ini() { | |
50 | + FrontEndResult frontEndResult = new FrontEndResult(); | |
51 | + return frontEndResult; | |
52 | + } | |
53 | +} |