|
@@ -48,11 +48,12 @@ public class CoreAuthServiceImpl implements CoreAuthService {
|
|
|
public boolean isDoingExam(Long rootOrgId, String accountType, String account) {
|
|
|
log.warn(String.format("[Check Doing Exam] rootOrgId=%s, account=%s, accountType=%s", rootOrgId, account, accountType));
|
|
|
|
|
|
- Map<String, String> params = new HashMap<>();
|
|
|
- if (rootOrgId != null) {
|
|
|
- params.put("rootOrgId", rootOrgId.toString());
|
|
|
+ if (rootOrgId == null) {
|
|
|
+ throw new StatusException("400", "学校ID为不能空!");
|
|
|
}
|
|
|
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("rootOrgId", rootOrgId.toString());
|
|
|
if (LoginType.STUDENT_CODE.name().equals(accountType)) {
|
|
|
params.put("studentCode", account);
|
|
|
} else if (LoginType.STUDENT_IDENTITY_NUMBER.name().equals(accountType)) {
|
|
@@ -84,11 +85,12 @@ public class CoreAuthServiceImpl implements CoreAuthService {
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
+
|
|
|
throw new StatusException("500", "考试状态检查异常!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<UserInfo> login(LoginInfo loginInfo) throws Exception {
|
|
|
+ public Result<UserInfo> login(LoginInfo loginInfo) {
|
|
|
Assert.notNull(loginInfo, "LoginInfo must be not null.");
|
|
|
if (StringUtils.isBlank(loginInfo.getAccountType())) {
|
|
|
loginInfo.setAccountType(LoginType.STUDENT_PHONE.name());
|
|
@@ -103,6 +105,9 @@ public class CoreAuthServiceImpl implements CoreAuthService {
|
|
|
params.put("rootOrgId", loginInfo.getRootOrgId() != null ? loginInfo.getRootOrgId().toString() : "");
|
|
|
params.put("domain", loginInfo.getDomain());
|
|
|
params.put("smsCode", loginInfo.getSmsCode());
|
|
|
+ if (loginInfo.getNoSession() != null && loginInfo.getNoSession()) {
|
|
|
+ params.put("noSession", loginInfo.getNoSession().toString());
|
|
|
+ }
|
|
|
String json = new JsonMapper().toJson(params);
|
|
|
|
|
|
RequestBody formBody = FormBody.create(MediaType.parse(Constants.CHARSET_JSON_UTF8), json);
|
|
@@ -112,19 +117,23 @@ public class CoreAuthServiceImpl implements CoreAuthService {
|
|
|
.build();
|
|
|
|
|
|
//执行请求
|
|
|
- Response response = HttpClientBuilder.getClient().newCall(request).execute();
|
|
|
- String bodyStr = response.body().string();
|
|
|
- if (response.isSuccessful()) {
|
|
|
- //获取用户信息
|
|
|
- UserInfo userInfo = new JsonMapper().fromJson(bodyStr, UserInfo.class);
|
|
|
- return new Result().success(userInfo);
|
|
|
- } else {
|
|
|
- log.warn("Http response is " + bodyStr);
|
|
|
- ResBody body = new JsonMapper().fromJson(bodyStr, ResBody.class);
|
|
|
- if (body != null && body.getCode() != null) {
|
|
|
- return new Result().error(body.getDesc());
|
|
|
+ try (Response response = HttpClientBuilder.getClient().newCall(request).execute();) {
|
|
|
+ String bodyStr = response.body().string();
|
|
|
+ if (response.isSuccessful()) {
|
|
|
+ //获取用户信息
|
|
|
+ UserInfo userInfo = new JsonMapper().fromJson(bodyStr, UserInfo.class);
|
|
|
+ return new Result().success(userInfo);
|
|
|
+ } else {
|
|
|
+ log.warn("Http response is " + bodyStr);
|
|
|
+ ResBody body = new JsonMapper().fromJson(bodyStr, ResBody.class);
|
|
|
+ if (body != null && body.getCode() != null) {
|
|
|
+ return new Result().error(body.getDesc());
|
|
|
+ }
|
|
|
+ return new Result().error(bodyStr);
|
|
|
}
|
|
|
- return new Result().error(bodyStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ throw new StatusException("500", "登录异常!");
|
|
|
}
|
|
|
}
|
|
|
|