diff --git a/platform-web-ui/src/views/project/list/index.vue b/platform-web-ui/src/views/project/list/index.vue index f2214fb..1892d7a 100644 --- a/platform-web-ui/src/views/project/list/index.vue +++ b/platform-web-ui/src/views/project/list/index.vue @@ -73,8 +73,12 @@ diff --git a/server/molly-cms/src/main/java/com/xaaef/molly/corems/mapper/CmsProjectMapper.java b/server/molly-cms/src/main/java/com/xaaef/molly/corems/mapper/CmsProjectMapper.java index 23e0de3..a6b76ca 100644 --- a/server/molly-cms/src/main/java/com/xaaef/molly/corems/mapper/CmsProjectMapper.java +++ b/server/molly-cms/src/main/java/com/xaaef/molly/corems/mapper/CmsProjectMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xaaef.molly.corems.entity.CmsProject; import com.xaaef.molly.corems.entity.TenantAndProject; +import org.apache.ibatis.annotations.Param; import java.util.Collection; import java.util.Set; @@ -28,8 +29,17 @@ public interface CmsProjectMapper extends BaseMapper { Set selectListTableNamesByNotIncludeColumn(String column); + // 查询 所有的包含 project_id 的表 + @InterceptorIgnore(tenantLine = "true") + Set selectListTableNamesByIncludeColumn(String column); + + + // 删除项目 + @InterceptorIgnore(tenantLine = "true") + int deleteByProjectId(@Param("tableName") Set tableName, @Param("projectId") Long projectId); + + // 根据 租户的数据名称 查询 项目列表。如: molly_master 、molly_google Set selectListByTenantDbName(Collection tenantDbNameList); - } diff --git a/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java b/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java index 026f7c3..38dec67 100644 --- a/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java +++ b/server/molly-cms/src/main/java/com/xaaef/molly/corems/service/impl/CmsProjectServiceImpl.java @@ -22,10 +22,12 @@ import org.springframework.stereotype.Service; import java.util.Collection; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import static com.xaaef.molly.auth.jwt.JwtSecurityUtils.*; import static com.xaaef.molly.common.consts.ConfigName.PROJECT_DEFAULT_PASSWORD; +import static com.xaaef.molly.common.consts.MbpConst.PROJECT_ID; /** @@ -171,11 +173,18 @@ public class CmsProjectServiceImpl extends BaseServiceImpl tableNames = baseMapper.selectListTableNamesByIncludeColumn(PROJECT_ID); + // 删除 此项目 在所有表中的数据 + if (!tableNames.isEmpty()) { + baseMapper.deleteByProjectId(tableNames, dbProject.getProjectId()); + } + // 租户 删除 此项目 tenantService.tenantDelProjectId(TenantUtils.getTenantId(), dbProject.getProjectId()); return flag2; } diff --git a/server/molly-cms/src/main/resources/mapper/CmsProjectMapper.xml b/server/molly-cms/src/main/resources/mapper/CmsProjectMapper.xml index 224f5c9..bfd4e3e 100644 --- a/server/molly-cms/src/main/resources/mapper/CmsProjectMapper.xml +++ b/server/molly-cms/src/main/resources/mapper/CmsProjectMapper.xml @@ -16,6 +16,18 @@ + + + + + + DELETE FROM ${item} WHERE `project_id` = #{projectId}; + + + +