Commit fed3b72787653f1b4fe6e7c296d3d04047bc8374
1 parent
8c1f5efc26
Exists in
master
and in
8 other branches
登录修改
Showing 1 changed file with 14 additions and 18 deletions
platform-common/src/main/java/com/lyms/platform/common/utils/LoginUtil.java
View file @
fed3b72
| ... | ... | @@ -5,20 +5,15 @@ |
| 5 | 5 | import org.apache.commons.httpclient.NameValuePair; |
| 6 | 6 | import org.apache.commons.httpclient.methods.GetMethod; |
| 7 | 7 | import org.apache.commons.httpclient.methods.PostMethod; |
| 8 | -import org.apache.commons.lang.*; | |
| 9 | 8 | import org.slf4j.Logger; |
| 10 | 9 | import org.slf4j.LoggerFactory; |
| 11 | 10 | import org.springframework.util.StopWatch; |
| 12 | 11 | |
| 13 | -import java.security.MessageDigest; | |
| 14 | -import java.security.NoSuchAlgorithmException; | |
| 15 | - | |
| 16 | 12 | public class LoginUtil { |
| 17 | 13 | private static Logger logger = LoggerFactory.getLogger("HTTP-INVOKE"); |
| 18 | 14 | |
| 19 | 15 | |
| 20 | - | |
| 21 | - public static LoginContext register(String userId, String phone,String account, String pwd, String token, String typeId) { | |
| 16 | + public static LoginContext register(String userId, String phone, String account, String pwd, String token, String typeId) { | |
| 22 | 17 | StopWatch stopWatch = new StopWatch("aouHospitalUser"); |
| 23 | 18 | stopWatch.start("init http client"); |
| 24 | 19 | HttpClient client = new HttpClient(); |
| 25 | 20 | |
| ... | ... | @@ -45,13 +40,13 @@ |
| 45 | 40 | stopWatch.start("parse json"); |
| 46 | 41 | LoginContext loginState = JsonUtil.str2Obj(result, LoginContext.class); |
| 47 | 42 | stopWatch.stop(); |
| 48 | - if (0 == loginState.getErrorcode()) { | |
| 49 | - return loginState; | |
| 50 | - } | |
| 43 | +// if (0 == loginState.getErrorcode()) { | |
| 44 | + return loginState; | |
| 45 | +// } | |
| 51 | 46 | } |
| 52 | 47 | } catch (Exception e) { |
| 53 | 48 | e.printStackTrace(); |
| 54 | - }finally { | |
| 49 | + } finally { | |
| 55 | 50 | logger.info(stopWatch.toString()); |
| 56 | 51 | } |
| 57 | 52 | return null; |
| ... | ... | @@ -65,7 +60,7 @@ |
| 65 | 60 | NameValuePair[] data = { |
| 66 | 61 | new NameValuePair("account", account), |
| 67 | 62 | new NameValuePair("typeId", typeId), |
| 68 | - new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd)?"p":MD5Utils.md5(pwd).toUpperCase()) | |
| 63 | + new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd) ? "p" : MD5Utils.md5(pwd).toUpperCase()) | |
| 69 | 64 | }; |
| 70 | 65 | post.setRequestBody(data); |
| 71 | 66 | post.setRequestHeader("Authorization", token); |
| ... | ... | @@ -125,7 +120,7 @@ |
| 125 | 120 | } |
| 126 | 121 | } catch (Exception e) { |
| 127 | 122 | e.printStackTrace(); |
| 128 | - }finally { | |
| 123 | + } finally { | |
| 129 | 124 | logger.info(stopWatch.toString()); |
| 130 | 125 | } |
| 131 | 126 | return null; |
| ... | ... | @@ -139,7 +134,7 @@ |
| 139 | 134 | NameValuePair[] data = { |
| 140 | 135 | new NameValuePair("account", account), |
| 141 | 136 | new NameValuePair("typeId", typeId), |
| 142 | - new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd)?"p":MD5Utils.md5(pwd).toUpperCase()) | |
| 137 | + new NameValuePair("password", org.apache.commons.lang.StringUtils.isBlank(pwd) ? "p" : MD5Utils.md5(pwd).toUpperCase()) | |
| 143 | 138 | }; |
| 144 | 139 | post.setRequestBody(data); |
| 145 | 140 | post.setRequestHeader("Authorization", token); |
| ... | ... | @@ -161,7 +156,7 @@ |
| 161 | 156 | } |
| 162 | 157 | } catch (Exception e) { |
| 163 | 158 | e.printStackTrace(); |
| 164 | - }finally { | |
| 159 | + } finally { | |
| 165 | 160 | logger.info(stopWatch.toString()); |
| 166 | 161 | } |
| 167 | 162 | return null; |
| ... | ... | @@ -186,7 +181,8 @@ |
| 186 | 181 | int statusCode = post.getStatusCode(); |
| 187 | 182 | String result = new String(post.getResponseBodyAsString()); |
| 188 | 183 | |
| 189 | - post.releaseConnection();stopWatch.stop(); | |
| 184 | + post.releaseConnection(); | |
| 185 | + stopWatch.stop(); | |
| 190 | 186 | |
| 191 | 187 | LoginContext loginState = new LoginContext(); |
| 192 | 188 | if (200 == statusCode) { |
| ... | ... | @@ -197,7 +193,7 @@ |
| 197 | 193 | } |
| 198 | 194 | } catch (Exception e) { |
| 199 | 195 | e.printStackTrace(); |
| 200 | - }finally { | |
| 196 | + } finally { | |
| 201 | 197 | logger.info(stopWatch.toString()); |
| 202 | 198 | } |
| 203 | 199 | return null; |
| ... | ... | @@ -238,7 +234,7 @@ |
| 238 | 234 | } |
| 239 | 235 | } catch (Exception e) { |
| 240 | 236 | e.printStackTrace(); |
| 241 | - }finally { | |
| 237 | + } finally { | |
| 242 | 238 | logger.info(stopWatch.toString()); |
| 243 | 239 | } |
| 244 | 240 | return null; |
| ... | ... | @@ -269,7 +265,7 @@ |
| 269 | 265 | } |
| 270 | 266 | } catch (Exception e) { |
| 271 | 267 | e.printStackTrace(); |
| 272 | - }finally { | |
| 268 | + } finally { | |
| 273 | 269 | logger.info(stopWatch.toString()); |
| 274 | 270 | } |
| 275 | 271 | return loginState; |