|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
|
import com.glxp.api.admin.annotation.Log;
|
|
|
|
import com.glxp.api.admin.annotation.Log;
|
|
|
|
import com.glxp.api.admin.constant.BusinessType;
|
|
|
|
import com.glxp.api.admin.constant.BusinessType;
|
|
|
|
|
|
|
|
import com.glxp.api.admin.constant.Constant;
|
|
|
|
import com.glxp.api.admin.entity.auth.AuthCheckEntity;
|
|
|
|
import com.glxp.api.admin.entity.auth.AuthCheckEntity;
|
|
|
|
import com.glxp.api.admin.entity.info.DeviceKeyEntity;
|
|
|
|
import com.glxp.api.admin.entity.info.DeviceKeyEntity;
|
|
|
|
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
|
|
|
import com.glxp.api.admin.entity.inventory.InvSubWarehouseEntity;
|
|
|
@ -17,6 +18,7 @@ import com.glxp.api.admin.service.auth.AuthCheckService;
|
|
|
|
import com.glxp.api.admin.service.auth.DeviceKeyService;
|
|
|
|
import com.glxp.api.admin.service.auth.DeviceKeyService;
|
|
|
|
import com.glxp.api.admin.service.inventory.InvSubWarehouseService;
|
|
|
|
import com.glxp.api.admin.service.inventory.InvSubWarehouseService;
|
|
|
|
import com.glxp.api.admin.service.inventory.InvWarehouseService;
|
|
|
|
import com.glxp.api.admin.service.inventory.InvWarehouseService;
|
|
|
|
|
|
|
|
import com.glxp.api.admin.service.monitor.LogininforService;
|
|
|
|
import com.glxp.api.admin.util.*;
|
|
|
|
import com.glxp.api.admin.util.*;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
@ -58,13 +60,14 @@ public class LoginController {
|
|
|
|
private AuthCheckService authCheckService;
|
|
|
|
private AuthCheckService authCheckService;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
DeviceKeyService deviceKeyService;
|
|
|
|
DeviceKeyService deviceKeyService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private LogininforService logininforService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 用户登录
|
|
|
|
* 用户登录
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Log(title = "用户登录")
|
|
|
|
|
|
|
|
@PostMapping(value = "/login")
|
|
|
|
@PostMapping(value = "/login")
|
|
|
|
public BaseResponse index(@RequestBody @Valid LoginRequest loginRequest,
|
|
|
|
public BaseResponse index(@RequestBody @Valid LoginRequest loginRequest,
|
|
|
|
BindingResult bindingResult,
|
|
|
|
BindingResult bindingResult,
|
|
|
@ -78,7 +81,7 @@ public class LoginController {
|
|
|
|
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
|
|
|
|
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (StrUtil.isEmpty(loginRequest.getImei())) {
|
|
|
|
if (StrUtil.isEmpty(loginRequest.getImei())) {
|
|
|
|
if (!PasswordUtils.authAdminPwd(loginRequest.getPassword()).equals(SecureUtil.md5().digestHex(authAdmin.getPassWord()))) {
|
|
|
|
if (!PasswordUtils.authAdminPwd(loginRequest.getPassword()).equals(SecureUtil.sha256(authAdmin.getPassWord()))) {
|
|
|
|
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
|
|
|
|
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -115,7 +118,7 @@ public class LoginController {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> claims = new HashMap<>();
|
|
|
|
Map<String, Object> claims = new HashMap<>();
|
|
|
|
claims.put("admin_id", authAdmin.getId());
|
|
|
|
claims.put("admin_id", authAdmin.getId());
|
|
|
|
String token = JwtUtils.createToken(claims, 86400L); // 一天后过期
|
|
|
|
String token = JwtUtils.createToken(claims, 1800l); // 一天后过期
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
map.put("id", authAdmin.getId());
|
|
|
|
map.put("id", authAdmin.getId());
|
|
|
@ -128,6 +131,7 @@ public class LoginController {
|
|
|
|
loginResponse.setDeptName(authAdmin.getDeptName());
|
|
|
|
loginResponse.setDeptName(authAdmin.getDeptName());
|
|
|
|
loginResponse.setNeedChangePwd(cn.hutool.core.date.DateUtil.between(authAdmin.getLastUpdatePwdTime() == null ? cn.hutool.core.date.DateUtil.date() : authAdmin.getLastUpdatePwdTime()
|
|
|
|
loginResponse.setNeedChangePwd(cn.hutool.core.date.DateUtil.between(authAdmin.getLastUpdatePwdTime() == null ? cn.hutool.core.date.DateUtil.date() : authAdmin.getLastUpdatePwdTime()
|
|
|
|
, cn.hutool.core.date.DateUtil.date(), DateUnit.DAY) >= 90);
|
|
|
|
, cn.hutool.core.date.DateUtil.date(), DateUnit.DAY) >= 90);
|
|
|
|
|
|
|
|
logininforService.recordLogininfor(authAdmin.getEmployeeName(), Constant.LOGIN_SUCCESS, "登录成功!", request);
|
|
|
|
return ResultVOUtils.success(loginResponse);
|
|
|
|
return ResultVOUtils.success(loginResponse);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -223,7 +227,6 @@ public class LoginController {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Log(title = "获取登录用户信息")
|
|
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
|
@GetMapping("/admin/auth/login/userInfo")
|
|
|
|
@GetMapping("/admin/auth/login/userInfo")
|
|
|
|
public BaseResponse userInfo(HttpServletRequest request) {
|
|
|
|
public BaseResponse userInfo(HttpServletRequest request) {
|
|
|
@ -258,7 +261,7 @@ public class LoginController {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Log(title = "修改密码",businessType = BusinessType.UPDATE)
|
|
|
|
@Log(title = "修改密码", businessType = BusinessType.UPDATE)
|
|
|
|
@AuthRuleAnnotation("") // 需要登录验证,但是不需要权限验证时,value 值填空字符串
|
|
|
|
@AuthRuleAnnotation("") // 需要登录验证,但是不需要权限验证时,value 值填空字符串
|
|
|
|
@PostMapping("/admin/auth/login/password")
|
|
|
|
@PostMapping("/admin/auth/login/password")
|
|
|
|
public BaseResponse password(@RequestBody @Valid UpdatePasswordRequest updatePasswordRequest,
|
|
|
|
public BaseResponse password(@RequestBody @Valid UpdatePasswordRequest updatePasswordRequest,
|
|
|
|