refactor(缺陷管理): 优化缺陷管理部分内容
This commit is contained in:
parent
2bbee050aa
commit
43cbf5edd5
|
@ -238,11 +238,11 @@ public class PermissionConstants {
|
||||||
/*------ end: API_DEBUG ------*/
|
/*------ end: API_DEBUG ------*/
|
||||||
|
|
||||||
/*------ start: BUG ------*/
|
/*------ start: BUG ------*/
|
||||||
public static final String BUG_READ = "BUG:READ";
|
public static final String PROJECT_BUG_READ = "PROJECT_BUG:READ";
|
||||||
public static final String BUG_ADD = "BUG:READ+ADD";
|
public static final String PROJECT_BUG_ADD = "PROJECT_BUG:READ+ADD";
|
||||||
public static final String BUG_UPDATE = "BUG:READ+UPDATE";
|
public static final String PROJECT_BUG_UPDATE = "PROJECT_BUG:READ+UPDATE";
|
||||||
public static final String BUG_DELETE = "BUG:READ+DELETE";
|
public static final String PROJECT_BUG_DELETE = "PROJECT_BUG:READ+DELETE";
|
||||||
public static final String BUG_EXPORT = "PROJECT_BUG:READ+EXPORT";
|
public static final String PROJECT_BUG_EXPORT = "PROJECT_BUG:READ+EXPORT";
|
||||||
/*------ end: BUG ------*/
|
/*------ end: BUG ------*/
|
||||||
/*------ start: API_MANAGEMENT ------*/
|
/*------ start: API_MANAGEMENT ------*/
|
||||||
public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ";
|
public static final String PROJECT_API_DEFINITION_READ = "PROJECT_API_DEFINITION:READ";
|
||||||
|
|
|
@ -46,105 +46,104 @@ public class BugController {
|
||||||
|
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
@Operation(summary = "缺陷管理-获取缺陷列表")
|
@Operation(summary = "缺陷管理-获取缺陷列表")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
|
||||||
public Pager<List<BugDTO>> page(@Validated @RequestBody BugPageRequest request) {
|
public Pager<List<BugDTO>> page(@Validated @RequestBody BugPageRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||||
request.setUseTrash(false);
|
request.setUseTrash(false);
|
||||||
return PageUtils.setPageInfo(page, bugService.list(request));
|
return PageUtils.setPageInfo(page, bugService.list(request, SessionUtils.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@Operation(summary = "缺陷管理-创建缺陷")
|
@Operation(summary = "缺陷管理-创建缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_ADD)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_ADD)
|
||||||
public void add(@Validated({Created.class}) @RequestPart(value = "request") BugEditRequest request,
|
public void add(@Validated({Created.class}) @RequestPart(value = "request") BugEditRequest request,
|
||||||
@RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
@RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
||||||
bugService.addOrUpdate(request, files, SessionUtils.getUserId(), false);
|
bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@Operation(summary = "缺陷管理-更新缺陷")
|
@Operation(summary = "缺陷管理-更新缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void update(@Validated({Updated.class}) @RequestPart(value = "request") BugEditRequest request,
|
public void update(@Validated({Updated.class}) @RequestPart(value = "request") BugEditRequest request,
|
||||||
@RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
@RequestPart(value = "file", required = false) List<MultipartFile> files) {
|
||||||
bugService.addOrUpdate(request, files, SessionUtils.getUserId(), true);
|
bugService.addOrUpdate(request, files, SessionUtils.getUserId(), SessionUtils.getCurrentOrganizationId(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/delete/{id}")
|
@GetMapping("/delete/{id}")
|
||||||
@Operation(summary = "缺陷管理-删除缺陷")
|
@Operation(summary = "缺陷管理-删除缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_DELETE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_DELETE)
|
||||||
public void delete(@PathVariable String id) {
|
public void delete(@PathVariable String id) {
|
||||||
bugService.delete(id);
|
bugService.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/template/option")
|
@GetMapping("/template/option")
|
||||||
@Operation(summary = "缺陷管理-获取当前项目缺陷模板选项")
|
@Operation(summary = "缺陷管理-获取当前项目缺陷模板选项")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
|
||||||
public List<ProjectTemplateOptionDTO> getTemplateOption(@RequestParam(value = "projectId") String projectId) {
|
public List<ProjectTemplateOptionDTO> getTemplateOption(@RequestParam(value = "projectId") String projectId) {
|
||||||
return projectTemplateService.getOption(projectId, TemplateScene.BUG.name());
|
return projectTemplateService.getOption(projectId, TemplateScene.BUG.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/template/detail")
|
@PostMapping("/template/detail")
|
||||||
@Operation(summary = "缺陷管理-获取模板详情内容")
|
@Operation(summary = "缺陷管理-获取模板详情内容")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_READ)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_READ)
|
||||||
public TemplateDTO getTemplateDetail(@RequestBody BugTemplateRequest request) {
|
public TemplateDTO getTemplateDetail(@RequestBody BugTemplateRequest request) {
|
||||||
return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey());
|
return bugService.getTemplate(request.getId(), request.getProjectId(), request.getFromStatusId(), request.getPlatformBugKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch-delete")
|
@PostMapping("/batch-delete")
|
||||||
@Operation(summary = "缺陷管理-批量删除缺陷")
|
@Operation(summary = "缺陷管理-批量删除缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_DELETE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_DELETE)
|
||||||
public void batchDelete(@Validated @RequestBody BugBatchRequest request) {
|
public void batchDelete(@Validated @RequestBody BugBatchRequest request) {
|
||||||
bugService.batchDelete(request);
|
bugService.batchDelete(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/batch-update")
|
@PostMapping("/batch-update")
|
||||||
@Operation(summary = "缺陷管理-批量编辑缺陷")
|
@Operation(summary = "缺陷管理-批量编辑缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void batchUpdate(@Validated @RequestBody BugBatchUpdateRequest request) {
|
public void batchUpdate(@Validated @RequestBody BugBatchUpdateRequest request) {
|
||||||
bugService.batchUpdate(request);
|
bugService.batchUpdate(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/follow/{id}")
|
@GetMapping("/follow/{id}")
|
||||||
@Operation(summary = "缺陷管理-关注缺陷")
|
@Operation(summary = "缺陷管理-关注缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void follow(@PathVariable String id) {
|
public void follow(@PathVariable String id) {
|
||||||
bugService.follow(id, SessionUtils.getUserId());
|
bugService.follow(id, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/unfollow/{id}")
|
@GetMapping("/unfollow/{id}")
|
||||||
@Operation(summary = "缺陷管理-取消关注缺陷")
|
@Operation(summary = "缺陷管理-取消关注缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void unfollow(@PathVariable String id) {
|
public void unfollow(@PathVariable String id) {
|
||||||
bugService.unfollow(id, SessionUtils.getUserId());
|
bugService.unfollow(id, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/sync/{projectId}")
|
@GetMapping("/sync/{projectId}")
|
||||||
@Operation(summary = "缺陷管理-同步缺陷(开源)")
|
@Operation(summary = "缺陷管理-同步缺陷(开源)")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void sync(@PathVariable String projectId) {
|
public void sync(@PathVariable String projectId) {
|
||||||
bugSyncService.syncBugs(projectId);
|
bugSyncService.syncBugs(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sync/all")
|
@PostMapping("/sync/all")
|
||||||
@Operation(summary = "缺陷管理-同步缺陷(全量)")
|
@Operation(summary = "缺陷管理-同步缺陷(全量)")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void syncAll(@RequestBody BugSyncRequest request) {
|
public void syncAll(@RequestBody BugSyncRequest request) {
|
||||||
bugSyncService.syncAllBugs(request);
|
bugSyncService.syncAllBugs(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export/columns/{projectId}")
|
@GetMapping("/export/columns/{projectId}")
|
||||||
@Operation(summary = "缺陷管理-获取导出字段配置")
|
@Operation(summary = "缺陷管理-获取导出字段配置")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_EXPORT)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT)
|
||||||
public BugExportColumns getExportColumns(@PathVariable String projectId) {
|
public BugExportColumns getExportColumns(@PathVariable String projectId) {
|
||||||
return bugService.getExportColumns(projectId);
|
return bugService.getExportColumns(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
@Operation(summary = "缺陷管理-批量导出缺陷")
|
@Operation(summary = "缺陷管理-批量导出缺陷")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_EXPORT)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT)
|
||||||
public ResponseEntity<byte[]> export(@Validated @RequestBody BugExportRequest request) throws Exception {
|
public ResponseEntity<byte[]> export(@Validated @RequestBody BugExportRequest request) throws Exception {
|
||||||
return bugService.export(request);
|
return bugService.export(request, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class BugRelateCaseController {
|
||||||
|
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
@Operation(description = "缺陷管理-关联用例-列表分页查询")
|
@Operation(description = "缺陷管理-关联用例-列表分页查询")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public Pager<List<BugRelateCaseDTO>> page(@Validated @RequestBody BugRelatedCasePageRequest request) {
|
public Pager<List<BugRelateCaseDTO>> page(@Validated @RequestBody BugRelatedCasePageRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize());
|
||||||
return PageUtils.setPageInfo(page, bugRelateCaseService.page(request));
|
return PageUtils.setPageInfo(page, bugRelateCaseService.page(request));
|
||||||
|
@ -36,7 +36,7 @@ public class BugRelateCaseController {
|
||||||
|
|
||||||
@GetMapping("/un-relate/{id}")
|
@GetMapping("/un-relate/{id}")
|
||||||
@Operation(description = "缺陷管理-关联用例-取消关联用例")
|
@Operation(description = "缺陷管理-关联用例-取消关联用例")
|
||||||
@RequiresPermissions(PermissionConstants.BUG_UPDATE)
|
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
|
||||||
public void unRelate(@PathVariable String id) {
|
public void unRelate(@PathVariable String id) {
|
||||||
bugRelateCaseService.unRelate(id);
|
bugRelateCaseService.unRelate(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package io.metersphere.bug;
|
package io.metersphere.bug.job;
|
||||||
|
|
||||||
import io.metersphere.bug.service.BugSyncService;
|
import io.metersphere.bug.service.BugSyncService;
|
||||||
import io.metersphere.bug.service.XpackBugService;
|
import io.metersphere.bug.service.XpackBugService;
|
||||||
|
@ -29,15 +29,21 @@ public class BugSyncJob extends BaseScheduleJob {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void businessExecute(JobExecutionContext context) {
|
protected void businessExecute(JobExecutionContext context) {
|
||||||
LicenseDTO licenseDTO = licenseService.validate();
|
LogUtils.info("bug sync job start......");
|
||||||
if (licenseDTO != null && licenseDTO.getLicense() != null
|
if (licenseService == null) {
|
||||||
&& StringUtils.equals(licenseDTO.getStatus(), "valid")) {
|
LogUtils.info("license is null, sync remain bug");
|
||||||
LogUtils.info("sync all bug");
|
|
||||||
xpackBugService.syncPlatformBugsBySchedule();
|
|
||||||
} else {
|
|
||||||
LogUtils.info("sync remain bug");
|
|
||||||
bugSyncService.syncPlatformBugBySchedule();
|
bugSyncService.syncPlatformBugBySchedule();
|
||||||
|
} else {
|
||||||
|
LicenseDTO licenseDTO = licenseService.validate();
|
||||||
|
if (licenseDTO != null && licenseDTO.getLicense() != null
|
||||||
|
&& StringUtils.equals(licenseDTO.getStatus(), "valid")) {
|
||||||
|
LogUtils.info("license is valid, sync all bug");
|
||||||
|
xpackBugService.syncPlatformBugsBySchedule();
|
||||||
|
} else {
|
||||||
|
LogUtils.info("license is invalid, sync remain bug");
|
||||||
|
bugSyncService.syncPlatformBugBySchedule();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LogUtils.info("sync bug end");
|
LogUtils.info("bug sync job end......");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,7 +11,6 @@ import io.metersphere.bug.dto.response.BugTagEditDTO;
|
||||||
import io.metersphere.bug.enums.BugPlatform;
|
import io.metersphere.bug.enums.BugPlatform;
|
||||||
import io.metersphere.bug.enums.BugTemplateCustomField;
|
import io.metersphere.bug.enums.BugTemplateCustomField;
|
||||||
import io.metersphere.bug.mapper.*;
|
import io.metersphere.bug.mapper.*;
|
||||||
import io.metersphere.bug.utils.CustomFieldUtils;
|
|
||||||
import io.metersphere.bug.utils.ExportUtils;
|
import io.metersphere.bug.utils.ExportUtils;
|
||||||
import io.metersphere.plugin.platform.dto.SelectOption;
|
import io.metersphere.plugin.platform.dto.SelectOption;
|
||||||
import io.metersphere.plugin.platform.dto.SyncBugResult;
|
import io.metersphere.plugin.platform.dto.SyncBugResult;
|
||||||
|
@ -43,12 +42,10 @@ import io.metersphere.system.dto.sdk.TemplateDTO;
|
||||||
import io.metersphere.system.log.constants.OperationLogModule;
|
import io.metersphere.system.log.constants.OperationLogModule;
|
||||||
import io.metersphere.system.mapper.BaseUserMapper;
|
import io.metersphere.system.mapper.BaseUserMapper;
|
||||||
import io.metersphere.system.mapper.TemplateMapper;
|
import io.metersphere.system.mapper.TemplateMapper;
|
||||||
import io.metersphere.system.service.BaseTemplateCustomFieldService;
|
import io.metersphere.system.service.*;
|
||||||
import io.metersphere.system.service.BaseTemplateService;
|
|
||||||
import io.metersphere.system.service.PlatformPluginService;
|
|
||||||
import io.metersphere.system.service.PluginLoadService;
|
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import io.metersphere.system.uid.NumGenerator;
|
import io.metersphere.system.uid.NumGenerator;
|
||||||
|
import io.metersphere.system.utils.CustomFieldUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jodd.util.StringUtil;
|
import jodd.util.StringUtil;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
@ -102,6 +99,8 @@ public class BugService {
|
||||||
@Resource
|
@Resource
|
||||||
private PlatformPluginService platformPluginService;
|
private PlatformPluginService platformPluginService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private UserPlatformAccountService userPlatformAccountService;
|
||||||
|
@Resource
|
||||||
private BugCustomFieldMapper bugCustomFieldMapper;
|
private BugCustomFieldMapper bugCustomFieldMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ExtBugCustomFieldMapper extBugCustomFieldMapper;
|
private ExtBugCustomFieldMapper extBugCustomFieldMapper;
|
||||||
|
@ -146,8 +145,8 @@ public class BugService {
|
||||||
* @param request 列表请求参数
|
* @param request 列表请求参数
|
||||||
* @return 缺陷列表
|
* @return 缺陷列表
|
||||||
*/
|
*/
|
||||||
public List<BugDTO> list(BugPageRequest request) {
|
public List<BugDTO> list(BugPageRequest request, String currentUser) {
|
||||||
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(request);
|
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(request, currentUser);
|
||||||
List<BugDTO> bugs = extBugMapper.list(request);
|
List<BugDTO> bugs = extBugMapper.list(request);
|
||||||
if (CollectionUtils.isEmpty(bugs)) {
|
if (CollectionUtils.isEmpty(bugs)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
@ -164,7 +163,7 @@ public class BugService {
|
||||||
* @param files 附件集合
|
* @param files 附件集合
|
||||||
* @param currentUser 当前用户
|
* @param currentUser 当前用户
|
||||||
*/
|
*/
|
||||||
public void addOrUpdate(BugEditRequest request, List<MultipartFile> files, String currentUser, boolean isUpdate) {
|
public void addOrUpdate(BugEditRequest request, List<MultipartFile> files, String currentUser, String currentOrgId, boolean isUpdate) {
|
||||||
/*
|
/*
|
||||||
* 缺陷创建或者修改逻辑:
|
* 缺陷创建或者修改逻辑:
|
||||||
* 1. 判断所属项目是否关联第三方平台;
|
* 1. 判断所属项目是否关联第三方平台;
|
||||||
|
@ -186,7 +185,7 @@ public class BugService {
|
||||||
Platform platform = platformPluginService.getPlatform(serviceIntegration.getPluginId(), serviceIntegration.getOrganizationId(),
|
Platform platform = platformPluginService.getPlatform(serviceIntegration.getPluginId(), serviceIntegration.getOrganizationId(),
|
||||||
new String(serviceIntegration.getConfiguration()));
|
new String(serviceIntegration.getConfiguration()));
|
||||||
PlatformBugUpdateRequest platformRequest = buildPlatformBugRequest(request);
|
PlatformBugUpdateRequest platformRequest = buildPlatformBugRequest(request);
|
||||||
platformRequest.setUserPlatformConfig(new String(serviceIntegration.getConfiguration()));
|
platformRequest.setUserPlatformConfig(JSON.toJSONString(userPlatformAccountService.get(currentUser, currentOrgId)));
|
||||||
platformRequest.setProjectConfig(projectApplicationService.getProjectBugThirdPartConfig(request.getProjectId()));
|
platformRequest.setProjectConfig(projectApplicationService.getProjectBugThirdPartConfig(request.getProjectId()));
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
Bug bug = bugMapper.selectByPrimaryKey(request.getId());
|
Bug bug = bugMapper.selectByPrimaryKey(request.getId());
|
||||||
|
@ -261,8 +260,8 @@ public class BugService {
|
||||||
* 批量删除缺陷
|
* 批量删除缺陷
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
public void batchDelete(BugBatchRequest request) {
|
public void batchDelete(BugBatchRequest request, String currentUser) {
|
||||||
List<String> batchIds = getBatchIdsByRequest(request);
|
List<String> batchIds = getBatchIdsByRequest(request, currentUser);
|
||||||
batchIds.forEach(this::delete);
|
batchIds.forEach(this::delete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,8 +269,8 @@ public class BugService {
|
||||||
* 批量编辑缺陷
|
* 批量编辑缺陷
|
||||||
* @param request 请求参数
|
* @param request 请求参数
|
||||||
*/
|
*/
|
||||||
public void batchUpdate(BugBatchUpdateRequest request) {
|
public void batchUpdate(BugBatchUpdateRequest request, String currentUser) {
|
||||||
List<String> batchIds = getBatchIdsByRequest(request);
|
List<String> batchIds = getBatchIdsByRequest(request, currentUser);
|
||||||
|
|
||||||
// 目前只做标签的批量编辑
|
// 目前只做标签的批量编辑
|
||||||
if (request.isAppend()) {
|
if (request.isAppend()) {
|
||||||
|
@ -1081,8 +1080,8 @@ public class BugService {
|
||||||
* @return 导出对象
|
* @return 导出对象
|
||||||
* @throws Exception 异常
|
* @throws Exception 异常
|
||||||
*/
|
*/
|
||||||
public ResponseEntity<byte[]> export(BugExportRequest request) throws Exception {
|
public ResponseEntity<byte[]> export(BugExportRequest request, String currentUser) throws Exception {
|
||||||
List<BugDTO> bugs = this.getExportDataByBatchRequest(request);
|
List<BugDTO> bugs = this.getExportDataByBatchRequest(request, currentUser);
|
||||||
if (CollectionUtils.isEmpty(bugs)) {
|
if (CollectionUtils.isEmpty(bugs)) {
|
||||||
throw new MSException(Translator.get("no_bug_select"));
|
throw new MSException(Translator.get("no_bug_select"));
|
||||||
}
|
}
|
||||||
|
@ -1110,13 +1109,13 @@ public class BugService {
|
||||||
* @param request 批量操作参数
|
* @param request 批量操作参数
|
||||||
* @return 缺陷集合
|
* @return 缺陷集合
|
||||||
*/
|
*/
|
||||||
private List<BugDTO> getExportDataByBatchRequest(BugBatchRequest request) {
|
private List<BugDTO> getExportDataByBatchRequest(BugBatchRequest request, String currentUser) {
|
||||||
if (request.isSelectAll()) {
|
if (request.isSelectAll()) {
|
||||||
// 全选{根据查询条件查询所有数据, 排除取消勾选的数据}
|
// 全选{根据查询条件查询所有数据, 排除取消勾选的数据}
|
||||||
BugPageRequest bugPageRequest = new BugPageRequest();
|
BugPageRequest bugPageRequest = new BugPageRequest();
|
||||||
BeanUtils.copyBean(bugPageRequest, request);
|
BeanUtils.copyBean(bugPageRequest, request);
|
||||||
bugPageRequest.setUseTrash(false);
|
bugPageRequest.setUseTrash(false);
|
||||||
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(bugPageRequest);
|
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(bugPageRequest, currentUser);
|
||||||
List<BugDTO> allBugs = extBugMapper.list(bugPageRequest);
|
List<BugDTO> allBugs = extBugMapper.list(bugPageRequest);
|
||||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||||
allBugs.removeIf(bug -> request.getExcludeIds().contains(bug.getId()));
|
allBugs.removeIf(bug -> request.getExcludeIds().contains(bug.getId()));
|
||||||
|
@ -1136,13 +1135,13 @@ public class BugService {
|
||||||
* @param request 批量操作参数
|
* @param request 批量操作参数
|
||||||
* @return 缺陷集合
|
* @return 缺陷集合
|
||||||
*/
|
*/
|
||||||
private List<String> getBatchIdsByRequest(BugBatchRequest request) {
|
private List<String> getBatchIdsByRequest(BugBatchRequest request, String currentUser) {
|
||||||
if (request.isSelectAll()) {
|
if (request.isSelectAll()) {
|
||||||
// 全选{根据查询条件查询所有数据, 排除取消勾选的数据}
|
// 全选{根据查询条件查询所有数据, 排除取消勾选的数据}
|
||||||
BugPageRequest bugPageRequest = new BugPageRequest();
|
BugPageRequest bugPageRequest = new BugPageRequest();
|
||||||
BeanUtils.copyBean(bugPageRequest, request);
|
BeanUtils.copyBean(bugPageRequest, request);
|
||||||
bugPageRequest.setUseTrash(false);
|
bugPageRequest.setUseTrash(false);
|
||||||
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(bugPageRequest);
|
CustomFieldUtils.setBaseQueryRequestCustomMultipleFields(bugPageRequest, currentUser);
|
||||||
List<String> ids = extBugMapper.getIdsByPageRequest(bugPageRequest);
|
List<String> ids = extBugMapper.getIdsByPageRequest(bugPageRequest);
|
||||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||||
ids.removeIf(id -> request.getExcludeIds().contains(id));
|
ids.removeIf(id -> request.getExcludeIds().contains(id));
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
package io.metersphere.bug.utils;
|
|
||||||
|
|
||||||
import io.metersphere.sdk.constants.CustomFieldType;
|
|
||||||
import io.metersphere.sdk.util.JSON;
|
|
||||||
import io.metersphere.system.dto.sdk.BasePageRequest;
|
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 字段处理工具类
|
|
||||||
* @author song-cc-rock
|
|
||||||
*/
|
|
||||||
@UtilityClass
|
|
||||||
public class CustomFieldUtils {
|
|
||||||
|
|
||||||
public static final String COMBINE_CUSTOM = "customs";
|
|
||||||
public static final String COMBINE_CUSTOM_FIELD_TYPE = "type";
|
|
||||||
public static final String COMBINE_CUSTOM_FIELD_VALUE = "value";
|
|
||||||
public static final String COMBINE_CUSTOM_FIELD_OPERATOR = "operator";
|
|
||||||
public static final String IS_CURRENT_USER = "current user";
|
|
||||||
public static final String CUSTOM_MULTIPLE_PREFIX = "custom_multiple";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置列表查询的多选字段参数
|
|
||||||
* @param request 请求参数
|
|
||||||
*/
|
|
||||||
public static void setBaseQueryRequestCustomMultipleFields(BasePageRequest request) {
|
|
||||||
// handle filter custom multiple fields
|
|
||||||
if (MapUtils.isNotEmpty(request.getFilter())) {
|
|
||||||
request.getFilter().entrySet().forEach(entry -> {
|
|
||||||
if (entry.getKey().startsWith(CUSTOM_MULTIPLE_PREFIX) && CollectionUtils.isNotEmpty(entry.getValue())) {
|
|
||||||
List<String> jsonValues = entry.getValue().stream().map(item -> "[\"".concat(item).concat("\"]")).collect(Collectors.toList());
|
|
||||||
entry.setValue(jsonValues);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle combine fields
|
|
||||||
if (MapUtils.isNotEmpty(request.getCombine())) {
|
|
||||||
Map<String, Object> combine = request.getCombine();
|
|
||||||
combine.forEach((k, v) -> {
|
|
||||||
if (StringUtils.equals(k, COMBINE_CUSTOM)) {
|
|
||||||
// handle combine custom multiple fields
|
|
||||||
if (ObjectUtils.isNotEmpty((v))) {
|
|
||||||
//noinspection unchecked
|
|
||||||
List<Map<String, Object>> customs = (List<Map<String, Object>>) v;
|
|
||||||
for (Map<String, Object> custom : customs) {
|
|
||||||
// when member select or member multipart select support current user, open it
|
|
||||||
if(StringUtils.equalsIgnoreCase(custom.get(COMBINE_CUSTOM_FIELD_OPERATOR).toString(), IS_CURRENT_USER)){
|
|
||||||
custom.put(COMBINE_CUSTOM_FIELD_VALUE, SessionUtils.getUserId());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (StringUtils.equalsAny(custom.get(COMBINE_CUSTOM_FIELD_TYPE).toString(), CustomFieldType.MULTIPLE_MEMBER.getType(),
|
|
||||||
CustomFieldType.CHECKBOX.getType(), CustomFieldType.MULTIPLE_SELECT.getType())
|
|
||||||
&& StringUtils.isNotEmpty(custom.get(COMBINE_CUSTOM_FIELD_VALUE).toString())) {
|
|
||||||
List<String> customValues = JSON.parseArray(custom.get(COMBINE_CUSTOM_FIELD_VALUE).toString(), String.class);
|
|
||||||
List<String> jsonValues = customValues.stream().map(item -> "JSON_CONTAINS(`value`, '[\"".concat(item).concat("\"]')")).toList();
|
|
||||||
custom.put(COMBINE_CUSTOM_FIELD_VALUE, "(".concat(StringUtils.join(jsonValues, " OR ")).concat(")"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//noinspection unchecked
|
|
||||||
Map<String, Object> combineField = (Map<String, Object>) v;
|
|
||||||
if (StringUtils.equalsIgnoreCase(combineField.get(COMBINE_CUSTOM_FIELD_OPERATOR).toString(), IS_CURRENT_USER)) {
|
|
||||||
// handle combine current user
|
|
||||||
combineField.put(COMBINE_CUSTOM_FIELD_VALUE, SessionUtils.getUserId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 多选字段追加值
|
|
||||||
* @param originalVal 原始值
|
|
||||||
* @param appendVal 追加值
|
|
||||||
* @return 追加后的值
|
|
||||||
*/
|
|
||||||
public static String appendToMultipleCustomField(String originalVal, String appendVal) {
|
|
||||||
if (StringUtils.isEmpty(originalVal)) {
|
|
||||||
return appendVal;
|
|
||||||
}
|
|
||||||
List<String> orignalList = JSON.parseArray(originalVal, String.class);
|
|
||||||
List<String> appendList = JSON.parseArray(appendVal, String.class);
|
|
||||||
orignalList.addAll(appendList);
|
|
||||||
// 追加后需去重
|
|
||||||
return JSON.toJSONString(orignalList.stream().distinct().toList());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -13,7 +13,6 @@ import io.metersphere.bug.mapper.BugMapper;
|
||||||
import io.metersphere.bug.service.BugService;
|
import io.metersphere.bug.service.BugService;
|
||||||
import io.metersphere.bug.service.BugSyncExtraService;
|
import io.metersphere.bug.service.BugSyncExtraService;
|
||||||
import io.metersphere.bug.service.BugSyncService;
|
import io.metersphere.bug.service.BugSyncService;
|
||||||
import io.metersphere.bug.utils.CustomFieldUtils;
|
|
||||||
import io.metersphere.plugin.platform.dto.request.SyncAllBugRequest;
|
import io.metersphere.plugin.platform.dto.request.SyncAllBugRequest;
|
||||||
import io.metersphere.project.domain.*;
|
import io.metersphere.project.domain.*;
|
||||||
import io.metersphere.project.dto.ProjectTemplateOptionDTO;
|
import io.metersphere.project.dto.ProjectTemplateOptionDTO;
|
||||||
|
@ -38,6 +37,7 @@ import io.metersphere.system.mapper.CustomFieldMapper;
|
||||||
import io.metersphere.system.mapper.ServiceIntegrationMapper;
|
import io.metersphere.system.mapper.ServiceIntegrationMapper;
|
||||||
import io.metersphere.system.service.PluginService;
|
import io.metersphere.system.service.PluginService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
|
import io.metersphere.system.utils.CustomFieldUtils;
|
||||||
import io.metersphere.system.utils.Pager;
|
import io.metersphere.system.utils.Pager;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -215,9 +215,6 @@ public class BugControllerTests extends BaseTest {
|
||||||
combine.put("customs", customs);
|
combine.put("customs", customs);
|
||||||
bugPageRequest.setCombine(combine);
|
bugPageRequest.setCombine(combine);
|
||||||
this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest);
|
this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest);
|
||||||
combine.put("customs", null);
|
|
||||||
bugPageRequest.setCombine(combine);
|
|
||||||
this.requestPostWithOkAndReturn(BUG_PAGE, bugPageRequest);
|
|
||||||
// cover combine current user
|
// cover combine current user
|
||||||
custom.clear();
|
custom.clear();
|
||||||
custom.put("operator", "current user");
|
custom.put("operator", "current user");
|
||||||
|
@ -408,7 +405,7 @@ public class BugControllerTests extends BaseTest {
|
||||||
void testExportColumns() throws Exception {
|
void testExportColumns() throws Exception {
|
||||||
this.requestGetWithOkAndReturn(String.format(BUG_EXPORT_COLUMNS, "default-project-for-bug"));
|
this.requestGetWithOkAndReturn(String.format(BUG_EXPORT_COLUMNS, "default-project-for-bug"));
|
||||||
//校验权限
|
//校验权限
|
||||||
this.requestGetPermissionTest(PermissionConstants.BUG_EXPORT, String.format(BUG_EXPORT_COLUMNS, DEFAULT_PROJECT_ID));
|
this.requestGetPermissionTest(PermissionConstants.PROJECT_BUG_EXPORT, String.format(BUG_EXPORT_COLUMNS, DEFAULT_PROJECT_ID));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -463,7 +460,7 @@ public class BugControllerTests extends BaseTest {
|
||||||
request.setProjectId(DEFAULT_PROJECT_ID);
|
request.setProjectId(DEFAULT_PROJECT_ID);
|
||||||
request.setSelectAll(true);
|
request.setSelectAll(true);
|
||||||
request.setExportColumns(exportColumns);
|
request.setExportColumns(exportColumns);
|
||||||
this.requestPostPermissionTest(PermissionConstants.BUG_EXPORT, BUG_EXPORT, request);
|
this.requestPostPermissionTest(PermissionConstants.PROJECT_BUG_EXPORT, BUG_EXPORT, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -659,7 +656,7 @@ public class BugControllerTests extends BaseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(98)
|
@Order(98)
|
||||||
void coverBugTests() {
|
void coverBugTests() throws Exception {
|
||||||
BugCustomFieldDTO field = new BugCustomFieldDTO();
|
BugCustomFieldDTO field = new BugCustomFieldDTO();
|
||||||
field.setId("test_field");
|
field.setId("test_field");
|
||||||
field.setName("test");
|
field.setName("test");
|
||||||
|
@ -670,6 +667,11 @@ public class BugControllerTests extends BaseTest {
|
||||||
removeApiFieldTmp();
|
removeApiFieldTmp();
|
||||||
bugService.transferCustomToPlatformField("default-bug-template-id-not-exist", List.of(field), false);
|
bugService.transferCustomToPlatformField("default-bug-template-id-not-exist", List.of(field), false);
|
||||||
rollBackApiField();
|
rollBackApiField();
|
||||||
|
// 覆盖导出相关的代码
|
||||||
|
BugExportRequest request = new BugExportRequest();
|
||||||
|
request.setSelectAll(true);
|
||||||
|
request.setExcludeIds(List.of("test-id"));
|
||||||
|
bugService.export(request, "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
||||||
|
package io.metersphere.system.config.interceptor;
|
||||||
|
|
||||||
|
import io.metersphere.bug.domain.BugContent;
|
||||||
|
import io.metersphere.bug.domain.BugHistory;
|
||||||
|
import io.metersphere.sdk.util.CompressUtils;
|
||||||
|
import io.metersphere.system.utils.MybatisInterceptorConfig;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class BugInterceptor {
|
||||||
|
@Bean
|
||||||
|
public List<MybatisInterceptorConfig> bugCompressConfigs() {
|
||||||
|
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
||||||
|
configList.add(new MybatisInterceptorConfig(BugContent.class, "description", CompressUtils.class, "zip", "unzip"));
|
||||||
|
configList.add(new MybatisInterceptorConfig(BugHistory.class, "content", CompressUtils.class, "zip", "unzip"));
|
||||||
|
return configList;
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,11 +46,10 @@ public class UserPlatformAccountController {
|
||||||
userPlatformAccountService.save(platformInfo, SessionUtils.getUserId());
|
userPlatformAccountService.save(platformInfo, SessionUtils.getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get")
|
@GetMapping("/get/{orgId}")
|
||||||
|
@Parameter(name = "orgId", description = "组织ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||||
@Operation(summary = "系统设置-个人中心-获取个人三方平台账号")
|
@Operation(summary = "系统设置-个人中心-获取个人三方平台账号")
|
||||||
public Map<String, Object> get() {
|
public Map<String, Object> get(@PathVariable String orgId) {
|
||||||
return userPlatformAccountService.get(SessionUtils.getUserId());
|
return userPlatformAccountService.get(SessionUtils.getUserId(), orgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import io.metersphere.system.log.dto.LogDTO;
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.UserExtendMapper;
|
import io.metersphere.system.mapper.UserExtendMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -69,7 +70,10 @@ public class UserPlatformAccountService {
|
||||||
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
||||||
userExtendMapper.insertSelective(userExtend);
|
userExtendMapper.insertSelective(userExtend);
|
||||||
} else {
|
} else {
|
||||||
userExtend.setPlatformInfo(JSON.toJSONBytes(platformInfo));
|
// noinspection unchecked
|
||||||
|
Map<String, Object> originalUserPlatformInfo = JSON.parseMap(new String(userExtend.getPlatformInfo()));
|
||||||
|
originalUserPlatformInfo.putAll(platformInfo);
|
||||||
|
userExtend.setPlatformInfo(JSON.toJSONBytes(originalUserPlatformInfo));
|
||||||
userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
userExtendMapper.updateByPrimaryKeySelective(userExtend);
|
||||||
}
|
}
|
||||||
LogDTO dto = LogDTOBuilder.builder()
|
LogDTO dto = LogDTOBuilder.builder()
|
||||||
|
@ -85,11 +89,21 @@ public class UserPlatformAccountService {
|
||||||
operationLogService.add(dto);
|
operationLogService.add(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> get(String userId) {
|
/**
|
||||||
|
* 获取个人三方平台账号
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param orgId 组织ID
|
||||||
|
* @return 三方平台账号
|
||||||
|
*/
|
||||||
|
public Map<String, Object> get(String userId, String orgId) {
|
||||||
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(userId);
|
UserExtend userExtend = userExtendMapper.selectByPrimaryKey(userId);
|
||||||
if (userExtend == null || userExtend.getPlatformInfo() == null) {
|
if (userExtend == null || StringUtils.isBlank(new String(userExtend.getPlatformInfo()))) {
|
||||||
return new HashMap<>();
|
return null;
|
||||||
}
|
}
|
||||||
return JSON.parseMap(new String(userExtend.getPlatformInfo()));
|
// noinspection unchecked
|
||||||
|
Map<String, Object> userPlatformInfo = JSON.parseMap(new String(userExtend.getPlatformInfo()));
|
||||||
|
// 获取组织用户集成信息
|
||||||
|
// noinspection unchecked
|
||||||
|
return (Map<String, Object>) userPlatformInfo.get(orgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import io.metersphere.system.base.BasePluginTestService;
|
||||||
import io.metersphere.system.base.BaseTest;
|
import io.metersphere.system.base.BaseTest;
|
||||||
import io.metersphere.system.controller.handler.ResultHolder;
|
import io.metersphere.system.controller.handler.ResultHolder;
|
||||||
import io.metersphere.system.domain.Plugin;
|
import io.metersphere.system.domain.Plugin;
|
||||||
|
import io.metersphere.system.domain.UserExtendExample;
|
||||||
|
import io.metersphere.system.mapper.UserExtendMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
import org.mockserver.client.MockServerClient;
|
import org.mockserver.client.MockServerClient;
|
||||||
|
@ -34,6 +36,8 @@ public class UserPlatformAccountControllerTests extends BaseTest {
|
||||||
private int mockServerHostPort;
|
private int mockServerHostPort;
|
||||||
@Resource
|
@Resource
|
||||||
private MockServerClient mockServerClient;
|
private MockServerClient mockServerClient;
|
||||||
|
@Resource
|
||||||
|
private UserExtendMapper userExtendMapper;
|
||||||
private static final String VALIDATE_POST = "/user/platform/validate/{0}/{1}";
|
private static final String VALIDATE_POST = "/user/platform/validate/{0}/{1}";
|
||||||
private static final String SAVE_POST = "/user/platform/save";
|
private static final String SAVE_POST = "/user/platform/save";
|
||||||
public static <T> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
public static <T> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
||||||
|
@ -84,27 +88,38 @@ public class UserPlatformAccountControllerTests extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
public void testSave() throws Exception {
|
public void testSave() throws Exception {
|
||||||
this.requestGetAndReturn("/user/platform/get");
|
// 未保存用户配置信息, 为空
|
||||||
basePluginTestService.getJiraPlugin();
|
MvcResult mvcResult = this.requestGetAndReturn("/user/platform/get/100001");
|
||||||
BasePluginTestService.JiraIntegrationConfig integrationConfig = new BasePluginTestService.JiraIntegrationConfig();
|
// noinspection unchecked
|
||||||
integrationConfig.setAddress(String.format("http://%s:%s", mockServerHost, mockServerHostPort));
|
Map<String, Object> accountMap = parseObjectFromMvcResult(mvcResult, Map.class);
|
||||||
Map<String, Object> jiraMap = new HashMap<>();
|
Assertions.assertNull(accountMap);
|
||||||
jiraMap.put("jira", integrationConfig);
|
// @@请求成功 保存两次
|
||||||
// @@请求成功
|
this.requestPostWithOk(SAVE_POST, buildUserPlatformConfig());
|
||||||
this.requestPostWithOk(SAVE_POST, jiraMap);
|
this.requestPostWithOk(SAVE_POST, buildUserPlatformConfig());
|
||||||
this.requestPostWithOk(SAVE_POST, jiraMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(4)
|
@Order(4)
|
||||||
public void testGet() throws Exception {
|
public void testGet() throws Exception {
|
||||||
MvcResult mvcResult = this.requestGetAndReturn("/user/platform/get");
|
MvcResult mvcResult = this.requestGetAndReturn("/user/platform/get/100001");
|
||||||
|
// noinspection unchecked
|
||||||
Map<String, Object> accountMap = parseObjectFromMvcResult(mvcResult, Map.class);
|
Map<String, Object> accountMap = parseObjectFromMvcResult(mvcResult, Map.class);
|
||||||
Assertions.assertNotNull(accountMap);
|
Assertions.assertNotNull(accountMap);
|
||||||
|
// 删除用户配置信息, 避免影响后续测试
|
||||||
|
UserExtendExample example = new UserExtendExample();
|
||||||
|
example.createCriteria().andIdEqualTo("admin");
|
||||||
|
userExtendMapper.deleteByExample(example);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> buildUserPlatformConfig() {
|
||||||
|
Map<String, Object> platformInfo = new HashMap<>();
|
||||||
|
Map<String, Object> userPlatformConfig = new HashMap<>();
|
||||||
|
userPlatformConfig.put("authType", "test");
|
||||||
|
userPlatformConfig.put("jiraAccount", "test");
|
||||||
|
userPlatformConfig.put("jiraPassword", "test");
|
||||||
|
userPlatformConfig.put("zentaoAccount", "test");
|
||||||
|
userPlatformConfig.put("zentaoPassword", "test");
|
||||||
|
platformInfo.put("100001", userPlatformConfig);
|
||||||
|
return platformInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue