Commit 20cb9e33ccbc053974a81daad0fa7164e7d7b9ae
1 parent
3fb75733e1
Exists in
master
and in
1 other branch
增加退出登录接口
Showing 7 changed files with 146 additions and 58 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyManageController.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/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyManagerFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyManagerQueryRequest.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyManageController.java
View file @
20cb9e3
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import javax.servlet.http.HttpServletRequest; | |
3 | 4 | import javax.validation.Valid; |
4 | 5 | |
5 | 6 | import com.lyms.platform.common.annotation.TokenRequired; |
6 | 7 | import com.lyms.platform.common.base.BaseController; |
8 | +import com.lyms.platform.common.base.LoginContext; | |
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; |
... | ... | @@ -45,8 +47,9 @@ |
45 | 47 | @RequestMapping(value = "/babymanage", method = RequestMethod.GET) |
46 | 48 | @ResponseBody |
47 | 49 | @TokenRequired |
48 | - public BaseListResponse findBabyDataList(@Valid BabyManagerQueryRequest babyManagerRequest){ | |
49 | - return babyManagerFacade.findBabyList(babyManagerRequest); | |
50 | + public BaseListResponse findBabyDataList(@Valid BabyManagerQueryRequest babyManagerRequest,HttpServletRequest request){ | |
51 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
52 | + return babyManagerFacade.findBabyList(babyManagerRequest,loginState.getId()); | |
50 | 53 | } |
51 | 54 | |
52 | 55 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/CommunityConfigController.java
View file @
20cb9e3
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | -import java.util.ArrayList; | |
4 | -import java.util.Collections; | |
5 | -import java.util.List; | |
6 | - | |
7 | -import javax.validation.Valid; | |
8 | - | |
9 | 3 | import com.lyms.platform.biz.param.CommunityQuery; |
10 | 4 | import com.lyms.platform.biz.service.BasicConfigService; |
5 | +import com.lyms.platform.biz.service.CommunityConfigService; | |
11 | 6 | import com.lyms.platform.biz.service.PatientsService; |
12 | 7 | import com.lyms.platform.common.annotation.TokenRequired; |
13 | 8 | import com.lyms.platform.common.base.BaseController; |
9 | +import com.lyms.platform.common.base.LoginContext; | |
10 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
14 | 11 | import com.lyms.platform.common.enums.YnEnums; |
12 | +import com.lyms.platform.common.result.BaseResponse; | |
15 | 13 | import com.lyms.platform.common.utils.SystemConfig; |
16 | -import com.lyms.platform.operate.web.facade.PuerperaManagerFacade; | |
17 | -import com.lyms.platform.operate.web.request.PuerperaManagerQueryRequest; | |
14 | +import com.lyms.platform.operate.web.facade.AutoMatchFacade; | |
15 | +import com.lyms.platform.operate.web.request.CommunityConfigRequest; | |
18 | 16 | import com.lyms.platform.operate.web.result.FrontEndResult; |
19 | -import com.lyms.platform.permission.model.Regions; | |
20 | -import com.lyms.platform.permission.service.RegionsService; | |
21 | 17 | import com.lyms.platform.pojo.BasicConfig; |
18 | +import com.lyms.platform.pojo.CommunityConfig; | |
22 | 19 | import com.lyms.platform.pojo.Patients; |
23 | 20 | import com.lyms.platform.query.PatientsQuery; |
24 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
25 | 22 | import org.springframework.stereotype.Controller; |
26 | -import org.springframework.web.bind.annotation.PathVariable; | |
27 | -import org.springframework.web.bind.annotation.RequestBody; | |
28 | -import org.springframework.web.bind.annotation.RequestMapping; | |
29 | -import org.springframework.web.bind.annotation.RequestMethod; | |
30 | -import org.springframework.web.bind.annotation.RequestParam; | |
31 | -import org.springframework.web.bind.annotation.ResponseBody; | |
23 | +import org.springframework.web.bind.annotation.*; | |
32 | 24 | |
33 | -import com.lyms.platform.biz.service.CommunityConfigService; | |
34 | -import com.lyms.platform.common.constants.ErrorCodeConstants; | |
35 | -import com.lyms.platform.common.result.BaseListResponse; | |
36 | -import com.lyms.platform.common.result.BaseResponse; | |
37 | -import com.lyms.platform.operate.web.request.CommunityConfigRequest; | |
38 | -import com.lyms.platform.pojo.CommunityConfig; | |
25 | +import javax.servlet.http.HttpServletRequest; | |
26 | +import javax.validation.Valid; | |
27 | +import java.util.ArrayList; | |
28 | +import java.util.Collections; | |
29 | +import java.util.List; | |
39 | 30 | |
40 | 31 | /** |
41 | 32 | * 社区管理 |
42 | 33 | * Created by Zhang.Rui on 2016/3/18. |
43 | 34 | */ |
44 | 35 | @Controller |
45 | -public class CommunityConfigController extends BaseController { | |
36 | +public class CommunityConfigController extends BaseController { | |
46 | 37 | @Autowired |
47 | 38 | private CommunityConfigService communityConfigService; |
48 | 39 | @Autowired |
49 | 40 | private PatientsService patientsService; |
50 | 41 | @Autowired |
51 | 42 | private BasicConfigService basicConfigService; |
43 | + @Autowired | |
44 | + private AutoMatchFacade autoMatchFacade; | |
52 | 45 | |
53 | 46 | |
54 | - | |
55 | - | |
56 | 47 | //添加管辖区域 |
57 | 48 | @RequestMapping(value = "addCommunity", method = RequestMethod.POST) |
58 | 49 | @ResponseBody |
59 | 50 | @TokenRequired |
60 | 51 | public BaseResponse addCommunity(@RequestBody @Valid CommunityConfigRequest communityConfigRequest) { |
61 | 52 | String names = ""; |
62 | - for(String tmp : communityConfigRequest.getNames()) { | |
53 | + for (String tmp : communityConfigRequest.getNames()) { | |
63 | 54 | names += ", " + tmp; |
64 | 55 | } |
65 | 56 | |
66 | 57 | |
67 | 58 | CommunityConfig communityConfig = communityConfigService.getCommunityById(communityConfigRequest.getId()); |
68 | - if(null == communityConfig) return null; | |
59 | + if (null == communityConfig) return null; | |
69 | 60 | |
70 | 61 | communityConfig.setId(communityConfigRequest.getId()); |
71 | - if(null != communityConfig.getGxxq() && 0 < communityConfig.getGxxq().length() ) { | |
62 | + if (null != communityConfig.getGxxq() && 0 < communityConfig.getGxxq().length()) { | |
72 | 63 | communityConfig.setGxxq(communityConfig.getGxxq() + ", " + names.substring(1, names.length())); |
73 | 64 | } else { |
74 | - communityConfig.setGxxq( names.substring(1, names.length())); | |
65 | + communityConfig.setGxxq(names.substring(1, names.length())); | |
75 | 66 | } |
76 | 67 | communityConfig.setCreateDate(System.currentTimeMillis()); |
77 | 68 | communityConfigService.updateCommunity(communityConfig); |
78 | 69 | |
79 | 70 | |
80 | 71 | |
81 | 72 | |
82 | 73 | |
... | ... | @@ -102,27 +93,34 @@ |
102 | 93 | @RequestMapping(value = "communityConfig", method = RequestMethod.GET) |
103 | 94 | @ResponseBody |
104 | 95 | @TokenRequired |
105 | - public FrontEndResult queryCommunity(CommunityQuery communityQuery) { | |
106 | - BasicConfig config = basicConfigService.getOneBasicConfigById(communityQuery.getId()); | |
107 | - if(null != communityQuery.getId() && null == config) { | |
96 | + public FrontEndResult queryCommunity(CommunityQuery communityQuery, HttpServletRequest request) { | |
97 | + BasicConfig config = basicConfigService.getOneBasicConfigById(communityQuery.getId()); | |
98 | + if (null != communityQuery.getId() && null == config) { | |
108 | 99 | communityQuery.setId(null); |
109 | 100 | } |
110 | - List<CommunityConfig> communityConfigList = communityConfigService.queryCommunity(communityQuery); | |
101 | + //获取登录用户 | |
102 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
103 | + String areaId = autoMatchFacade.match(loginState.getId()); | |
104 | + List<CommunityConfig> communityConfigList; | |
105 | + if (null != areaId) { | |
106 | + communityQuery.setId(areaId); | |
107 | + } | |
108 | + communityConfigList = communityConfigService.queryCommunity(communityQuery); | |
111 | 109 | List<BasicConfig> basicConfigs = null; |
112 | 110 | |
113 | - if(null != communityConfigList) { | |
114 | - for(CommunityConfig communityConfig : communityConfigList) { | |
111 | + if (null != communityConfigList) { | |
112 | + for (CommunityConfig communityConfig : communityConfigList) { | |
115 | 113 | String areaNames = ""; |
116 | - basicConfigs = new ArrayList<>(); | |
117 | - for(String s : communityConfig.getAreas()) { | |
114 | + basicConfigs = new ArrayList<>(); | |
115 | + for (String s : communityConfig.getAreas()) { | |
118 | 116 | config = basicConfigService.getOneBasicConfigById(s); |
119 | 117 | basicConfigs.add(config); |
120 | - if(null != config) { | |
118 | + if (null != config) { | |
121 | 119 | areaNames += config.getName() + ", "; |
122 | 120 | } |
123 | 121 | } |
124 | - if(2 < areaNames.length()) { | |
125 | - communityConfig.setAreaNames(areaNames.substring(0, areaNames.length()-2)); | |
122 | + if (2 < areaNames.length()) { | |
123 | + communityConfig.setAreaNames(areaNames.substring(0, areaNames.length() - 2)); | |
126 | 124 | } |
127 | 125 | communityConfig.setAreasObj(basicConfigs); |
128 | 126 | } |
129 | 127 | |
130 | 128 | |
131 | 129 | |
132 | 130 | |
... | ... | @@ -134,24 +132,23 @@ |
134 | 132 | } |
135 | 133 | |
136 | 134 | |
137 | - | |
138 | 135 | //新增社区 |
139 | 136 | @RequestMapping(value = "communityConfig", method = RequestMethod.POST) |
140 | 137 | @ResponseBody |
141 | 138 | @TokenRequired |
142 | 139 | public BaseResponse appendArea(@RequestBody @Valid CommunityConfigRequest communityConfigRequest) { |
143 | - CommunityConfig communityConfig = null; | |
140 | + CommunityConfig communityConfig = null; | |
144 | 141 | BasicConfig basicConfig = null; |
145 | 142 | List<String> areaIds = new ArrayList<>(); |
146 | - for(String tmp : communityConfigRequest.getNames()) { | |
143 | + for (String tmp : communityConfigRequest.getNames()) { | |
147 | 144 | areaIds = new ArrayList<>(); |
148 | 145 | communityConfig = new CommunityConfig(); |
149 | 146 | communityConfig.setYn(YnEnums.YES.getId()); |
150 | 147 | communityConfig.setName(tmp); |
151 | 148 | basicConfig = basicConfigService.getOneBasicConfigById(communityConfigRequest.getAreaId()); |
152 | - while(null != basicConfig ) { | |
149 | + while (null != basicConfig) { | |
153 | 150 | areaIds.add(basicConfig.getId()); |
154 | - if(SystemConfig.CHINA_BASIC_ID.equals(basicConfig.getParentId())) break; | |
151 | + if (SystemConfig.CHINA_BASIC_ID.equals(basicConfig.getParentId())) break; | |
155 | 152 | basicConfig = basicConfigService.getOneBasicConfigById(basicConfig.getParentId()); |
156 | 153 | } |
157 | 154 | Collections.reverse(areaIds); |
... | ... | @@ -171,8 +168,8 @@ |
171 | 168 | public BaseResponse deleteArea(@PathVariable String id) { |
172 | 169 | PatientsQuery patientsQuery = new PatientsQuery(); |
173 | 170 | patientsQuery.setCommunityId(id); |
174 | - List<Patients > q = patientsService.queryPatient(patientsQuery); | |
175 | - if(0 < q.size()) { | |
171 | + List<Patients> q = patientsService.queryPatient(patientsQuery); | |
172 | + if (0 < q.size()) { | |
176 | 173 | return new BaseResponse().setErrorcode(ErrorCodeConstants.DONT_DELETE).setErrormsg("该社区下有产妇数据不能删除!"); |
177 | 174 | } |
178 | 175 | |
... | ... | @@ -189,7 +186,7 @@ |
189 | 186 | @RequestMapping(value = "communityConfig/{id}", method = RequestMethod.PUT) |
190 | 187 | @ResponseBody |
191 | 188 | @TokenRequired |
192 | - public BaseResponse updateArea(@RequestParam(required=true) String name, @PathVariable String id) { | |
189 | + public BaseResponse updateArea(@RequestParam(required = true) String name, @PathVariable String id) { | |
193 | 190 | CommunityConfig communityConfig = new CommunityConfig(); |
194 | 191 | communityConfig.setId(id); |
195 | 192 | communityConfig.setName(name); |
... | ... | @@ -221,7 +218,6 @@ |
221 | 218 | // return FrontEndResult.ini(ErrorCodeConstants.NO_DATA, "没有数据"); |
222 | 219 | // |
223 | 220 | // } |
224 | - | |
225 | 221 | |
226 | 222 | |
227 | 223 | // |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
20cb9e3
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import javax.servlet.http.HttpServletRequest; | |
3 | 4 | import javax.validation.Valid; |
4 | 5 | |
5 | 6 | import com.lyms.platform.common.annotation.TokenRequired; |
6 | 7 | import com.lyms.platform.common.base.BaseController; |
8 | +import com.lyms.platform.common.base.LoginContext; | |
7 | 9 | import com.lyms.platform.operate.web.facade.PatientFacade; |
8 | 10 | import com.lyms.platform.operate.web.request.PuerperaMatcherCommunityRequest; |
9 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -41,8 +43,9 @@ |
41 | 43 | @RequestMapping(value = "/puerperamanage", method = RequestMethod.GET) |
42 | 44 | @ResponseBody |
43 | 45 | @TokenRequired |
44 | - public BaseListResponse queryPuerperaList(@Valid PuerperaManagerQueryRequest managerRequest) { | |
45 | - return patientFacade.findPatientList(managerRequest); | |
46 | + public BaseListResponse queryPuerperaList(@Valid PuerperaManagerQueryRequest managerRequest,HttpServletRequest request) { | |
47 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
48 | + return patientFacade.findPatientList(managerRequest,loginState.getId()); | |
46 | 49 | } |
47 | 50 | |
48 | 51 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AutoMatchFacade.java
View file @
20cb9e3
1 | +package com.lyms.platform.operate.web.facade; | |
2 | + | |
3 | +import com.lyms.platform.biz.param.CommunityQuery; | |
4 | +import com.lyms.platform.biz.service.CommunityConfigService; | |
5 | +import com.lyms.platform.biz.service.PatientsService; | |
6 | +import com.lyms.platform.common.enums.YnEnums; | |
7 | +import com.lyms.platform.permission.model.Organization; | |
8 | +import com.lyms.platform.permission.model.Users; | |
9 | +import com.lyms.platform.permission.model.UsersQuery; | |
10 | +import com.lyms.platform.permission.service.OrganizationService; | |
11 | +import com.lyms.platform.permission.service.UsersService; | |
12 | +import com.lyms.platform.pojo.CommunityConfig; | |
13 | +import com.lyms.platform.pojo.Patients; | |
14 | +import com.lyms.platform.query.PatientsQuery; | |
15 | +import org.apache.commons.collections.CollectionUtils; | |
16 | +import org.springframework.beans.factory.annotation.Autowired; | |
17 | + | |
18 | +import java.util.List; | |
19 | + | |
20 | +/** | |
21 | + * Created by Administrator on 2016/5/3 0003. | |
22 | + */ | |
23 | +public class AutoMatchFacade { | |
24 | + @Autowired | |
25 | + private UsersService usersService; | |
26 | + @Autowired | |
27 | + private OrganizationService organizationService; | |
28 | + @Autowired | |
29 | + private CommunityConfigService communityConfigService; | |
30 | + @Autowired | |
31 | + private PatientsService patientsService; | |
32 | + | |
33 | + public String match(int userId) { | |
34 | + UsersQuery usersQuery = new UsersQuery(); | |
35 | + usersQuery.setId(userId); | |
36 | + | |
37 | + usersQuery.setYn(1); | |
38 | + List<Users> list = usersService.queryUsers(usersQuery); | |
39 | + if (CollectionUtils.isNotEmpty(list)) { | |
40 | + //用户角色 | |
41 | + if (list.get(0).getType() == 1) { | |
42 | + Organization organization = organizationService.getOrganization(list.get(0).getOrgId()); | |
43 | + return organization.getAreaId(); | |
44 | + } | |
45 | + } | |
46 | + return null; | |
47 | + } | |
48 | + | |
49 | + | |
50 | + public List<CommunityConfig> findCommunity(String areaId) { | |
51 | + CommunityQuery communityQuery = new CommunityQuery(); | |
52 | + communityQuery.setId(areaId); | |
53 | + return communityConfigService.queryCommunity(communityQuery); | |
54 | + } | |
55 | + | |
56 | + public List<Patients> findPatients(String areaId) { | |
57 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
58 | + patientsQuery.setAreaId(areaId); | |
59 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
60 | + patientsQuery.setType(3); | |
61 | + return patientsService.queryPatient(patientsQuery); | |
62 | + } | |
63 | + /*public List<BabyModel> findBaby(){ | |
64 | + | |
65 | + }*/ | |
66 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyManagerFacade.java
View file @
20cb9e3
... | ... | @@ -41,6 +41,8 @@ |
41 | 41 | private VisitFacade visitFacade; |
42 | 42 | @Autowired |
43 | 43 | private BasicConfigService basicConfigService; |
44 | + @Autowired | |
45 | + private AutoMatchFacade autoMatchFacade; | |
44 | 46 | |
45 | 47 | /** |
46 | 48 | * 根据条件查询符合条件的新生儿 |
... | ... | @@ -48,7 +50,7 @@ |
48 | 50 | * @param babyManagerRequest |
49 | 51 | * @return |
50 | 52 | */ |
51 | - public BaseListResponse findBabyList(BabyManagerQueryRequest babyManagerRequest) { | |
53 | + public BaseListResponse findBabyList(BabyManagerQueryRequest babyManagerRequest,int userId) { | |
52 | 54 | |
53 | 55 | /*PatientsQuery patientsQuery = new PatientsQuery(); |
54 | 56 | patientsQuery.setType(2); |
... | ... | @@ -93,8 +95,10 @@ |
93 | 95 | babyQuery.setMname(babyManagerRequest.getName()); |
94 | 96 | babyQuery.setLimit(babyManagerRequest.getLimit()); |
95 | 97 | babyQuery.setYn(YnEnums.YES.getId()); |
96 | - | |
97 | - | |
98 | + String areaid= autoMatchFacade.match(userId); | |
99 | + if(StringUtils.isNotEmpty(areaid)){ | |
100 | + babyQuery.setAreaId(areaid); | |
101 | + } | |
98 | 102 | List<BabyResult> data = new ArrayList<BabyResult>(); |
99 | 103 | // 根据关键字先查询产妇信息 |
100 | 104 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
20cb9e3
... | ... | @@ -43,8 +43,10 @@ |
43 | 43 | private VisitFacade visitFacade; |
44 | 44 | @Autowired |
45 | 45 | private BabyService babyService; |
46 | -@Autowired | |
46 | + @Autowired | |
47 | 47 | private BasicConfigService basicConfigService; |
48 | + @Autowired | |
49 | + private AutoMatchFacade autoMatchFacade; | |
48 | 50 | |
49 | 51 | /** |
50 | 52 | * 修改产妇的社区 |
... | ... | @@ -110,7 +112,7 @@ |
110 | 112 | * @param managerRequest |
111 | 113 | * @return |
112 | 114 | */ |
113 | - public BaseListResponse findPatientList(PuerperaManagerQueryRequest managerRequest) { | |
115 | + public BaseListResponse findPatientList(PuerperaManagerQueryRequest managerRequest,int userId) { | |
114 | 116 | PatientsQuery puerperaQuery = new PatientsQuery(); |
115 | 117 | puerperaQuery.setLimit(managerRequest.getLimit()); |
116 | 118 | puerperaQuery.setPage(managerRequest.getPage()); |
... | ... | @@ -129,6 +131,10 @@ |
129 | 131 | puerperaQuery.setType(3); |
130 | 132 | puerperaQuery.setNeed("1"); |
131 | 133 | puerperaQuery.setYn(YnEnums.YES.getId()); |
134 | + String areaid= autoMatchFacade.match(userId); | |
135 | + if(StringUtils.isNotEmpty(areaid)){ | |
136 | + puerperaQuery.setAreaId(areaid); | |
137 | + } | |
132 | 138 | // 调用service查询 |
133 | 139 | |
134 | 140 | List<Patients> puerperaList = patientsService.queryPatient(puerperaQuery); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/BabyManagerQueryRequest.java
View file @
20cb9e3
... | ... | @@ -61,6 +61,16 @@ |
61 | 61 | */ |
62 | 62 | @FormParam("dend") |
63 | 63 | private String dEnd; |
64 | + //区id | |
65 | + private String areaId; | |
66 | + | |
67 | + public String getAreaId() { | |
68 | + return areaId; | |
69 | + } | |
70 | + | |
71 | + public void setAreaId(String areaId) { | |
72 | + this.areaId = areaId; | |
73 | + } | |
64 | 74 | |
65 | 75 | public String getKeyword() { |
66 | 76 | return keyword; |