feat(项目管理-初始化项目): #5363 工作项导入及导出
This commit is contained in:
parent
5eb783f6fe
commit
7af1fdadaf
|
|
@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -391,4 +392,18 @@ public class PmsProjectIssuesController extends BaseController {
|
|||
public GenericsTableDataInfo<PmsProjectTestsheetCaseVo> linkTestcase(@ApiParam("工作项id") @PathVariable Long issueId, @ApiParam("项目Id") @RequestParam(name = "pmProjectId") Long pmProjectId) {
|
||||
return pmsProjectTestsheetIssuesService.getProjectIssueLinkTestcaseList(issueId, pmProjectId);
|
||||
}
|
||||
|
||||
@RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe"}, logical = Logical.OR)
|
||||
@PostMapping("/import")
|
||||
@ApiOperation(value = "导入工作项")
|
||||
public AjaxResult importIssuesFromFile(@PathVariable String enterpriseIdentifier, @RequestPart("file") MultipartFile file, @ApiParam("项目Id") @RequestParam(name = "pmProjectId") Long pmProjectId) {
|
||||
return success(pmsProjectIssuesService.importIssuesFromFile(enterpriseIdentifier, file, pmProjectId));
|
||||
}
|
||||
|
||||
@RequiresPermissions(value = {"pms:pmsProject:show", "pms:pmsProject:showMe"}, logical = Logical.OR)
|
||||
@GetMapping("/export")
|
||||
@ApiOperation(value = "导出工作项")
|
||||
public void exportIssues(HttpServletResponse response, @ApiParam("项目Id") @RequestParam(name = "pmProjectId") Long pmProjectId) {
|
||||
pmsProjectIssuesService.exportIssues(response, pmProjectId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import com.microservices.common.core.exception.ServiceException;
|
|||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.pms.enterprise.domain.PmsEnterprise;
|
||||
import com.microservices.pms.enterprise.service.IPmsEnterpriseService;
|
||||
import com.microservices.pms.project.domain.PmsProject;
|
||||
import com.microservices.pms.project.domain.SimpleRepository;
|
||||
import com.microservices.pms.project.domain.vo.*;
|
||||
|
|
@ -20,6 +22,7 @@ import org.springframework.context.annotation.Lazy;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -51,6 +54,9 @@ public class PmsProjectIssuesService {
|
|||
@Lazy
|
||||
private IPmsProjectTestsheetIssuesService pmsProjectTestsheetIssuesService;
|
||||
|
||||
@Autowired
|
||||
private IPmsEnterpriseService pmsEnterpriseService;
|
||||
|
||||
|
||||
public JSONObject selectPmsProjectIssuesList(PmsProjectIssuesSearchVo pmsProjectIssuesSearchVo) {
|
||||
pmsProjectService.selectAndCheckPmsProjectById(pmsProjectIssuesSearchVo.getPmProjectId());
|
||||
|
|
@ -323,4 +329,25 @@ public class PmsProjectIssuesService {
|
|||
public JSONObject deletePmsEnterpriseIssueTag(Long tagId) {
|
||||
return gitLinkRequestHelper.doDelete(PmsGitLinkRequestUrl.DELETE_ORGANIZATION_ISSUE_TAG(tagId));
|
||||
}
|
||||
|
||||
public JSONObject importIssuesFromFile(String enterpriseIdentifier, MultipartFile file, Long pmProjectId) {
|
||||
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseByIdentifier(enterpriseIdentifier);
|
||||
JSONObject result;
|
||||
try {
|
||||
result = gitLinkRequestHelper.doPostFile(PmsGitLinkRequestUrl.IMPORT_ISSUES(pmProjectId, pmsEnterprise.getGitlinkOrgId()), file);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new ServiceException("导入工作项失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void exportIssues(HttpServletResponse response, Long pmProjectId) {
|
||||
try {
|
||||
gitLinkRequestHelper.doGetResponse(PmsGitLinkRequestUrl.EXPORT_ISSUES(pmProjectId), response);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
throw new ServiceException("导出工作项失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,6 +261,16 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
return getGitLinkRequestUrl(path);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl IMPORT_ISSUES(Long pmProjectId, Long organizationId) {
|
||||
String path = String.format("/api/pm/issues/import?pm_project_id=%s&organization_id=%s", pmProjectId, organizationId);
|
||||
return getGitLinkRequestUrl(path);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl EXPORT_ISSUES(Long pmProjectId) {
|
||||
String path = "/api/pm/issues/export?pm_project_id=" + pmProjectId;
|
||||
return getGitLinkRequestUrl(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织下代码库列表
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue