|
|
@@ -8,6 +8,7 @@ import cn.seecoder.web.model.vo.fork.ForkVO;
|
|
|
import cn.seecoder.web.service.fork.ForkService;
|
|
|
import com.nju.edu.gitlab.SeecoderGitlabApi;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
@@ -17,6 +18,7 @@ import java.util.Objects;
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class ForkServiceImpl implements ForkService {
|
|
|
private final SeecoderGitlabApi gitlabApi;
|
|
|
private final ProjectMapper projectMapper;
|
|
|
@@ -29,6 +31,7 @@ public class ForkServiceImpl implements ForkService {
|
|
|
try {
|
|
|
ProjectPO oldProject = projectMapper.getProjectById(forkVO.getProjectId());
|
|
|
if (oldProject == null) {
|
|
|
+ log.error("不存在想要 Fork 的项目 id: " + forkVO.getProjectId());
|
|
|
return null;
|
|
|
}
|
|
|
String newName;
|
|
|
@@ -43,6 +46,7 @@ public class ForkServiceImpl implements ForkService {
|
|
|
// 检测是否已经有重名项目
|
|
|
for (com.nju.edu.gitlab.vo.ProjectVO project: allProjects) {
|
|
|
if (Objects.equals(project.getProjectName(), newName)) {
|
|
|
+ log.error("存在重名项目,项目名:" + newName);
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
@@ -57,6 +61,7 @@ public class ForkServiceImpl implements ForkService {
|
|
|
}
|
|
|
}
|
|
|
if (newProject == null) {
|
|
|
+ log.error("未知错误,貌似没有成功创建 Fork 出来的项目,新项目不存在,新 id: " + newProjectId);
|
|
|
return null;
|
|
|
}
|
|
|
// 向 Devcloud 数据库中插入新项目的 PO
|
|
|
@@ -73,6 +78,7 @@ public class ForkServiceImpl implements ForkService {
|
|
|
false);
|
|
|
return new ForkVO(newProjectId, newName);
|
|
|
} catch (Exception e) {
|
|
|
+ log.error("Fork API 异常:" + e.getMessage());
|
|
|
return null;
|
|
|
}
|
|
|
}
|