Commit 0e87af1182494695d2e6f7710394d8fdfc93b3e9
1 parent
2e02114451
Exists in
master
and in
8 other branches
platform permission
add return pageinfo
Showing 5 changed files with 53 additions and 64 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-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.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/request/CommunityConfigRequest.java
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/param/CommunityQuery.java
View file @
0e87af1
... | ... | @@ -8,15 +8,8 @@ |
8 | 8 | public class CommunityQuery extends BaseQuery { |
9 | 9 | private String keyword; |
10 | 10 | private String id; |
11 | - private String level; | |
12 | 11 | |
13 | - public String getLevel() { | |
14 | - return level; | |
15 | - } | |
16 | 12 | |
17 | - public void setLevel(String level) { | |
18 | - this.level = level; | |
19 | - } | |
20 | 13 | |
21 | 14 | public String getId() { |
22 | 15 | return id; |
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/CommunityConfigService.java
View file @
0e87af1
... | ... | @@ -46,12 +46,8 @@ |
46 | 46 | mongoCondition = mongoCondition.orCondition(new MongoCondition[]{new MongoCondition("name", communityQuery.getKeyword(), MongoOper.LIKE), new MongoCondition("gxxq", communityQuery.getKeyword(), MongoOper.LIKE)}); |
47 | 47 | } |
48 | 48 | mongoCondition.and("yn", YnEnums.YES.getId(), MongoOper.IS); |
49 | - if(null != communityQuery.getLevel() && communityQuery.getLevel().equals("3")) { | |
50 | - mongoCondition = mongoCondition.andCondition(new MongoCondition("areaId", communityQuery.getId(), MongoOper.IS)); | |
51 | - } else if(null != communityQuery.getLevel() && communityQuery.getLevel().equals("2")) { | |
52 | - mongoCondition = mongoCondition.andCondition(new MongoCondition("cityId", communityQuery.getId(), MongoOper.IS)); | |
53 | - } else if(null != communityQuery.getLevel() && communityQuery.getLevel().equals("1")) { | |
54 | - mongoCondition = mongoCondition.andCondition(new MongoCondition("provinceId", communityQuery.getId(), MongoOper.IS)); | |
49 | + if(null != communityQuery.getId() ) { | |
50 | + mongoCondition = mongoCondition.andCondition(new MongoCondition("areas", communityQuery.getId(), MongoOper.IS)); | |
55 | 51 | } |
56 | 52 | MongoQuery mongoQuery = mongoCondition.toMongoQuery(); |
57 | 53 |
platform-dal/src/main/java/com/lyms/platform/pojo/CommunityConfig.java
View file @
0e87af1
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | import org.springframework.data.mongodb.core.mapping.Document; |
5 | 5 | |
6 | 6 | import java.util.List; |
7 | +import java.util.Map; | |
7 | 8 | |
8 | 9 | /** |
9 | 10 | * Created by Zhang.Rui on 2016/3/18. |
10 | 11 | |
11 | 12 | |
12 | 13 | |
13 | 14 | |
... | ... | @@ -15,33 +16,23 @@ |
15 | 16 | private String name; |
16 | 17 | private Integer yn; |
17 | 18 | private String gxxq; //管辖小区 |
18 | - private Integer provinceId; | |
19 | - private Integer cityId; | |
20 | - private Integer areaId; | |
19 | + private List<String> areas; | |
20 | + private String areaNames; | |
21 | 21 | |
22 | - | |
23 | - public Integer getProvinceId() { | |
24 | - return provinceId; | |
22 | + public String getAreaNames() { | |
23 | + return areaNames; | |
25 | 24 | } |
26 | 25 | |
27 | - public void setProvinceId(Integer provinceId) { | |
28 | - this.provinceId = provinceId; | |
26 | + public void setAreaNames(String areaNames) { | |
27 | + this.areaNames = areaNames; | |
29 | 28 | } |
30 | 29 | |
31 | - public Integer getCityId() { | |
32 | - return cityId; | |
30 | + public List<String> getAreas() { | |
31 | + return areas; | |
33 | 32 | } |
34 | 33 | |
35 | - public void setCityId(Integer cityId) { | |
36 | - this.cityId = cityId; | |
37 | - } | |
38 | - | |
39 | - public Integer getAreaId() { | |
40 | - return areaId; | |
41 | - } | |
42 | - | |
43 | - public void setAreaId(Integer areaId) { | |
44 | - this.areaId = areaId; | |
34 | + public void setAreas(List<String> areas) { | |
35 | + this.areas = areas; | |
45 | 36 | } |
46 | 37 | |
47 | 38 | public String getGxxq() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
0e87af1
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.Collections; | |
3 | 5 | import java.util.List; |
4 | 6 | |
5 | 7 | import javax.validation.Valid; |
... | ... | @@ -10,6 +12,7 @@ |
10 | 12 | import com.lyms.platform.common.annotation.TokenRequired; |
11 | 13 | import com.lyms.platform.common.base.BaseController; |
12 | 14 | import com.lyms.platform.common.enums.YnEnums; |
15 | +import com.lyms.platform.common.utils.SystemConfig; | |
13 | 16 | import com.lyms.platform.operate.web.facade.PuerperaManagerFacade; |
14 | 17 | import com.lyms.platform.operate.web.request.PuerperaManagerQueryRequest; |
15 | 18 | import com.lyms.platform.operate.web.result.FrontEndResult; |
16 | 19 | |
17 | 20 | |
18 | 21 | |
... | ... | @@ -98,12 +101,25 @@ |
98 | 101 | @ResponseBody |
99 | 102 | @TokenRequired |
100 | 103 | public FrontEndResult queryCommunity(CommunityQuery communityQuery) { |
101 | - List<CommunityConfig> communityConfigList = communityConfigService.queryCommunity(communityQuery); | |
102 | 104 | BasicConfig config = basicConfigService.getOneBasicConfigById(communityQuery.getId()); |
103 | - if(null == config) { | |
105 | + if(null != communityQuery.getId() && null == config) { | |
104 | 106 | return FrontEndResult.ini(ErrorCodeConstants.PARAMETER_ERROR, "address ID error"); |
105 | 107 | } |
108 | + List<CommunityConfig> communityConfigList = communityConfigService.queryCommunity(communityQuery); | |
106 | 109 | if(null != communityConfigList) { |
110 | + for(CommunityConfig communityConfig : communityConfigList) { | |
111 | + String areaNames = ""; | |
112 | + for(String s : communityConfig.getAreas()) { | |
113 | + config = basicConfigService.getOneBasicConfigById(s); | |
114 | + if(null != config) { | |
115 | + areaNames += config.getName() + ", "; | |
116 | + } | |
117 | + } | |
118 | + if(2 < areaNames.length()) { | |
119 | + communityConfig.setAreaNames(areaNames.substring(0, areaNames.length()-2)); | |
120 | + } | |
121 | + } | |
122 | + | |
107 | 123 | return FrontEndResult.ini().setData(communityConfigList).setPageInfo(communityQuery.getPageInfo()).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("查询成功"); |
108 | 124 | } |
109 | 125 | return FrontEndResult.ini(ErrorCodeConstants.NO_DATA, "没有数据"); |
110 | 126 | |
111 | 127 | |
... | ... | @@ -118,13 +134,22 @@ |
118 | 134 | @TokenRequired |
119 | 135 | public BaseResponse appendArea(@RequestBody @Valid CommunityConfigRequest communityConfigRequest) { |
120 | 136 | CommunityConfig communityConfig = null; |
137 | + BasicConfig basicConfig = null; | |
138 | + List<String> areaIds = new ArrayList<>(); | |
121 | 139 | for(String tmp : communityConfigRequest.getNames()) { |
140 | + areaIds = new ArrayList<>(); | |
122 | 141 | communityConfig = new CommunityConfig(); |
123 | 142 | communityConfig.setYn(YnEnums.YES.getId()); |
124 | 143 | communityConfig.setName(tmp); |
125 | - communityConfig.setProvinceId(communityConfigRequest.getProvinceId()); | |
126 | - communityConfig.setCityId(communityConfigRequest.getCityId()); | |
127 | - communityConfig.setAreaId(communityConfigRequest.getAreaId()); | |
144 | + basicConfig = basicConfigService.getOneBasicConfigById(communityConfigRequest.getAreaId()); | |
145 | + while(null != basicConfig ) { | |
146 | + areaIds.add(basicConfig.getId()); | |
147 | + if(SystemConfig.CHINA_BASIC_ID.equals(basicConfig.getParentId())) break; | |
148 | + basicConfig = basicConfigService.getOneBasicConfigById(basicConfig.getParentId()); | |
149 | + } | |
150 | + Collections.reverse(areaIds); | |
151 | + communityConfig.setAreas(areaIds); | |
152 | + | |
128 | 153 | communityConfigService.appendCommunity(communityConfig); |
129 | 154 | } |
130 | 155 | return new BaseResponse() |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/CommunityConfigRequest.java
View file @
0e87af1
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | import com.lyms.platform.common.core.annotation.form.Form; |
4 | 4 | |
5 | 5 | import javax.validation.constraints.NotNull; |
6 | +import java.util.Map; | |
6 | 7 | |
7 | 8 | /** |
8 | 9 | * Created by Zhang.Rui on 2016/3/18. |
9 | 10 | |
... | ... | @@ -11,12 +12,18 @@ |
11 | 12 | public class CommunityConfigRequest { |
12 | 13 | |
13 | 14 | private String id; |
14 | - private Integer provinceId; | |
15 | - private Integer cityId; | |
16 | - private Integer areaId; | |
15 | + private String areaId; | |
17 | 16 | @NotNull(message = "添加内容不能为空") |
18 | 17 | private String[] names; |
19 | 18 | |
19 | + public String getAreaId() { | |
20 | + return areaId; | |
21 | + } | |
22 | + | |
23 | + public void setAreaId(String areaId) { | |
24 | + this.areaId = areaId; | |
25 | + } | |
26 | + | |
20 | 27 | public String getId() { |
21 | 28 | return id; |
22 | 29 | } |
... | ... | @@ -25,29 +32,6 @@ |
25 | 32 | this.id = id; |
26 | 33 | } |
27 | 34 | |
28 | - public Integer getProvinceId() { | |
29 | - return provinceId; | |
30 | - } | |
31 | - | |
32 | - public void setProvinceId(Integer provinceId) { | |
33 | - this.provinceId = provinceId; | |
34 | - } | |
35 | - | |
36 | - public Integer getCityId() { | |
37 | - return cityId; | |
38 | - } | |
39 | - | |
40 | - public void setCityId(Integer cityId) { | |
41 | - this.cityId = cityId; | |
42 | - } | |
43 | - | |
44 | - public Integer getAreaId() { | |
45 | - return areaId; | |
46 | - } | |
47 | - | |
48 | - public void setAreaId(Integer areaId) { | |
49 | - this.areaId = areaId; | |
50 | - } | |
51 | 35 | |
52 | 36 | public String[] getNames() { |
53 | 37 | return names; |