@@ -20,6 +20,17 @@ public class CreateClientUserDto { | |||
@NotEmpty(message = "password can not be empty!") | |||
private String password; | |||
/** | |||
* 如果不是租户,传值:用户所属租户名称 | |||
*/ | |||
private String tenantName; | |||
/** | |||
* 是否为租户标识 | |||
* 0:不是;1:是 | |||
*/ | |||
private Integer tenantFlag; | |||
@NotNull(message = "clientRoleDtoList can not be null!") | |||
private List<ClientRoleDto> clientRoleDtoList; | |||
@@ -20,4 +20,8 @@ public class UserPo extends BasePo { | |||
private Integer enabled; | |||
private Long tenantId; | |||
private Integer isTenant; | |||
} |
@@ -57,6 +57,19 @@ public class ClientUserServiceImpl implements ClientUserSevice { | |||
.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); | |||
List<AuthoritiesPo> authoritiesPos = new ArrayList<>(); |
@@ -3,8 +3,8 @@ | |||
<mapper namespace="com.tuoheng.mapper.ClientUserMapper"> | |||
<insert id="insertClientUser" parameterType="com.tuoheng.model.po.UserPo" keyProperty="id" useGeneratedKeys="true"> | |||
insert into users (username, password, create_user) | |||
values (#{username}, #{password}, #{createUser}) | |||
insert into users (username, password, create_user, tenant_id, is_tenant) | |||
values (#{username}, #{password}, #{createUser}, #{tenantId}, #{isTenant}) | |||
</insert> | |||
<select id="judgeCreateByUserName" parameterType="java.lang.String" resultType="int"> |