mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
fix(项目设置): 补充公共脚本变更历史接口
This commit is contained in:
parent
2dfbf36da7
commit
e067d7db1e
@ -756,6 +756,9 @@ public class BugService {
|
||||
}).toList();
|
||||
statusField.setOptions(statusCustomOption);
|
||||
statusField.setRequired(true);
|
||||
if (CollectionUtils.isEmpty(templateDTO.getCustomFields())) {
|
||||
templateDTO.setCustomFields(new ArrayList<>());
|
||||
}
|
||||
templateDTO.getCustomFields().addFirst(statusField);
|
||||
return templateDTO;
|
||||
}
|
||||
@ -1570,7 +1573,7 @@ public class BugService {
|
||||
});
|
||||
// 第三方平台模板
|
||||
TemplateDTO pluginDefaultTemplate = getPluginBugDefaultTemplate(projectId, true);
|
||||
if (pluginDefaultTemplate != null) {
|
||||
if (pluginDefaultTemplate != null && CollectionUtils.isNotEmpty(pluginDefaultTemplate.getCustomFields())) {
|
||||
headerCustomFields.addAll(pluginDefaultTemplate.getCustomFields());
|
||||
}
|
||||
return headerCustomFields;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.metersphere.project.controller;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.page.PageMethod;
|
||||
import io.metersphere.project.domain.CustomFunction;
|
||||
import io.metersphere.project.dto.customfunction.CustomFuncColumnsOptionDTO;
|
||||
@ -11,6 +12,8 @@ import io.metersphere.project.dto.customfunction.request.CustomFunctionUpdateReq
|
||||
import io.metersphere.project.service.CustomFunctionLogService;
|
||||
import io.metersphere.project.service.CustomFunctionService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
@ -93,11 +96,21 @@ public class CustomFunctionController {
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@Operation(summary = "项目管理-公共脚本-脚本删除")
|
||||
@Operation(summary = "项目管理-脚本删除")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_CUSTOM_FUNCTION_DELETE)
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.delLog(#id)", msClass = CustomFunctionLogService.class)
|
||||
@CheckOwner(resourceId = "#id", resourceType = "custom_function")
|
||||
public void delete(@PathVariable String id) {
|
||||
customFunctionService.delete(id);
|
||||
}
|
||||
|
||||
@PostMapping("/history/page")
|
||||
@Operation(summary = "项目管理-公共脚本-变更历史-列表")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_CUSTOM_FUNCTION_READ)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public Pager<List<OperationHistoryDTO>> page(@Validated @RequestBody OperationHistoryRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "id desc");
|
||||
return PageUtils.setPageInfo(page, customFunctionService.list(request));
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,30 @@ import io.metersphere.project.mapper.ExtCustomFunctionMapper;
|
||||
import io.metersphere.project.request.ProjectMemberRequest;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
import io.metersphere.system.domain.OperationHistory;
|
||||
import io.metersphere.system.domain.OperationHistoryExample;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.domain.UserExample;
|
||||
import io.metersphere.system.dto.OperationHistoryDTO;
|
||||
import io.metersphere.system.dto.request.OperationHistoryRequest;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.mapper.OperationHistoryMapper;
|
||||
import io.metersphere.system.mapper.UserMapper;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.utils.ServiceUtils;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author: LAN
|
||||
@ -51,6 +65,12 @@ public class CustomFunctionService {
|
||||
@Resource
|
||||
ExtCustomFunctionMapper extCustomFunctionMapper;
|
||||
|
||||
@Resource
|
||||
UserMapper userMapper;
|
||||
|
||||
@Resource
|
||||
OperationHistoryMapper operationHistoryMapper;
|
||||
|
||||
public List<CustomFunctionDTO> getPage(CustomFunctionPageRequest request) {
|
||||
List<CustomFunctionDTO> list = extCustomFunctionMapper.list(request);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
@ -147,6 +167,39 @@ public class CustomFunctionService {
|
||||
customFunctionBlobMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共脚本变更历史分页列表
|
||||
* @param request 请求参数
|
||||
* @return 变更历史集合
|
||||
*/
|
||||
public List<OperationHistoryDTO> list(OperationHistoryRequest request) {
|
||||
OperationHistoryExample example = new OperationHistoryExample();
|
||||
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andModuleIn(List.of(OperationLogModule.PROJECT_CUSTOM_FUNCTION))
|
||||
.andSourceIdEqualTo(request.getSourceId());
|
||||
List<OperationHistory> history = operationHistoryMapper.selectByExample(example);
|
||||
if (org.apache.commons.collections4.CollectionUtils.isEmpty(history)) {
|
||||
return List.of();
|
||||
}
|
||||
List<String> userIds = history.stream().map(OperationHistory::getCreateUser).toList();
|
||||
UserExample userExample = new UserExample();
|
||||
userExample.createCriteria().andIdIn(userIds);
|
||||
List<User> users = userMapper.selectByExample(userExample);
|
||||
Map<String, String> userMap = users.stream().collect(Collectors.toMap(User::getId, User::getName));
|
||||
return history.stream().map(h -> {
|
||||
OperationHistoryDTO dto = new OperationHistoryDTO();
|
||||
BeanUtils.copyBean(dto, h);
|
||||
dto.setCreateUserName(userMap.get(h.getCreateUser()) == null ? h.getCreateUser() : userMap.get(h.getCreateUser()));
|
||||
if (StringUtils.equals(dto.getType(), OperationLogType.ADD.name())) {
|
||||
dto.setType(Translator.get("add"));
|
||||
} else if (StringUtils.equals(dto.getType(), OperationLogType.UPDATE.name())) {
|
||||
dto.setType(Translator.get("update"));
|
||||
} else if (StringUtils.equals(dto.getType(), OperationLogType.DELETE.name())) {
|
||||
dto.setType(Translator.get("delete"));
|
||||
}
|
||||
return dto;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private CustomFunction checkCustomFunction(String id) {
|
||||
return ServiceUtils.checkResourceExist(customFunctionMapper.selectByPrimaryKey(id), "resource_not_exist");
|
||||
}
|
||||
|
@ -397,6 +397,8 @@
|
||||
onBeforeMount(() => {
|
||||
initData();
|
||||
});
|
||||
|
||||
await tableStore.initColumn(TableKeyEnum.PROJECT_MEMBER, columns, 'drawer');
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
Loading…
Reference in New Issue
Block a user