Commit 6ac33240d1b9ecca65f8963f583b0bd3e4194a9e
Exists in
master
and in
8 other branches
Merge remote-tracking branch 'origin/master'
Showing 4 changed files
- platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java
- platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java
View file @
6ac3324
... | ... | @@ -64,26 +64,27 @@ |
64 | 64 | return null; |
65 | 65 | } |
66 | 66 | |
67 | - public static String loginHospitalUser(String phone, String pwd, String typeId, String token) { | |
67 | + public static LoginContext loginHospitalUser(String account, String pwd, String typeId, String token) { | |
68 | 68 | HttpClient client = new HttpClient(); |
69 | 69 | PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/userLogin.action"); |
70 | + NameValuePair[] data = { | |
71 | + new NameValuePair("account", account), | |
72 | + new NameValuePair("typeId", typeId), | |
73 | + new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd)?"p":md5(pwd).toUpperCase()) | |
74 | + }; | |
75 | + post.setRequestBody(data); | |
76 | + post.setRequestHeader("Authorization", token); | |
70 | 77 | try { |
71 | - NameValuePair[] data = { | |
72 | - new NameValuePair("phone", phone), | |
73 | - new NameValuePair("typeId", typeId), | |
74 | - new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd)?"p":md5(pwd)) | |
75 | - }; | |
76 | - post.setRequestBody(data); | |
77 | - post.setRequestHeader("Authorization", token); | |
78 | 78 | client.executeMethod(post); |
79 | 79 | int statusCode = post.getStatusCode(); |
80 | 80 | String result = new String(post.getResponseBodyAsString()); |
81 | 81 | |
82 | 82 | post.releaseConnection(); |
83 | + LoginContext loginState = new LoginContext(); | |
83 | 84 | if (200 == statusCode) { |
84 | - LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
85 | + loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
85 | 86 | if (0 == loginState.getErrorcode()) { |
86 | - return loginState.getToken(); | |
87 | + return loginState; | |
87 | 88 | } |
88 | 89 | } |
89 | 90 | } catch (Exception e) { |
... | ... | @@ -92,7 +93,7 @@ |
92 | 93 | return null; |
93 | 94 | } |
94 | 95 | |
95 | - public static String login(String phone, String varCode, String typeId, String token) { | |
96 | + public static LoginContext login(String phone, String varCode, String typeId, String token) { | |
96 | 97 | HttpClient client = new HttpClient(); |
97 | 98 | PostMethod post = new MessageUtil.UTF8PostMethod("http://passport.healthbaby.com.cn/v1/login.action"); |
98 | 99 | NameValuePair[] data = { |
99 | 100 | |
100 | 101 | |
... | ... | @@ -108,10 +109,11 @@ |
108 | 109 | String result = new String(post.getResponseBodyAsString()); |
109 | 110 | |
110 | 111 | post.releaseConnection(); |
112 | + LoginContext loginState = new LoginContext(); | |
111 | 113 | if (200 == statusCode) { |
112 | - LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
114 | + loginState = JsonUtil.str2Obj(result, LoginContext.class); | |
113 | 115 | if (0 == loginState.getErrorcode()) { |
114 | - return loginState.getToken(); | |
116 | + return loginState; | |
115 | 117 | } |
116 | 118 | } |
117 | 119 | } catch (Exception e) { |
platform-dal/src/main/java/com/lyms/platform/query/PatientsQuery.java
View file @
6ac3324
... | ... | @@ -218,15 +218,11 @@ |
218 | 218 | if(-1!=yn){ |
219 | 219 | condition=condition.and("yn", yn, MongoOper.IS); |
220 | 220 | } |
221 | - if(-1!=type){ | |
221 | + //去掉type为3 的情况 | |
222 | + /* if(-1!=type){ | |
222 | 223 | condition=condition.and("type", type, MongoOper.IS); |
223 | - } | |
224 | - /*if(null!=dueDateStart){ | |
225 | -// condition= condition.elemMatch("dueDate",MongoCondition.newInstance("$lte", dueDateStart, MongoOper.IS).and("$gte", dueDateEnd, MongoOper.IS)); | |
226 | -// condition=condition.and("dueDate", dueDateStart, MongoOper.GTE).and("dueDate", dueDateEnd, MongoOper.LTE); | |
227 | - Criteria c = Criteria.where("dueDate").gte(dueDateStart).lte(dueDateEnd).andOperator(condition.getCriteria()); | |
228 | - return new MongoCondition(c).toMongoQuery(); | |
229 | 224 | }*/ |
225 | + | |
230 | 226 | boolean isAddStart = Boolean.FALSE; |
231 | 227 | Criteria c = null; |
232 | 228 | if (null != dueDateStart) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/OrganizationController.java
View file @
6ac3324
... | ... | @@ -320,6 +320,8 @@ |
320 | 320 | map.put("cityId", organization.getCityId()); |
321 | 321 | map.put("province", organization.getProvince()); |
322 | 322 | map.put("provinceId", organization.getProvinceId()); |
323 | + map.put("foreignId",organization.getForeignId()); | |
324 | + map.put("code",organization.getShortCode()); | |
323 | 325 | return map; |
324 | 326 | } |
325 | 327 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/UsersController.java
View file @
6ac3324
... | ... | @@ -171,10 +171,11 @@ |
171 | 171 | */ |
172 | 172 | @RequestMapping(value = "/tokens", method = RequestMethod.POST) |
173 | 173 | public void usersLogin(@RequestParam(value = "account") String account, |
174 | - @RequestParam(value = "vercode") String code, | |
174 | + @RequestParam(value = "vercode", required = false) String code, | |
175 | + @RequestParam(value = "password", required = false) String password, | |
175 | 176 | HttpServletResponse response) { |
176 | 177 | Map<String, Object> resultMsgMap = new HashMap<>(); |
177 | - if (StringUtils.isEmpty(account) || StringUtils.isEmpty(code)) { | |
178 | + if (StringUtils.isEmpty(account) && (StringUtils.isEmpty(code) || StringUtils.isEmpty(password))) { | |
178 | 179 | resultMsgMap.put(ResultUtils.ERROR_CODE, ConstantInterface.PARAMETER_ERROR);//参数错误 |
179 | 180 | resultMsgMap.put(ResultUtils.ERROR_MSG, "登录账户或者验证码为空,请输入"); |
180 | 181 | //把这个map转成一个json字符串输出到前台 |
181 | 182 | |
182 | 183 | |
183 | 184 | |
184 | 185 | |
... | ... | @@ -182,26 +183,40 @@ |
182 | 183 | return; |
183 | 184 | } |
184 | 185 | |
186 | + //code 不为空使用手机登录, password不为空时使用帐号登录 | |
185 | 187 | UsersQuery usersQuery = new UsersQuery(); |
186 | - usersQuery.setPhone(account); | |
188 | + usersQuery.setYn(YnEnums.YES.getId()); | |
189 | + if(null != code) { | |
190 | + usersQuery.setPhone(account); | |
191 | + } | |
192 | + if(null != password) { | |
193 | + usersQuery.setAccount(account); | |
194 | + } | |
187 | 195 | List<Users> users = usersService.queryUsers(usersQuery); |
188 | 196 | if(0 == users.size()) { |
189 | 197 | ResultUtils.buildParameterErrorResultAndWrite(response, "该账户不存在"); |
190 | 198 | return; |
191 | 199 | } |
192 | 200 | |
193 | - String key =LoginUtil.login(account, code, typeId, token); | |
194 | - if(null != key) { | |
201 | + LoginContext loginContext = null; | |
202 | + if(null != code) { | |
203 | + loginContext =LoginUtil.login(account, code, typeId, token); | |
204 | + } | |
205 | + if(null != password) { | |
206 | + loginContext = LoginUtil.loginHospitalUser(account, password, typeId, token); | |
207 | + } | |
208 | + | |
209 | + if(null != loginContext) { | |
195 | 210 | Users users1 = new Users(); |
196 | 211 | users1.setId(users.get(0).getId()); |
197 | 212 | users1.setLastLoginTime(new Date()); |
198 | 213 | usersService.updateUsers(users1); |
199 | 214 | |
200 | 215 | Map<String, Object> result = new HashMap<>(); |
201 | - result.put("token", key); | |
216 | + result.put("token", loginContext.getToken()); | |
202 | 217 | ResultUtils.buildSuccessResultAndWrite(response, result); |
203 | 218 | }else { |
204 | - ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.PARAMETER_ERROR, "登录失败,手机或验证码错误"); | |
219 | + ResultUtils.buildResultAndWrite(response, ErrorCodeConstants.PARAMETER_ERROR, loginContext.getErrormsg()); | |
205 | 220 | } |
206 | 221 | } |
207 | 222 | |
... | ... | @@ -218,7 +233,7 @@ |
218 | 233 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse); |
219 | 234 | return; |
220 | 235 | } |
221 | - if(!phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+d{8})$")) { | |
236 | + if(!phone.matches("^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\\d{8})$")) { | |
222 | 237 | ResultUtils.buildParameterErrorResultAndWrite(httpServletResponse, "手机号不正确!"); |
223 | 238 | return; |
224 | 239 | } |