|
|
@@ -3,13 +3,12 @@ package com.tuoheng.service.impl; |
|
|
|
import com.tuoheng.mapper.AuthoritiesMapper; |
|
|
|
import com.tuoheng.mapper.ClientUserMapper; |
|
|
|
import com.tuoheng.mapper.ClientUserRoleMapper; |
|
|
|
import com.tuoheng.mapper.TenantMapper; |
|
|
|
import com.tuoheng.model.dto.LoginUser; |
|
|
|
import com.tuoheng.model.param.ClientRoleDto; |
|
|
|
import com.tuoheng.model.param.CreateClientUserDto; |
|
|
|
import com.tuoheng.model.param.UpdateUserClientRoleDto; |
|
|
|
import com.tuoheng.model.param.UpdateUserPassDto; |
|
|
|
import com.tuoheng.model.param.*; |
|
|
|
import com.tuoheng.model.po.AuthoritiesPo; |
|
|
|
import com.tuoheng.model.po.ClientUserRolePo; |
|
|
|
import com.tuoheng.model.po.TenantPo; |
|
|
|
import com.tuoheng.model.po.UserPo; |
|
|
|
import com.tuoheng.service.ClientUserSevice; |
|
|
|
import com.tuoheng.until.JsonResult; |
|
|
@@ -32,12 +31,16 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
@Autowired |
|
|
|
private ClientUserMapper clientUserMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TenantMapper tenantMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AuthoritiesMapper authoritiesMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ClientUserRoleMapper clientUserRoleMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(readOnly = true) |
|
|
|
public JsonResult judgeCreate(String username){ |
|
|
|
if(clientUserMapper.judgeCreateByUserName(username) > 0){ |
|
|
@@ -46,6 +49,7 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
return JsonResult.success(true); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult createClientUser(CreateClientUserDto createClientUserDto, LoginUser loginUser){ |
|
|
|
|
|
|
@@ -71,7 +75,13 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
} |
|
|
|
//租户逻辑新增 end |
|
|
|
clientUserMapper.insertClientUser(userPo); |
|
|
|
|
|
|
|
if(createClientUserDto.getTenantFlag() != null){ |
|
|
|
if(createClientUserDto.getTenantFlag() == 1){ |
|
|
|
TenantPo tenantPo = new TenantPo() |
|
|
|
.setUserId(userPo.getId()); |
|
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
|
} |
|
|
|
} |
|
|
|
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
|
|
|
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); |
|
|
|
for(ClientRoleDto clientRoleDto : createClientUserDto.getClientRoleDtoList()){ |
|
|
@@ -95,6 +105,48 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
return JsonResult.success(userPo.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult createClientTenant(CreateClientTenantDto createClientTenantDto, LoginUser loginUser){ |
|
|
|
|
|
|
|
if(clientUserMapper.judgeCreateByUserName(createClientTenantDto.getUsername()) > 0){ |
|
|
|
return JsonResult.error("该用户名称已存在!"); |
|
|
|
} |
|
|
|
UserPo userPo = new UserPo() |
|
|
|
.setIsTenant(1) |
|
|
|
.setUsername(createClientTenantDto.getUsername()) |
|
|
|
.setPassword("{bcrypt}" + new BCryptPasswordEncoder().encode(createClientTenantDto.getPassword())); |
|
|
|
userPo.setCreateUser(loginUser.getUserId()); |
|
|
|
clientUserMapper.insertClientUser(userPo); |
|
|
|
TenantPo tenantPo = new TenantPo() |
|
|
|
.setUserId(userPo.getId()) |
|
|
|
.setRemark(createClientTenantDto.getRemark()); |
|
|
|
tenantMapper.insertTenant(tenantPo); |
|
|
|
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
|
|
|
List<ClientUserRolePo> clientUserRolePoArrayList = new ArrayList<>(); |
|
|
|
for(ClientRoleDto clientRoleDto : createClientTenantDto.getClientRoleDtoList()){ |
|
|
|
AuthoritiesPo authoritiesPo = new AuthoritiesPo() |
|
|
|
.setUserId(userPo.getId()) |
|
|
|
.setUsername(createClientTenantDto.getUsername()) |
|
|
|
.setAuthority(clientRoleDto.getClientId()); |
|
|
|
authoritiesPo.setCreateUser(loginUser.getUserId()); |
|
|
|
authoritiesPos.add(authoritiesPo); |
|
|
|
|
|
|
|
ClientUserRolePo clientUserRolePo = new ClientUserRolePo() |
|
|
|
.setUserId(userPo.getId()) |
|
|
|
.setClientId(clientRoleDto.getClientId()) |
|
|
|
.setRoleId(clientRoleDto.getRoleId()); |
|
|
|
clientUserRolePo.setCreateUser(loginUser.getUserId()); |
|
|
|
clientUserRolePoArrayList.add(clientUserRolePo); |
|
|
|
|
|
|
|
} |
|
|
|
authoritiesMapper.batchInsert(authoritiesPos); |
|
|
|
clientUserRoleMapper.batchInsert(clientUserRolePoArrayList); |
|
|
|
return JsonResult.success(userPo.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult updateUserPassword(UpdateUserPassDto updateUserPassDto, LoginUser loginUser){ |
|
|
|
|
|
|
@@ -110,6 +162,7 @@ public class ClientUserServiceImpl implements ClientUserSevice { |
|
|
|
return JsonResult.success(true); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public JsonResult updateUserClientRole(UpdateUserClientRoleDto updateUserClientRoleDto, LoginUser loginUser){ |
|
|
|
UserPo userPo = clientUserMapper.getUserByUserName(updateUserClientRoleDto.getUsername()); |