|
|
@@ -74,44 +74,60 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult createClientUser(CreateClientUserDto createClientUserDto, LoginUser loginUser) { |
|
|
|
|
|
|
|
log.info("请求参数:{}", createClientUserDto.toString()); |
|
|
|
if (clientUserMapper.judgeCreateByUserName(createClientUserDto.getUsername()) > 0) { |
|
|
|
return JsonResult.error("该用户名称已存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
UserPo userPo = new UserPo() |
|
|
|
.setUsername(createClientUserDto.getUsername()) |
|
|
|
.setPassword("{bcrypt}" + new BCryptPasswordEncoder().encode(createClientUserDto.getPassword())); |
|
|
|
userPo.setCreateUser(loginUser.getUserId()); |
|
|
|
//租户逻辑新增 start |
|
|
|
if (createClientUserDto.getTenantFlag() != null) { |
|
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
|
userPo.setIsTenant(1); |
|
|
|
} else { |
|
|
|
userPo.setIsTenant(0); |
|
|
|
UserPo po = clientUserMapper.getUserByUserName(createClientUserDto.getTenantName()); |
|
|
|
if (po != null) { |
|
|
|
userPo.setTenantId(po.getId()); |
|
|
|
return getObjectJsonResult(createClientUserDto, loginUser); |
|
|
|
} else { |
|
|
|
UserPo userPo = new UserPo() |
|
|
|
.setUsername(createClientUserDto.getUsername()) |
|
|
|
.setPassword("{bcrypt}" + new BCryptPasswordEncoder().encode(createClientUserDto.getPassword())); |
|
|
|
userPo.setCreateUser(loginUser.getUserId()); |
|
|
|
//租户逻辑新增 start |
|
|
|
if (createClientUserDto.getTenantFlag() != null) { |
|
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
|
userPo.setIsTenant(1); |
|
|
|
} else { |
|
|
|
userPo.setIsTenant(0); |
|
|
|
UserPo po = clientUserMapper.getUserByUserName(createClientUserDto.getTenantName()); |
|
|
|
if (po != null) { |
|
|
|
userPo.setTenantId(po.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//租户逻辑新增 end |
|
|
|
clientUserMapper.insertClientUser(userPo); |
|
|
|
if (createClientUserDto.getTenantFlag() != null) { |
|
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
|
tenantPo.setUserId(userPo.getId()); |
|
|
|
//添加租户code |
|
|
|
tenantPo.setCode(createClientUserDto.getCode()); |
|
|
|
tenantPo.setName(createClientUserDto.getName()); |
|
|
|
tenantPo.setProvinceCode(createClientUserDto.getProvinceCode()); |
|
|
|
tenantPo.setProvinceName(createClientUserDto.getProvinceName()); |
|
|
|
tenantPo.setDistrictCode(createClientUserDto.getDistrictCode()); |
|
|
|
tenantPo.setDistrictName(createClientUserDto.getDistrictName()); |
|
|
|
tenantPo.setCityCode(createClientUserDto.getCityCode()); |
|
|
|
tenantPo.setCityName(createClientUserDto.getCityName()); |
|
|
|
log.debug("信息:" + tenantPo.toString()); |
|
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
|
//租户逻辑新增 end |
|
|
|
clientUserMapper.insertClientUser(userPo); |
|
|
|
if (createClientUserDto.getTenantFlag() != null) { |
|
|
|
if (createClientUserDto.getTenantFlag() == 1) { |
|
|
|
TenantPo tenantPo = new TenantPo(); |
|
|
|
tenantPo.setUserId(userPo.getId()); |
|
|
|
//添加租户code |
|
|
|
tenantPo.setCode(createClientUserDto.getCode()); |
|
|
|
tenantPo.setName(createClientUserDto.getName()); |
|
|
|
tenantPo.setProvinceCode(createClientUserDto.getProvinceCode()); |
|
|
|
tenantPo.setProvinceName(createClientUserDto.getProvinceName()); |
|
|
|
tenantPo.setDistrictCode(createClientUserDto.getDistrictCode()); |
|
|
|
tenantPo.setDistrictName(createClientUserDto.getDistrictName()); |
|
|
|
tenantPo.setCityCode(createClientUserDto.getCityCode()); |
|
|
|
tenantPo.setCityName(createClientUserDto.getCityName()); |
|
|
|
log.debug("信息:" + tenantPo.toString()); |
|
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
|
} |
|
|
|
} |
|
|
|
return getObjectJsonResult(createClientUserDto, loginUser); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 用户/租户更新关联关系 |
|
|
|
* |
|
|
|
* @param createClientUserDto |
|
|
|
* @param loginUser |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private JsonResult getObjectJsonResult(CreateClientUserDto createClientUserDto, LoginUser loginUser) { |
|
|
|
UserPo userPo = clientUserMapper.getUserByUserName(createClientUserDto.getUsername()); |
|
|
|
if (ObjectUtil.isNull(userPo)) { |
|
|
|
return JsonResult.error("此用户不存在"); |
|
|
|
} |
|
|
|
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
|
|
|
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); |
|
|
@@ -296,8 +312,8 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
if (ObjectUtil.isNotNull(tTenant)) { |
|
|
|
return JsonResult.error("该租户code已存在,请重新输入"); |
|
|
|
} |
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
if (dto.getClientId().contains(CommonConstant.COMMA)) { |
|
|
|
String[] codes = dto.getClientId().split(CommonConstant.COMMA); |
|
|
|
for (String code : codes) { |
|
|
|
JsonResult result = getResult(dto, code, loginUser); |
|
|
|
if (result.getCode() != JsonResult.SUCCESS) { |
|
|
@@ -384,8 +400,8 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
UserPo userPo = clientUserMapper.selectByUserId(tenantPo.getUserId()); |
|
|
|
userPo.setEnabled(0); |
|
|
|
clientUserMapper.updatePass(userPo); |
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
if (dto.getClientId().contains(CommonConstant.COMMA)) { |
|
|
|
String[] codes = dto.getClientId().split(CommonConstant.COMMA); |
|
|
|
for (String code : codes) { |
|
|
|
JsonResult jsonResult = deleteResult(dto, code, loginUser); |
|
|
|
if (jsonResult.getCode() != JsonResult.SUCCESS) { |
|
|
@@ -415,8 +431,8 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
if (ObjectUtil.isEmpty(dto.getTenantCode())) { |
|
|
|
return JsonResult.error("租户code不能为空"); |
|
|
|
} |
|
|
|
if (dto.getClientId().contains(",")) { |
|
|
|
String[] codes = dto.getClientId().split(","); |
|
|
|
if (dto.getClientId().contains(CommonConstant.COMMA)) { |
|
|
|
String[] codes = dto.getClientId().split(CommonConstant.COMMA); |
|
|
|
for (String code : codes) { |
|
|
|
JsonResult jsonResult = editResult(dto, code, loginUser); |
|
|
|
if (jsonResult.getCode() != JsonResult.SUCCESS) { |
|
|
@@ -487,6 +503,7 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
//case AirportConstant.AIRPORT_CLIENT: |
|
|
|
// url = url + AirportConstant.CREATE_TENANT; |
|
|
|
// break; |
|
|
|
//航道 |
|
|
|
case WaterWayConstant.WATERWAY_CLIENT: |
|
|
|
url = url + WaterWayConstant.CREATE_TENANT; |
|
|
|
dto.setClientId(WaterWayConstant.WATERWAY_CLIENT_ADMIN + CommonConstant.COMMA + WaterWayConstant.WATERWAY_CLIENT_MP); |