Browse Source

更新

tags/v2.4.1
xiaoying 1 year ago
parent
commit
26ad03cee4
3 changed files with 57 additions and 40 deletions
  1. +57
    -40
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  2. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class
  3. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class

+ 57
- 40
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public JsonResult createClientUser(CreateClientUserDto createClientUserDto, LoginUser loginUser) { public JsonResult createClientUser(CreateClientUserDto createClientUserDto, LoginUser loginUser) {


log.info("请求参数:{}", createClientUserDto.toString());
if (clientUserMapper.judgeCreateByUserName(createClientUserDto.getUsername()) > 0) { 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<AuthoritiesPo> authoritiesPos = new ArrayList<>();
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>();
if (ObjectUtil.isNotNull(tTenant)) { if (ObjectUtil.isNotNull(tTenant)) {
return JsonResult.error("该租户code已存在,请重新输入"); 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) { for (String code : codes) {
JsonResult result = getResult(dto, code, loginUser); JsonResult result = getResult(dto, code, loginUser);
if (result.getCode() != JsonResult.SUCCESS) { if (result.getCode() != JsonResult.SUCCESS) {
UserPo userPo = clientUserMapper.selectByUserId(tenantPo.getUserId()); UserPo userPo = clientUserMapper.selectByUserId(tenantPo.getUserId());
userPo.setEnabled(0); userPo.setEnabled(0);
clientUserMapper.updatePass(userPo); 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) { for (String code : codes) {
JsonResult jsonResult = deleteResult(dto, code, loginUser); JsonResult jsonResult = deleteResult(dto, code, loginUser);
if (jsonResult.getCode() != JsonResult.SUCCESS) { if (jsonResult.getCode() != JsonResult.SUCCESS) {
if (ObjectUtil.isEmpty(dto.getTenantCode())) { if (ObjectUtil.isEmpty(dto.getTenantCode())) {
return JsonResult.error("租户code不能为空"); 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) { for (String code : codes) {
JsonResult jsonResult = editResult(dto, code, loginUser); JsonResult jsonResult = editResult(dto, code, loginUser);
if (jsonResult.getCode() != JsonResult.SUCCESS) { if (jsonResult.getCode() != JsonResult.SUCCESS) {
//case AirportConstant.AIRPORT_CLIENT: //case AirportConstant.AIRPORT_CLIENT:
// url = url + AirportConstant.CREATE_TENANT; // url = url + AirportConstant.CREATE_TENANT;
// break; // break;
//航道
case WaterWayConstant.WATERWAY_CLIENT: case WaterWayConstant.WATERWAY_CLIENT:
url = url + WaterWayConstant.CREATE_TENANT; url = url + WaterWayConstant.CREATE_TENANT;
dto.setClientId(WaterWayConstant.WATERWAY_CLIENT_ADMIN + CommonConstant.COMMA + WaterWayConstant.WATERWAY_CLIENT_MP); dto.setClientId(WaterWayConstant.WATERWAY_CLIENT_ADMIN + CommonConstant.COMMA + WaterWayConstant.WATERWAY_CLIENT_MP);

BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/constant/HhzUrlConstant.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class View File


Loading…
Cancel
Save