fix(项目设置): 设置项目默认模板,没有操作日志

--bug=1041261 --user=陈建星 【项目管理】模板管理-默认模板切换为JIRA模版后天提示Error https://www.tapd.cn/55049933/s/1522006
This commit is contained in:
AgAngle 2024-05-28 14:25:50 +08:00 committed by Craftsman
parent 4e8f1c5ae3
commit e331f30881
2 changed files with 8 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.Template;
import io.metersphere.system.log.constants.OperationLogType;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import io.metersphere.system.log.constants.OperationLogModule;
@ -73,8 +74,8 @@ public class ProjectTemplateLogService {
return dto;
}
public LogDTO setDefaultTemplateLog(TemplateUpdateRequest request) {
Template template = projectTemplateService.getWithCheck(request.getId());
public LogDTO setDefaultTemplateLog(String id) {
Template template = projectTemplateService.getWithCheck(id);
LogDTO dto = null;
if (template != null) {
dto = new LogDTO(
@ -82,9 +83,10 @@ public class ProjectTemplateLogService {
null,
template.getId(),
null,
String.join(Translator.get("set_default_template"), ":", OperationLogType.UPDATE.name()),
OperationLogType.UPDATE.name(),
getOperationLogModule(template.getScene()),
template.getName());
StringUtils.join(Translator.get("set_default_template"), ":",
template.getInternal() ? projectTemplateService.translateInternalTemplate() : template.getName()));
dto.setOriginalValue(JSON.toJSONBytes(template));
}
return dto;

View File

@ -40,6 +40,7 @@ import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.jdbc.SqlConfig;
import org.springframework.test.web.servlet.MvcResult;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -383,7 +384,7 @@ public class ProjectTemplateControllerTests extends BaseTest {
Assertions.assertEquals(defaultTemplateDTO.getId(), template.getId());
// @@校验日志
checkLog(addTemplate.getId(), OperationLogType.UPDATE);
checkLog(addTemplate.getId(), OperationLogType.UPDATE, MessageFormat.format(BASE_PATH + SET_DEFAULT, DEFAULT_PROJECT_ID, addTemplate.getId()));
// @@校验权限
requestGetPermissionTest(PermissionConstants.PROJECT_TEMPLATE_UPDATE, SET_DEFAULT, DEFAULT_PROJECT_ID, addTemplate.getId());
}