fix(缺陷管理): 批量操作日志操作人未给值

--bug=1036414 --user=宋昌昌 【缺陷管理】回收站,批量恢复/删除缺陷,日志操作人显示空 https://www.tapd.cn/55049933/s/1476544
This commit is contained in:
song-cc-rock 2024-03-15 19:36:00 +08:00 committed by Craftsman
parent c28967ce00
commit 8fcaf9430e
4 changed files with 18 additions and 12 deletions

View File

@ -68,7 +68,7 @@ public class BugRelateCaseController {
@PostMapping("/relate")
@Operation(summary = "缺陷管理-关联用例-关联")
@RequiresPermissions(PermissionConstants.PROJECT_BUG_UPDATE)
@CheckOwner(resourceId = "#request.sourceId", resourceType = "functional_case")
@CheckOwner(resourceId = "#request.projectId", resourceType = "project")
public void relate(@Validated @RequestBody AssociateOtherCaseRequest request) {
bugRelateCaseCommonService.relateCase(request, false, SessionUtils.getUserId());
}

View File

@ -13,6 +13,7 @@ import io.metersphere.system.log.constants.OperationLogType;
import io.metersphere.system.security.CheckOwner;
import io.metersphere.system.utils.PageUtils;
import io.metersphere.system.utils.Pager;
import io.metersphere.system.utils.SessionUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
@ -62,7 +63,7 @@ public class BugTrashController {
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
public void batchRecover(@Validated @RequestBody BugBatchRequest request) {
request.setUseTrash(true);
bugService.batchRecover(request);
bugService.batchRecover(request, SessionUtils.getUserId());
}
@PostMapping("/batch-delete")

View File

@ -389,7 +389,7 @@ public class BugService {
List<String> batchIds = getBatchIdsByRequest(request);
batchIds.forEach(id -> delete(id, currentUser));
// 批量日志
List<LogDTO> logs = getBatchLogByRequest(batchIds, OperationLogType.DELETE.name(), "/bug/batch-delete", request.getProjectId(), false, false, null);
List<LogDTO> logs = getBatchLogByRequest(batchIds, OperationLogType.DELETE.name(), "/bug/batch-delete", request.getProjectId(), false, false, null, currentUser);
operationLogService.batchAdd(logs);
}
@ -397,11 +397,11 @@ public class BugService {
* 批量恢复缺陷
* @param request 请求参数
*/
public void batchRecover(BugBatchRequest request) {
public void batchRecover(BugBatchRequest request, String currentUser) {
List<String> batchIds = getBatchIdsByRequest(request);
batchIds.forEach(this::recover);
// 批量日志
List<LogDTO> logs = getBatchLogByRequest(batchIds, OperationLogType.RECOVER.name(), "/bug/batch-recover", request.getProjectId(), false, false, null);
List<LogDTO> logs = getBatchLogByRequest(batchIds, OperationLogType.RECOVER.name(), "/bug/batch-recover", request.getProjectId(), false, false, null, currentUser);
operationLogService.batchAdd(logs);
}
@ -426,7 +426,7 @@ public class BugService {
List<String> batchIds = getBatchIdsByRequest(request);
// 批量日志{修改之前}
List<LogDTO> logs = getBatchLogByRequest(batchIds, OperationLogType.UPDATE.name(), "/bug/batch-update",
request.getProjectId(), true, request.isAppend(), request.getTags());
request.getProjectId(), true, request.isAppend(), request.getTags(), currentUser);
operationLogService.batchAdd(logs);
// 目前只做标签的批量编辑
if (request.isAppend()) {
@ -1515,14 +1515,14 @@ public class BugService {
* @return 日志集合
*/
private List<LogDTO> getBatchLogByRequest(List<String> batchIds, String operationType, String path, String projectId, boolean batchUpdate,
boolean appendTag, List<String> modifiedTags) {
boolean appendTag, List<String> modifiedTags, String currentUser) {
Project project = projectMapper.selectByPrimaryKey(projectId);
BugExample example = new BugExample();
example.createCriteria().andIdIn(batchIds);
List<Bug> bugs = bugMapper.selectByExample(example);
List<LogDTO> logs = new ArrayList<>();
bugs.forEach(bug -> {
LogDTO log = new LogDTO(bug.getProjectId(), project.getOrganizationId(), bug.getId(), null, operationType, OperationLogModule.BUG_MANAGEMENT_INDEX, bug.getTitle());
LogDTO log = new LogDTO(bug.getProjectId(), project.getOrganizationId(), bug.getId(), currentUser, operationType, OperationLogModule.BUG_MANAGEMENT_INDEX, bug.getTitle());
log.setPath(path);
log.setMethod(HttpMethodConstants.POST.name());
if (batchUpdate) {

View File

@ -1,8 +1,10 @@
package io.metersphere.project.service;
import com.alibaba.excel.util.StringUtils;
import io.metersphere.project.domain.Project;
import io.metersphere.project.dto.ProjectUserRoleDTO;
import io.metersphere.project.mapper.ExtProjectUserRoleMapper;
import io.metersphere.project.mapper.ProjectMapper;
import io.metersphere.project.request.ProjectUserRoleMemberEditRequest;
import io.metersphere.project.request.ProjectUserRoleMemberRequest;
import io.metersphere.project.request.ProjectUserRoleRequest;
@ -43,11 +45,13 @@ import static io.metersphere.system.controller.result.SystemResultCode.NO_PROJEC
public class ProjectUserRoleService extends BaseUserRoleService {
@Resource
UserRoleMapper userRoleMapper;
private ProjectMapper projectMapper;
@Resource
UserRoleRelationMapper userRoleRelationMapper;
private UserRoleMapper userRoleMapper;
@Resource
ExtProjectUserRoleMapper extProjectUserRoleMapper;
private UserRoleRelationMapper userRoleRelationMapper;
@Resource
private ExtProjectUserRoleMapper extProjectUserRoleMapper;
public List<ProjectUserRoleDTO> list(ProjectUserRoleRequest request) {
List<ProjectUserRoleDTO> roles = extProjectUserRoleMapper.list(request);
@ -106,6 +110,7 @@ public class ProjectUserRoleService extends BaseUserRoleService {
}
public void addMember(ProjectUserRoleMemberEditRequest request, String createUserId) {
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
request.getUserIds().forEach(userId -> {
checkMemberParam(userId, request.getUserRoleId());
UserRoleRelation relation = new UserRoleRelation();
@ -115,7 +120,7 @@ public class ProjectUserRoleService extends BaseUserRoleService {
relation.setSourceId(request.getProjectId());
relation.setCreateTime(System.currentTimeMillis());
relation.setCreateUser(createUserId);
relation.setOrganizationId(request.getProjectId());
relation.setOrganizationId(project.getOrganizationId());
userRoleRelationMapper.insert(relation);
});
}