Browse Source

修改租户删除的相关逻辑

tags/v2.4.0
xiaoying 1 year ago
parent
commit
429d1e6f34
3 changed files with 15 additions and 0 deletions
  1. +3
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/ClientUserMapper.java
  2. +5
    -0
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  3. +7
    -0
      tuoheng_oidc_admin/src/main/resources/mapper/ClientUserMapper.xml

+ 3
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/ClientUserMapper.java View File

@@ -4,6 +4,8 @@ import com.tuoheng.model.po.UserPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author chenjiandong
* @description: TODO
@@ -22,4 +24,5 @@ public interface ClientUserMapper {

UserPo selectByUserId(@Param("userId") Long userId);

List<UserPo> selectByTenantId(@Param("tenantId") Long id);
}

+ 5
- 0
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

@@ -292,6 +292,11 @@ public class ClientUserServiceImpl implements ClientUserSevice {
@Override
@Transactional(rollbackFor = Exception.class)
public JsonResult deleteTenant(OidcTenantDto dto, LoginUser loginUser) {

List<UserPo> list = clientUserMapper.selectByTenantId(dto.getId());
if (ObjectUtil.isNotEmpty(list)) {
return JsonResult.error("该租户下含有关联用户,不能进行删除");
}
TenantPo tenantPo = tenantMapper.selectById(dto.getId());
tenantPo.setEnabled(0);
tenantMapper.updateById(tenantPo);

+ 7
- 0
tuoheng_oidc_admin/src/main/resources/mapper/ClientUserMapper.xml View File

@@ -29,6 +29,13 @@
WHERE id = #{userId}
and enabled = 1
</select>
<select id="selectByTenantId" resultType="com.tuoheng.model.po.UserPo">
SELECT *
FROM users
WHERE tenant_id = #{tenantId}
# 用户没有被删除
and enabled = 1
</select>

<update id="updatePass" parameterType="com.tuoheng.model.po.UserPo">
update users

Loading…
Cancel
Save