|
@@ -11,8 +11,8 @@ import cn.com.qmth.examcloud.app.model.LoginInfo;
|
|
|
import cn.com.qmth.examcloud.app.model.LoginType;
|
|
|
import cn.com.qmth.examcloud.app.model.Result;
|
|
|
import cn.com.qmth.examcloud.app.model.UserInfo;
|
|
|
-import cn.com.qmth.examcloud.app.service.CoreBasicService;
|
|
|
import cn.com.qmth.examcloud.app.service.CoreAuthService;
|
|
|
+import cn.com.qmth.examcloud.app.service.CoreBasicService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.slf4j.Logger;
|
|
@@ -26,7 +26,6 @@ import static cn.com.qmth.examcloud.app.model.Constants.PARAM_APP_TOKEN;
|
|
|
/**
|
|
|
* 认证中心相关接口
|
|
|
*
|
|
|
- * @version v1.0
|
|
|
* @author: fengdesheng
|
|
|
* @since: 2018/7/16
|
|
|
*/
|
|
@@ -40,41 +39,58 @@ public class UserAuthRestController {
|
|
|
@Autowired
|
|
|
private CoreBasicService basicService;
|
|
|
|
|
|
- @ApiOperation(value = "登录接口", notes = "参数accountType值说明:学生身份证号类型=STUDENT_IDENTITY_NUMBER,学生学号类型=STUDENT_CODE,学生手机号类型=STUDENT_PHONE")
|
|
|
+ @ApiOperation(value = "登录接口", notes = "参数accountType值:STUDENT_IDENTITY_NUMBER、STUDENT_CODE、STUDENT_PHONE")
|
|
|
@RequestMapping(value = "/user/login", method = {RequestMethod.POST})
|
|
|
- public Result<UserInfo> login(@RequestParam String account, @RequestParam String password, @RequestParam String accountType, @RequestParam(required = false) Long rootOrgId,
|
|
|
- @RequestParam(required = false) String domain, @RequestHeader String deviceId) throws Exception {
|
|
|
+ public Result<UserInfo> login(@RequestParam String account,
|
|
|
+ @RequestParam String password,
|
|
|
+ @RequestParam String accountType,
|
|
|
+ @RequestParam(required = false) Long rootOrgId,
|
|
|
+ @RequestParam(required = false) String domain,
|
|
|
+ @RequestHeader String deviceId) throws Exception {
|
|
|
LoginInfo loginInfo = new LoginInfo(account, password, accountType, rootOrgId, domain, deviceId, null);
|
|
|
Result<UserInfo> result = authService.login(loginInfo);
|
|
|
+
|
|
|
if (result.isSuccess() && result.getData() != null) {
|
|
|
//登录成功后缓存Token信息
|
|
|
UserInfo userInfo = result.getData();
|
|
|
+ loginInfo.setUserId(userInfo.getUserId());
|
|
|
+ loginInfo.setRootOrgId(userInfo.getRootOrgId());
|
|
|
loginInfo.setUserName(userInfo.getDisplayName());
|
|
|
loginInfo.setKey(userInfo.getKey());
|
|
|
loginInfo.setToken(userInfo.getToken());
|
|
|
loginInfo.setAppToken(userInfo.getToken());
|
|
|
+
|
|
|
authService.cacheLoginInfo(loginInfo, userInfo.getKey());
|
|
|
log.info(String.format("key:%s token:%s", userInfo.getKey(), userInfo.getToken()));
|
|
|
}
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "验证码接口", notes = "参数accountType值说明:学生身份证号类型=STUDENT_IDENTITY_NUMBER,学生学号类型=STUDENT_CODE,学生手机号类型=STUDENT_PHONE")
|
|
|
+ @ApiOperation(value = "验证码登录接口")
|
|
|
@RequestMapping(value = "/user/verify", method = {RequestMethod.POST})
|
|
|
- public Result<UserInfo> verifyLogin(@RequestParam String account, @RequestParam String smsCode, @RequestParam(required = false) Long rootOrgId,
|
|
|
- @RequestParam(required = false) String domain, @RequestHeader String deviceId) throws Exception {
|
|
|
+ public Result<UserInfo> verifyLogin(@RequestParam String account,
|
|
|
+ @RequestParam String smsCode,
|
|
|
+ @RequestParam(required = false) Long rootOrgId,
|
|
|
+ @RequestParam(required = false) String domain,
|
|
|
+ @RequestHeader String deviceId) throws Exception {
|
|
|
LoginInfo loginInfo = new LoginInfo(account, null, LoginType.STUDENT_PHONE.name(), rootOrgId, domain, deviceId, smsCode);
|
|
|
Result<UserInfo> result = authService.login(loginInfo);
|
|
|
+
|
|
|
if (result.isSuccess() && result.getData() != null) {
|
|
|
//登录成功后缓存Token信息
|
|
|
UserInfo userInfo = result.getData();
|
|
|
+ loginInfo.setUserId(userInfo.getUserId());
|
|
|
+ loginInfo.setRootOrgId(userInfo.getRootOrgId());
|
|
|
loginInfo.setUserName(userInfo.getDisplayName());
|
|
|
loginInfo.setToken(userInfo.getToken());
|
|
|
loginInfo.setKey(userInfo.getKey());
|
|
|
loginInfo.setAppToken(userInfo.getToken());
|
|
|
+
|
|
|
authService.cacheLoginInfo(loginInfo, userInfo.getKey());
|
|
|
log.info(String.format("key:%s token:%s", userInfo.getKey(), userInfo.getToken()));
|
|
|
}
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|