From 8f451c93755bf6d65a9435c1dd4135c8dfc447c0 Mon Sep 17 00:00:00 2001 From: shizhendong Date: Mon, 21 Oct 2024 16:39:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20workspace=20=E5=88=9B=E5=BB=BA/?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E5=90=8C=E6=AD=A5=E6=9B=B4=E6=96=B0=20GIT?= =?UTF-8?q?=20=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. workspace 创建时初始化 GIT 仓库 2. workspace 删除时删除 GIT 仓库目录 --- .../service/impl/WorkspaceServiceImpl.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/geedge/asw/module/workspace/service/impl/WorkspaceServiceImpl.java b/src/main/java/net/geedge/asw/module/workspace/service/impl/WorkspaceServiceImpl.java index 9a4a3af..1f6b139 100644 --- a/src/main/java/net/geedge/asw/module/workspace/service/impl/WorkspaceServiceImpl.java +++ b/src/main/java/net/geedge/asw/module/workspace/service/impl/WorkspaceServiceImpl.java @@ -1,6 +1,7 @@ package net.geedge.asw.module.workspace.service.impl; import cn.dev33.satoken.stp.StpUtil; +import cn.hutool.log.Log; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -12,6 +13,8 @@ import net.geedge.asw.module.workspace.entity.WorkspaceEntity; import net.geedge.asw.module.workspace.entity.WorkspaceMemberEntity; import net.geedge.asw.module.workspace.service.IWorkspaceMemberService; import net.geedge.asw.module.workspace.service.IWorkspaceService; +import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.GitAPIException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,6 +26,8 @@ import java.util.Map; @Service public class WorkspaceServiceImpl extends ServiceImpl implements IWorkspaceService { + private final static Log log = Log.get(); + @Autowired private IWorkspaceService workspaceService; @@ -57,6 +62,16 @@ public class WorkspaceServiceImpl extends ServiceImpl().in(WorkspaceMemberEntity::getWorkspaceId, workspaceIds)); + + List entityList = workspaceService.list(new LambdaQueryWrapper().in(WorkspaceEntity::getId, workspaceIds)); + if (T.CollUtil.isNotEmpty(entityList)) { + workspaceService.removeBatchByIds(workspaceIds); + workspaceMemberService.remove(new LambdaQueryWrapper().in(WorkspaceMemberEntity::getWorkspaceId, workspaceIds)); + + // remove git repo + for (WorkspaceEntity entity : entityList) { + T.FileUtil.del(T.FileUtil.file(T.WebPathUtil.getRootPath(), "workspace", entity.getId())); + } + } } private void validateWorkspaceInfo(WorkspaceEntity workspace, boolean isUpdate) {