|
@@ -43,7 +43,6 @@ import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.controller.bean.UserFormDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.base.constants.BasicConsts;
|
|
|
-import cn.com.qmth.examcloud.core.basic.base.enums.AccountType;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.OrgRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.RoleRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.UserRepo;
|
|
@@ -52,8 +51,6 @@ import cn.com.qmth.examcloud.core.basic.dao.entity.OrgEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.RoleEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.UserRoleRelationEntity;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.AuthService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.impl.UserServiceImpl;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
@@ -77,9 +74,6 @@ public class UserController extends ControllerSupport {
|
|
|
@Autowired
|
|
|
RoleRepo roleRepo;
|
|
|
|
|
|
- @Autowired
|
|
|
- AuthService authService;
|
|
|
-
|
|
|
@Autowired
|
|
|
UserRoleRelationRepo userRoleRelationRepo;
|
|
|
|
|
@@ -561,80 +555,4 @@ public class UserController extends ControllerSupport {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 系统遗留,谨慎修改
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @param loginName
|
|
|
- * @param password
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "登录1", notes = "登录")
|
|
|
- @PostMapping("/login")
|
|
|
- public Map<String, Object> login1(@RequestParam String loginName, @RequestParam String password,
|
|
|
- @RequestParam(required = false) Long rootOrgId) {
|
|
|
- return login(loginName, password, rootOrgId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 系统遗留,谨慎修改
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @param rootOrgId
|
|
|
- * @param loginName
|
|
|
- * @param password
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ApiOperation(value = "登录2", notes = "登录")
|
|
|
- @PostMapping("/login/{rootOrgId}")
|
|
|
- public Map<String, Object> login2(@PathVariable long rootOrgId, @RequestParam String loginName,
|
|
|
- @RequestParam String password) {
|
|
|
- return login(loginName, password, rootOrgId);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 废弃的登陆
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @param loginName
|
|
|
- * @param password
|
|
|
- * @param rootOrgId
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Map<String, Object> login(String loginName, String password, Long rootOrgId) {
|
|
|
-
|
|
|
- UserEntity user = null;
|
|
|
- if (null != rootOrgId) {
|
|
|
- user = userRepo.findByRootOrgIdAndLoginName(rootOrgId, loginName);
|
|
|
- } else {
|
|
|
- List<UserEntity> userList = userRepo.findByLoginName(loginName);
|
|
|
- if (CollectionUtils.isNotEmpty(userList)) {
|
|
|
- user = null;
|
|
|
- }
|
|
|
- if (1 == userList.size()) {
|
|
|
- user = userList.get(0);
|
|
|
- } else if (1 < userList.size()) {
|
|
|
- throw new StatusException("B-001003", "不同顶级机构下存在相同登录名");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (user == null) {
|
|
|
- throw new StatusException("B-001001", "该用户不存在");
|
|
|
- } else if (!user.getEnable()) {
|
|
|
- throw new StatusException("B-001002", "该用户被禁用");
|
|
|
- }
|
|
|
-
|
|
|
- LoginInfo loginInfo = new LoginInfo();
|
|
|
- loginInfo.setAccountType(AccountType.COMMON_LOGIN_NAME.name());
|
|
|
- loginInfo.setAccountValue(user.getLoginName());
|
|
|
- loginInfo.setPassword(user.getPassword());
|
|
|
- loginInfo.setRootOrgId(user.getRootOrgId());
|
|
|
- User loginUser = authService.login(loginInfo);
|
|
|
-
|
|
|
- Map<String, Object> ret = Maps.newHashMap();
|
|
|
- ret.put("userId", loginUser.getUserId());
|
|
|
- ret.put("token", loginUser.getKey() + ":" + loginUser.getToken());
|
|
|
- return ret;
|
|
|
- }
|
|
|
-
|
|
|
}
|