|
|
|
@@ -10,6 +10,7 @@ import com.ruoyi.platform.domain.CodeConfig; |
|
|
|
import com.ruoyi.platform.service.CodeConfigService; |
|
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
@@ -25,6 +26,11 @@ import java.util.stream.Collectors; |
|
|
|
@Service("codeConfigService") |
|
|
|
public class CodeConfigServiceImpl implements CodeConfigService { |
|
|
|
|
|
|
|
@Value("${git.endpointIp}") |
|
|
|
private String gitEndpointIp; |
|
|
|
@Value("${git.cloneEndpointIp}") |
|
|
|
private String gitCloneEndpointIp; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private CodeConfigDao codeConfigDao; |
|
|
|
@Resource |
|
|
|
@@ -52,7 +58,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { |
|
|
|
@Override |
|
|
|
public CodeConfig insert(CodeConfig codeConfig) { |
|
|
|
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); |
|
|
|
if(id != null){ |
|
|
|
if (id != null) { |
|
|
|
throw new IllegalStateException("代码仓库名称已存在"); |
|
|
|
} |
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser(); |
|
|
|
@@ -60,6 +66,11 @@ public class CodeConfigServiceImpl implements CodeConfigService { |
|
|
|
codeConfig.setUpdateBy(loginUser.getUsername()); |
|
|
|
codeConfig.setCreateTime(new Date()); |
|
|
|
codeConfig.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
String[] split = codeConfig.getGitAccUrl().split(gitEndpointIp); |
|
|
|
if (split.length != 0) { |
|
|
|
codeConfig.setGitUrl(gitCloneEndpointIp + "/" + split[1]); |
|
|
|
} |
|
|
|
this.codeConfigDao.insert(codeConfig); |
|
|
|
return codeConfig; |
|
|
|
} |
|
|
|
@@ -67,7 +78,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { |
|
|
|
@Override |
|
|
|
public CodeConfig update(CodeConfig codeConfig) { |
|
|
|
Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); |
|
|
|
if(id != null && !id.equals(codeConfig.getId())){ |
|
|
|
if (id != null && !id.equals(codeConfig.getId())) { |
|
|
|
throw new IllegalStateException("代码仓库名称已存在"); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -80,6 +91,10 @@ public class CodeConfigServiceImpl implements CodeConfigService { |
|
|
|
codeConfig.setGitPassword(null); |
|
|
|
codeConfig.setSshKey(null); |
|
|
|
} |
|
|
|
String[] split = codeConfig.getGitAccUrl().split(gitEndpointIp); |
|
|
|
if (split.length != 0) { |
|
|
|
codeConfig.setGitUrl(gitCloneEndpointIp + "/" + split[1]); |
|
|
|
} |
|
|
|
this.codeConfigDao.update(codeConfig); |
|
|
|
return this.codeConfigDao.queryById(codeConfig.getId()); |
|
|
|
} |
|
|
|
|