|
@@ -301,10 +301,6 @@ public class TAdminController {
|
|
|
@Transactional
|
|
|
@Audit(type = AuditEnum.DELETE, content = "#loginUser.name + '删除账号'")
|
|
|
public ResponseModel<?> deleteLoginUser(@RequestBody @Valid UpdateLoginUserParam param) {
|
|
|
- //获取当前操作人员
|
|
|
-// UserDetailBO loginUser = tokenManager.getLoginUserDetails();
|
|
|
- // 保存用户实体
|
|
|
-// Date now = new Date();
|
|
|
Long parentId = param.getAdminId();
|
|
|
if (parentId == null) {
|
|
|
return R.fail(ResponseCodesEnum.A0001);
|
|
@@ -736,6 +732,68 @@ public class TAdminController {
|
|
|
return R.ok(userDetailBO);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("PC端登录")
|
|
|
+ @PostMapping("/pcLogin")
|
|
|
+ public ResponseModel<?> pcLogin(@RequestBody LoginParam loginParam, HttpServletRequest request) {
|
|
|
+ String username = loginParam.getUsername();
|
|
|
+ String password = loginParam.getPassword();
|
|
|
+ String hostName = loginParam.getHostName();
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "参数有空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //验证用户名/手机/邮箱
|
|
|
+ LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
|
|
|
+ query.eq(TAdmin::getPassword, password);
|
|
|
+ query.and(wrapper -> wrapper.eq(TAdmin::getUsername, username).or().eq(TAdmin::getPhone, username).or().eq(TAdmin::getEmail, username));
|
|
|
+ TAdmin tAdmin = Optional.ofNullable(tAdminService.getOnly(query))
|
|
|
+ .orElseThrow(() -> new BizException(ResponseCodesEnum.L0002));
|
|
|
+
|
|
|
+ // 判断是为申泽用户还是七云用户
|
|
|
+ String companyType = tAdmin.getCompanyType();
|
|
|
+ String sZ = "Sunzee";
|
|
|
+ String sC = "Sevencloud";
|
|
|
+ // 如果不为管理员
|
|
|
+ if (tAdmin.getType() >= 1) {
|
|
|
+ if (sZ.equals(hostName)) {
|
|
|
+ // 如果companyType不为空,且不等于“0”
|
|
|
+ if (StringUtils.isNotEmpty(companyType) && !companyType.equals("0")) {
|
|
|
+ return R.fail(ResponseCodesEnum.L0002);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sC.equals(hostName)) {
|
|
|
+ // 如果companyType为空,或者不等于“1”
|
|
|
+ if (StringUtils.isEmpty(companyType) || !(companyType.equals("1"))) {
|
|
|
+ return R.fail(ResponseCodesEnum.L0002);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加系统id
|
|
|
+ if (StringUtils.isEmpty(tAdmin.getManagerId())) {
|
|
|
+ String managerId = AdminUtils.encrypt(false, tAdmin.getId());
|
|
|
+ tAdmin.setManagerId(managerId);
|
|
|
+ }
|
|
|
+ // 设置登录时间
|
|
|
+ tAdmin.setLoginDate(new Date());
|
|
|
+ // 登录IP
|
|
|
+ String ipAddress;
|
|
|
+ // 获取通过代理服务器传递的真实IP地址
|
|
|
+ String xForwardedForHeader = request.getHeader("X-Forwarded-For");
|
|
|
+ if (xForwardedForHeader == null) {
|
|
|
+ ipAddress = request.getRemoteAddr();
|
|
|
+ } else {
|
|
|
+ // 多次反向代理后会有多个IP值,第一个IP才是真实IP
|
|
|
+ String[] ips = xForwardedForHeader.split(",");
|
|
|
+ ipAddress = ips[0].trim();
|
|
|
+ }
|
|
|
+ tAdmin.setLoginIp(ipAddress);
|
|
|
+ tAdminService.updateById(tAdmin);
|
|
|
+ // 添加token和刷新token
|
|
|
+
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "切换自动登录")
|
|
|
@GetMapping("/autoLogin")
|
|
|
@Audit(type = AuditEnum.LOGIN, content = "切换登录'")
|
|
@@ -1037,7 +1095,6 @@ public class TAdminController {
|
|
|
public ResponseModel<?> getAdminList() {
|
|
|
UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
|
|
|
.orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
|
|
|
-// UserDetailBO loginUserDetails = tokenManager.getLoginUserDetails();
|
|
|
String adminId = userDetailBO.getId().toString();
|
|
|
LambdaQueryWrapper<TAdmin> query = Wrappers.lambdaQuery();
|
|
|
query.eq(TAdmin::getRelationAdminId, adminId);
|
|
@@ -1048,9 +1105,6 @@ public class TAdminController {
|
|
|
@ApiOperation(value = "获取admin信息")
|
|
|
@GetMapping("/getAdminOne/{adminId}")
|
|
|
public ResponseModel<TAdmin> getAdminOne(@PathVariable Long adminId) {
|
|
|
-// UserDetailBO userDetailBO = Optional.ofNullable(tokenManager.getLoginUserDetails())
|
|
|
-// .orElseThrow(() -> new BizException(ResponseCodesEnum.L0001));
|
|
|
-// String id = userDetailBO.getId().toString();
|
|
|
TAdmin admin = tAdminService.getById(adminId);
|
|
|
if (Objects.isNull(admin)) {
|
|
|
return R.fail("当前用户不存在");
|