refactor(用例评审): 去掉sessionutils在service里的使用
This commit is contained in:
parent
8b54ddab04
commit
74f1958eff
|
@ -4,6 +4,7 @@ import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -12,6 +13,8 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
public class BaseFunctionalCaseBatchDTO extends TableBatchProcessDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "模块id")
|
||||
private List<String> moduleIds;
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.functional.dto;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,6 +11,8 @@ import java.util.List;
|
|||
*/
|
||||
@Data
|
||||
public class CombineDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id;
|
||||
private List<Object> value;
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -11,6 +12,8 @@ import java.io.Serializable;
|
|||
*/
|
||||
@Data
|
||||
public class DemandDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "需求ID")
|
||||
private String demandId;
|
||||
|
|
|
@ -4,6 +4,7 @@ import io.metersphere.system.dto.table.TableBatchProcessDTO;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,6 +14,9 @@ import java.util.List;
|
|||
@Data
|
||||
public class CaseReviewBatchRequest extends TableBatchProcessDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String projectId;
|
||||
|
||||
|
|
|
@ -5,12 +5,16 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CaseReviewPageRequest extends BasePageRequest implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "项目ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{functional_case.project_id.not_blank}")
|
||||
private String projectId;
|
||||
|
|
|
@ -16,7 +16,7 @@ public class CaseReviewRequest implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@Schema(description = "用例评审id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{functional_case.id.not_blank}", groups = {Updated.class})
|
||||
private String id;
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import io.metersphere.functional.mapper.CaseReviewMapper;
|
|||
import io.metersphere.functional.mapper.ExtCaseReviewMapper;
|
||||
import io.metersphere.functional.request.CaseReviewRequest;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -37,7 +36,7 @@ public class CaseReviewNoticeService {
|
|||
caseReview.setReviewPassRule(request.getReviewPassRule());
|
||||
caseReview.setPos(getNextPos(request.getProjectId()));
|
||||
caseReview.setCreateTime(System.currentTimeMillis());
|
||||
caseReview.setCreateUser(SessionUtils.getUserId());
|
||||
caseReview.setCreateUser(null);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(request.getTags())) {
|
||||
caseReview.setTags(JSON.toJSONString(request.getTags()));
|
||||
|
@ -45,7 +44,7 @@ public class CaseReviewNoticeService {
|
|||
caseReview.setStartTime(request.getStartTime());
|
||||
caseReview.setEndTime(request.getEndTime());
|
||||
caseReview.setUpdateTime(System.currentTimeMillis());
|
||||
caseReview.setUpdateUser(SessionUtils.getUserId());
|
||||
caseReview.setUpdateUser(null);
|
||||
return caseReview;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import io.metersphere.system.dto.sdk.OptionDTO;
|
|||
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||
import io.metersphere.system.mapper.ExtOrganizationCustomFieldMapper;
|
||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
|
@ -129,12 +128,11 @@ public class FunctionalCaseNoticeService {
|
|||
}
|
||||
|
||||
public FunctionalCaseDTO getMainFunctionalCaseDTO(String name, String caseEditType, String projectId, Map<String, Object> customFields) {
|
||||
String userId = SessionUtils.getUserId();
|
||||
FunctionalCaseDTO functionalCaseDTO = new FunctionalCaseDTO();
|
||||
functionalCaseDTO.setName(name);
|
||||
functionalCaseDTO.setProjectId(projectId);
|
||||
functionalCaseDTO.setCaseEditType(caseEditType);
|
||||
functionalCaseDTO.setCreateUser(userId);
|
||||
functionalCaseDTO.setCreateUser(null);
|
||||
List<OptionDTO> fields = new ArrayList<>();
|
||||
if (MapUtils.isNotEmpty(customFields)) {
|
||||
customFields.keySet().forEach(key -> {
|
||||
|
@ -179,7 +177,6 @@ public class FunctionalCaseNoticeService {
|
|||
if (CollectionUtils.isNotEmpty(ids)) {
|
||||
Map<String, FunctionalCase> functionalCaseMap = functionalCaseService.copyBaseInfo(projectId, ids);
|
||||
Map<String, List<FunctionalCaseCustomField>> customFieldMap = functionalCaseCustomFieldService.getCustomFieldMapByCaseIds(ids);
|
||||
String userId = SessionUtils.getUserId();
|
||||
AtomicReference<List<OptionDTO>> optionDTOS = new AtomicReference<>(new ArrayList<>());
|
||||
ids.forEach(id -> {
|
||||
FunctionalCase functionalCase = functionalCaseMap.get(id);
|
||||
|
@ -192,7 +189,7 @@ public class FunctionalCaseNoticeService {
|
|||
functionalCaseDTO.setName(functionalCase.getName());
|
||||
functionalCaseDTO.setProjectId(functionalCase.getProjectId());
|
||||
functionalCaseDTO.setCaseEditType(functionalCase.getCaseEditType());
|
||||
functionalCaseDTO.setCreateUser(userId);
|
||||
functionalCaseDTO.setCreateUser(null);
|
||||
functionalCaseDTO.setFields(optionDTOS.get());
|
||||
dtoList.add(functionalCaseDTO);
|
||||
});
|
||||
|
|
|
@ -75,6 +75,10 @@ Insert into message_task(id, event, receiver, project_robot_id, task_type, test_
|
|||
VALUES ('case-review_message0', 'CREATE', 'gyq_review_test', 'test_case_review_message_robot1', 'CASE_REVIEW_TASK', 'NONE', 'project-gyq-case-review-test', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_create');
|
||||
INSERT INTO message_task_blob(id, template) VALUES ('case-review_message0', 'message.case_review_task_create');
|
||||
|
||||
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
|
||||
VALUES ('case-review_message9', 'CREATE', 'CREATE_USER', 'test_case_review_message_robot1', 'CASE_REVIEW_TASK', 'NONE', 'project-gyq-case-review-test', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_create');
|
||||
INSERT INTO message_task_blob(id, template) VALUES ('case-review_message9', 'message.case_review_task_create');
|
||||
|
||||
Insert into message_task(id, event, receiver, project_robot_id, task_type, test_id, project_id, enable, create_user, create_time, update_user, update_time, use_default_template, use_default_subject, subject)
|
||||
VALUES ('case-review_message1', 'UPDATE', 'CREATE_USER', 'test_case_review_message_robot1', 'CASE_REVIEW_TASK', 'NONE', 'project-gyq-case-review-test', true, 'admin', unix_timestamp() * 1000, 'admin', unix_timestamp() * 1000, true, true, 'message.title.case_review_task_update');
|
||||
INSERT INTO message_task_blob(id, template) VALUES ('case-review_message1', 'message.case_review_task_update');
|
||||
|
|
|
@ -110,6 +110,8 @@ public abstract class AbstractNoticeSender implements NoticeSender {
|
|||
String createUser = (String) paramMap.get("createUser");
|
||||
if (StringUtils.isNotBlank(createUser)) {
|
||||
toUsers.add(new Receiver(createUser, NotificationConstants.Type.SYSTEM_NOTICE.name()));
|
||||
} else {
|
||||
toUsers.add(new Receiver((String) paramMap.get(NoticeConstants.RelatedUser.OPERATOR), NotificationConstants.Type.SYSTEM_NOTICE.name()));
|
||||
}
|
||||
}
|
||||
case NoticeConstants.RelatedUser.OPERATOR -> {
|
||||
|
|
Loading…
Reference in New Issue