|
|
@@ -50,8 +50,8 @@ public class EditOidcTenantService { |
|
|
|
Tenant tenant = (Tenant) result.getData(); |
|
|
|
|
|
|
|
User oldUser = userMapper.selectOne(new LambdaQueryWrapper<User>() |
|
|
|
.eq(User::getUsername, request.getUsername()) |
|
|
|
.eq(User::getMark, MarkEnum.VALID.getCode())); |
|
|
|
.eq(User::getUsername, request.getUsername()) |
|
|
|
.eq(User::getMark, MarkEnum.VALID.getCode())); |
|
|
|
User user = this.buildUser(request); |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(request.getClientId()) && !oldUser.getClientId().equals(user.getClientId())) { |
|
|
@@ -98,7 +98,6 @@ public class EditOidcTenantService { |
|
|
|
* |
|
|
|
* @param request |
|
|
|
* @param |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult check(EditOidcTenantRequest request) { |
|
|
@@ -115,8 +114,8 @@ public class EditOidcTenantService { |
|
|
|
return JsonResult.error(400, "租户编号"); |
|
|
|
} |
|
|
|
Tenant tenant = tenantMapper.selectOne(new LambdaQueryWrapper<Tenant>() |
|
|
|
.eq(Tenant::getUsername, request.getUsername()) |
|
|
|
.eq(Tenant::getMark, MarkEnum.VALID.getCode())); |
|
|
|
.eq(Tenant::getUsername, request.getUsername()) |
|
|
|
.eq(Tenant::getMark, MarkEnum.VALID.getCode())); |
|
|
|
if (ObjectUtil.isNull(tenant)) { |
|
|
|
return JsonResult.error("系统中不存在该租户"); |
|
|
|
} |
|
|
@@ -130,7 +129,7 @@ public class EditOidcTenantService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改租户 |
|
|
|
* 修改租户 |
|
|
|
*/ |
|
|
|
private JsonResult updateTenant(Tenant tenant, EditOidcTenantRequest request) { |
|
|
|
// 如果是租户先去创建 |
|
|
@@ -141,8 +140,7 @@ public class EditOidcTenantService { |
|
|
|
tenant.setDistrictName(request.getDistrictName()); |
|
|
|
tenant.setCityCode(request.getCityCode()); |
|
|
|
tenant.setCityName(request.getCityName()); |
|
|
|
|
|
|
|
Integer count = tenantMapper.insert(tenant); |
|
|
|
Integer count = tenantMapper.updateById(tenant); |
|
|
|
if (count <= 0) { |
|
|
|
log.info("修改租户失败"); |
|
|
|
JsonResult.error("修改租户失败"); |
|
|
@@ -156,14 +154,27 @@ public class EditOidcTenantService { |
|
|
|
private User buildUser(EditOidcTenantRequest request) { |
|
|
|
// 创建用户数据 |
|
|
|
User user = new User(); |
|
|
|
user.setUsername(request.getUsername()); |
|
|
|
user.setRealname(request.getTenantName()); |
|
|
|
user.setNickname(request.getTenantName()); |
|
|
|
user.setPassword(CommonUtils.password(request.getPassword())); |
|
|
|
user.setProvinceCode(request.getProvinceCode()); |
|
|
|
user.setCityCode(request.getCityCode()); |
|
|
|
user.setCityName(request.getCityName()); |
|
|
|
user.setDistrictCode(request.getDistrictCode()); |
|
|
|
user.setClientId(this.getClientId(request.getClientId())); |
|
|
|
if (StringUtils.isNotEmpty(request.getPassword())) { |
|
|
|
user.setPassword(CommonUtils.password(request.getPassword())); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(request.getProvinceCode())) { |
|
|
|
user.setProvinceCode(request.getProvinceCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(request.getCityCode())) { |
|
|
|
user.setCityCode(request.getCityCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(request.getCityName())) { |
|
|
|
user.setCityName(request.getCityName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(request.getDistrictCode())) { |
|
|
|
user.setDistrictCode(request.getDistrictCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(request.getClientId())) { |
|
|
|
user.setClientId(this.getClientId(request.getClientId())); |
|
|
|
} |
|
|
|
user.setUpdateTime(DateUtils.now()); |
|
|
|
return user; |
|
|
|
} |
|
|
@@ -188,17 +199,18 @@ public class EditOidcTenantService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改用户 |
|
|
|
* 修改用户 |
|
|
|
*/ |
|
|
|
private JsonResult editUser(User user) { |
|
|
|
User userTmp = userMapper.selectOne(Wrappers.<User>lambdaQuery() |
|
|
|
.eq(User::getMark, 1) |
|
|
|
.eq(User::getMark, MarkEnum.VALID.getCode()) |
|
|
|
.eq(User::getStatus, 1) |
|
|
|
.eq(User::getUsername, user.getUsername())); |
|
|
|
if (ObjectUtil.isNull(userTmp)) { |
|
|
|
log.info("修改租户用户,用户不存在,username:{}", user.getUsername()); |
|
|
|
return JsonResult.error("修改租户用户,不用户存在"); |
|
|
|
} |
|
|
|
user.setId(userTmp.getId()); |
|
|
|
Integer rowCount = userMapper.updateById(user); |
|
|
|
if (rowCount <= 0) { |
|
|
|
log.info("修改租户用户失败,username:{}", user.getUsername()); |