用户id登录
This commit is contained in:
parent
b7d455ebae
commit
7a69f94343
@ -88,6 +88,18 @@ public class LoginController {
|
|||||||
return Result.success(resultMap);
|
return Result.success(resultMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperLog(operModul = "用户登录", operType = "用户id登录", operDesc = "用户id登录")
|
||||||
|
@ApiOperation(value = "用户id登录", notes = "用户id登录", httpMethod = "POST")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "userId", required = true, value = "用户id", paramType = "body"),
|
||||||
|
@ApiImplicitParam(name = "projectSn", required = false, value = "新用户账号类型需要传此参数", paramType = "body"),
|
||||||
|
})
|
||||||
|
@PostMapping(value = "/userId/login")
|
||||||
|
public Result<Map<String, Object>> userIdLogin(@RequestBody Map<String, Object> map) {
|
||||||
|
Map<String, Object> resultMap = systemUserService.userIdLogin(map);
|
||||||
|
return Result.success(resultMap);
|
||||||
|
}
|
||||||
|
|
||||||
@OperLog(operModul = "人员/设备登录", operType = "人员/设备登录", operDesc = "人员/设备登录")
|
@OperLog(operModul = "人员/设备登录", operType = "人员/设备登录", operDesc = "人员/设备登录")
|
||||||
@ApiOperation(value = "人员/设备登录", notes = "人员/设备登录", httpMethod = "POST")
|
@ApiOperation(value = "人员/设备登录", notes = "人员/设备登录", httpMethod = "POST")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
|
|||||||
@ -212,6 +212,13 @@ public interface ISystemUserService extends IService<SystemUser> {
|
|||||||
*/
|
*/
|
||||||
Map<String, Object> md5Login(Map<String, Object> map);
|
Map<String, Object> md5Login(Map<String, Object> map);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id登录
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Object> userIdLogin(Map<String, Object> map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 星纵修改密码
|
* 星纵修改密码
|
||||||
*
|
*
|
||||||
|
|||||||
@ -298,6 +298,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|||||||
|
|
||||||
Map<String, Object> result = new HashMap<>(16);
|
Map<String, Object> result = new HashMap<>(16);
|
||||||
|
|
||||||
|
String account = systemUser.getAccount();
|
||||||
if ((Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.NEW_USER.getValue()) || Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.SUPPLIER.getValue())) &&
|
if ((Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.NEW_USER.getValue()) || Objects.equals(systemUser.getAccountType(), SystemUserAccountTypeEnum.SUPPLIER.getValue())) &&
|
||||||
StringUtils.isBlank(MapUtils.getString(map, "headquartersSn"))) {
|
StringUtils.isBlank(MapUtils.getString(map, "headquartersSn"))) {
|
||||||
try {
|
try {
|
||||||
@ -306,7 +307,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String token = jwtTokenProvider.createToken(MapUtils.getString(map, "account"), 60 * 60 * 24 * 30 * 12, 0);
|
String token = jwtTokenProvider.createToken(account, 60 * 60 * 24 * 30 * 12, 0);
|
||||||
result.put("userEnterpriseId", "");
|
result.put("userEnterpriseId", "");
|
||||||
result.put("seeEquipment", 0);
|
result.put("seeEquipment", 0);
|
||||||
result.put("token", token);
|
result.put("token", token);
|
||||||
@ -336,10 +337,38 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|||||||
result.put("addProjectType", null);
|
result.put("addProjectType", null);
|
||||||
result.put("enterProjectBackType", null);
|
result.put("enterProjectBackType", null);
|
||||||
result.put("companyBigScreen", null);
|
result.put("companyBigScreen", null);
|
||||||
Map<String, Object> menuAuthority = new HashMap<>(16);
|
String projectSn = MapUtils.getString(map, "projectSn");
|
||||||
menuAuthority.put("moduleList", new ArrayList<>());
|
if (StrUtil.isNotBlank(projectSn)) {
|
||||||
menuAuthority.put("menuList", new ArrayList<>());
|
CompanyConfig companyConfig = companyConfigMapper.getCompanyConfigByProject(projectSn);
|
||||||
result.put("menuAuthority", menuAuthority);
|
if (companyConfig.getExpireTime() == null) {
|
||||||
|
throw new OpenAlertException(MessageUtil.get("loginEnabledErr"));
|
||||||
|
} else {
|
||||||
|
DateTime expireTime = DateUtil.parse(companyConfig.getExpireTime(), "yyyy-MM-dd");
|
||||||
|
DateTime currentDate = new DateTime();
|
||||||
|
|
||||||
|
if (expireTime.getTime() < currentDate.getTime()) {
|
||||||
|
throw new OpenAlertException(MessageUtil.get("loginExpiredErr"));
|
||||||
|
} else {
|
||||||
|
companyConfig.setDiffDay((int) DateUtil.between(currentDate, DateUtil.offset(expireTime, DateField.DAY_OF_MONTH, 1), DateUnit.DAY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (companyConfig == null || companyConfig.getIsEnable() == 0) {
|
||||||
|
throw new OpenAlertException(MessageUtil.get("loginEnabledErr"));
|
||||||
|
}
|
||||||
|
if (companyConfig.getDiffDay() == 0) {
|
||||||
|
throw new OpenAlertException(MessageUtil.get("loginExpiredErr"));
|
||||||
|
}
|
||||||
|
if (companyConfig.getEffectiveTime() == null) {
|
||||||
|
companyConfig.setEffectiveTime(60 * 60 * 24 * 30 * 12);
|
||||||
|
}
|
||||||
|
Map<String, Object> menuAuthority = getUserAuthority(null, SystemUserAccountTypeEnum.PROJECT_ACCOUNT.getValue(), projectSn, null, companyConfig.getStyleType());
|
||||||
|
result.put("menuAuthority", menuAuthority);
|
||||||
|
} else {
|
||||||
|
Map<String, Object> menuAuthority = new HashMap<>(16);
|
||||||
|
menuAuthority.put("moduleList", new ArrayList<>());
|
||||||
|
menuAuthority.put("menuList", new ArrayList<>());
|
||||||
|
result.put("menuAuthority", menuAuthority);
|
||||||
|
}
|
||||||
result.put("scope", scope);
|
result.put("scope", scope);
|
||||||
result.put("expire", false);
|
result.put("expire", false);
|
||||||
result.put("personMail", systemUser.getPersonMail());
|
result.put("personMail", systemUser.getPersonMail());
|
||||||
@ -410,7 +439,7 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|||||||
companyConfig.setEffectiveTime(60 * 60 * 24 * 30 * 12);
|
companyConfig.setEffectiveTime(60 * 60 * 24 * 30 * 12);
|
||||||
}
|
}
|
||||||
SystemLogoConfig slc = this.getSystemLogoConfig(companyConfig.getHeadquartersSn());
|
SystemLogoConfig slc = this.getSystemLogoConfig(companyConfig.getHeadquartersSn());
|
||||||
String token = jwtTokenProvider.createToken(MapUtils.getString(map, "account"), companyConfig.getEffectiveTime(), slc != null ? slc.getLoginTimeOut() : null);
|
String token = jwtTokenProvider.createToken(account, companyConfig.getEffectiveTime(), slc != null ? slc.getLoginTimeOut() : null);
|
||||||
UserEnterprise userEnterprise = userEnterpriseService.selectUserEnterpriseByUserId(systemUser.getUserId());
|
UserEnterprise userEnterprise = userEnterpriseService.selectUserEnterpriseByUserId(systemUser.getUserId());
|
||||||
if (userEnterprise != null) {
|
if (userEnterprise != null) {
|
||||||
result.put("userEnterpriseId", userEnterprise.getEnterpriseId());
|
result.put("userEnterpriseId", userEnterprise.getEnterpriseId());
|
||||||
@ -1518,6 +1547,21 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> userIdLogin(Map<String, Object> map) {
|
||||||
|
try {
|
||||||
|
SystemUser systemUser = systemUserMapper.selectById(MapUtils.getString(map, "userId"));
|
||||||
|
if (systemUser == null || systemUser.getUserId() == null) {
|
||||||
|
throw new OpenAlertException("账号不存在");
|
||||||
|
}
|
||||||
|
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(systemUser.getAccount(), systemUser.getShowPassword()));
|
||||||
|
return doLogin(map, systemUser);
|
||||||
|
} catch (AuthenticationException e) {
|
||||||
|
log.error("error:", e);
|
||||||
|
throw new CustomException("Invalid username/password supplied", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void xzUpdatePw(SystemUser systemUser) {
|
public void xzUpdatePw(SystemUser systemUser) {
|
||||||
Integer isCheckCode = systemUser.getIsCheckCode();
|
Integer isCheckCode = systemUser.getIsCheckCode();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user