feat(项目管理): 增加基础信息接口
This commit is contained in:
parent
ebd651ea94
commit
252d203328
backend
framework/sdk/src/main
java/io/metersphere/sdk
resources/i18n
services
project-management/src
main
java/io/metersphere/project
controller
service
resources
test
system-setting/src
main/java/io/metersphere/system
controller
service
test/resources/dml
|
@ -159,6 +159,10 @@ public class PermissionConstants {
|
|||
public static final String PROJECT_APPLICATION_WORKSTATION_UPDATE = "PROJECT_APPLICATION_WORKSTATION:UPDATE";
|
||||
/*------ end: PROJECT_APPLICATION ------*/
|
||||
public static final String PROJECT_BASE_INFO_READ = "PROJECT_BASE_INFO:READ";
|
||||
public static final String PROJECT_BASE_INFO_READ_UPDATE = "PROJECT_BASE_INFO:READ+UPDATE";
|
||||
|
||||
public static final String PROJECT_BASE_INFO_READ_DELETE = "PROJECT_BASE_INFO:READ+DELETE";
|
||||
public static final String PROJECT_BASE_INFO_READ_RECOVER = "PROJECT_BASE_INFO:READ+RECOVER";
|
||||
|
||||
/**
|
||||
* 项目环境权限
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ProjectExtendDTO extends Project implements Serializable {
|
||||
public class ProjectExtendDTO extends ProjectDTO implements Serializable {
|
||||
private List<String> moduleIds;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
@ -435,6 +435,7 @@ permission.edit=修改
|
|||
permission.delete=删除
|
||||
permission.import=导入
|
||||
permission.recover=恢复
|
||||
permission.export=导出
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未启用
|
||||
|
|
|
@ -437,6 +437,7 @@ permission.edit=Update
|
|||
permission.delete=Delete
|
||||
permission.import=Import
|
||||
permission.recover=Recover
|
||||
permission.export=Export
|
||||
|
||||
file_name_illegal_error=File name is illegal
|
||||
plugin_enable_error=Plugin is not enabled
|
||||
|
|
|
@ -435,6 +435,7 @@ permission.edit=修改
|
|||
permission.delete=删除
|
||||
permission.import=导入
|
||||
permission.recover=恢复
|
||||
permission.export=导出
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未启用
|
||||
|
|
|
@ -433,6 +433,7 @@ permission.edit=修改
|
|||
permission.delete=刪除
|
||||
permission.import=導入
|
||||
permission.recover=恢復
|
||||
permission.export=導出
|
||||
|
||||
file_name_illegal_error=文件名不合法
|
||||
plugin_enable_error=插件未啟用
|
||||
|
|
|
@ -2,15 +2,23 @@ package io.metersphere.project.controller;
|
|||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.request.ProjectSwitchRequest;
|
||||
import io.metersphere.project.service.ProjectLogService;
|
||||
import io.metersphere.project.service.ProjectService;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.util.SessionUtils;
|
||||
import io.metersphere.system.log.annotation.Log;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.validation.groups.Updated;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -23,7 +31,7 @@ public class ProjectController {
|
|||
private ProjectService projectService;
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
@Operation(summary = "基本信息")
|
||||
@Operation(summary = "项目管理-基本信息")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ)
|
||||
public ProjectExtendDTO getProject(@PathVariable String id) {
|
||||
return projectService.getProjectById(id);
|
||||
|
@ -42,4 +50,49 @@ public class ProjectController {
|
|||
public UserDTO switchProject(@RequestBody ProjectSwitchRequest request) {
|
||||
return projectService.switchProject(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "项目管理-更新项目")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#request)", msClass = ProjectLogService.class)
|
||||
public ProjectExtendDTO updateProject(@RequestBody @Validated({Updated.class}) UpdateProjectRequest request) {
|
||||
return projectService.update(request, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/delete/{id}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_DELETE)
|
||||
@Operation(summary = "项目管理-删除")
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = ProjectLogService.class)
|
||||
public int deleteProject(@PathVariable String id) {
|
||||
return projectService.delete(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/revoke/{id}")
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_RECOVER)
|
||||
@Operation(summary = "项目管理-撤销删除")
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.recoverLog(#id)", msClass = ProjectLogService.class)
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public int revokeProject(@PathVariable String id) {
|
||||
return projectService.revoke(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/enable/{id}")
|
||||
@Operation(summary = "项目管理-启用")
|
||||
@Parameter(name = "id", description = "项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ProjectLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
public void enable(@PathVariable String id) {
|
||||
projectService.enable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/disable/{id}")
|
||||
@Operation(summary = "项目管理-禁用")
|
||||
@Parameter(name = "id", description = "项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = ProjectLogService.class)
|
||||
public void disable(@PathVariable String id) {
|
||||
projectService.disable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.project.dto.environment.EnvironmentRequest;
|
||||
import io.metersphere.project.dto.environment.datasource.DataSource;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlob;
|
||||
import io.metersphere.sdk.domain.EnvironmentBlobExample;
|
||||
import io.metersphere.sdk.domain.EnvironmentExample;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.OptionDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.sdk.file.FileRequest;
|
||||
import io.metersphere.sdk.file.MinioRepository;
|
||||
import io.metersphere.sdk.mapper.EnvironmentBlobMapper;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import io.metersphere.system.uid.UUID;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.LogUtils;
|
||||
|
@ -41,12 +48,15 @@ public class EnvironmentService {
|
|||
private MinioRepository minioRepository;
|
||||
@Resource
|
||||
private JdbcDriverPluginService jdbcDriverPluginService;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
private static final String DIR_PATH = "/project-management/environment/";
|
||||
private static final String USERNAME = "user";
|
||||
private static final String PASSWORD = "password";
|
||||
|
||||
|
||||
public List<OptionDTO> getDriverOptions(String organizationId) {
|
||||
return jdbcDriverPluginService.getJdbcDriverOption(organizationId);
|
||||
}
|
||||
|
@ -190,6 +200,10 @@ public class EnvironmentService {
|
|||
// 拿到的参数是一个list
|
||||
List<EnvironmentRequest> environmentRequests = JSON.parseArray(content, EnvironmentRequest.class);
|
||||
if (CollectionUtils.isNotEmpty(environmentRequests)) {
|
||||
List<Environment> environments = new ArrayList<>();
|
||||
List<EnvironmentBlob> environmentBlobs = new ArrayList<>();
|
||||
List<LogDTO> logDTOS = new ArrayList<>();
|
||||
Project project = projectMapper.selectByPrimaryKey(currentProjectId);
|
||||
environmentRequests.forEach(environmentRequest -> {
|
||||
Environment environment = new Environment();
|
||||
environment.setId(UUID.randomUUID().toString());
|
||||
|
@ -201,12 +215,27 @@ public class EnvironmentService {
|
|||
checkEnvironmentExist(environment);
|
||||
environment.setCreateTime(System.currentTimeMillis());
|
||||
environment.setProjectId(currentProjectId);
|
||||
environmentMapper.insert(environment);
|
||||
environments.add(environment);
|
||||
EnvironmentBlob environmentBlob = new EnvironmentBlob();
|
||||
environmentBlob.setId(environment.getId());
|
||||
environmentBlob.setConfig(JSON.toJSONBytes(environmentRequest.getConfig()));
|
||||
environmentBlobMapper.insert(environmentBlob);
|
||||
environmentBlobs.add(environmentBlob);
|
||||
LogDTO logDTO = new LogDTO(
|
||||
currentProjectId,
|
||||
project.getOrganizationId(),
|
||||
environment.getId(),
|
||||
userId,
|
||||
OperationLogType.ADD.name(),
|
||||
OperationLogModule.PROJECT_ENVIRONMENT_SETTING,
|
||||
environment.getName());
|
||||
logDTO.setMethod(HttpMethodConstants.POST.name());
|
||||
logDTO.setOriginalValue(JSON.toJSONBytes(environmentRequest.getConfig()));
|
||||
logDTO.setPath("/project/environment/import");
|
||||
logDTOS.add(logDTO);
|
||||
});
|
||||
environmentMapper.batchInsert(environments);
|
||||
environmentBlobMapper.batchInsert(environmentBlobs);
|
||||
operationLogService.batchAdd(logDTOS);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.error("获取文件输入流异常", e);
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
package io.metersphere.project.service;
|
||||
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.dto.LogDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ProjectLogService {
|
||||
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
/**
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
public LogDTO updateLog(UpdateProjectRequest request) {
|
||||
Project project = projectMapper.selectByPrimaryKey(request.getId());
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
project.getId(),
|
||||
project.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public LogDTO updateLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
project.getId(),
|
||||
project.getCreateUser(),
|
||||
OperationLogType.UPDATE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
dto.setMethod(HttpMethodConstants.GET.name());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口日志
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public LogDTO deleteLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
id,
|
||||
project.getCreateUser(),
|
||||
OperationLogType.DELETE.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复项目
|
||||
* @param id 接口请求参数
|
||||
* @return 日志详情
|
||||
*/
|
||||
public LogDTO recoverLog(String id) {
|
||||
Project project = projectMapper.selectByPrimaryKey(id);
|
||||
if (project != null) {
|
||||
LogDTO dto = new LogDTO(
|
||||
project.getId(),
|
||||
project.getOrganizationId(),
|
||||
id,
|
||||
null,
|
||||
OperationLogType.RECOVER.name(),
|
||||
OperationLogModule.PROJECT_MANAGEMENT,
|
||||
project.getName());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(project));
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -8,8 +8,10 @@ import io.metersphere.project.request.ProjectSwitchRequest;
|
|||
import io.metersphere.sdk.constants.InternalUserRole;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.SessionUser;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.domain.Organization;
|
||||
import io.metersphere.system.service.BaseUserService;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
|
@ -20,6 +22,7 @@ import io.metersphere.system.domain.UserRoleRelation;
|
|||
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||
import io.metersphere.system.mapper.OrganizationMapper;
|
||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||
import io.metersphere.system.service.CommonProjectService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -42,6 +45,8 @@ public class ProjectService {
|
|||
private BaseUserService baseUserService;
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
@Resource
|
||||
private CommonProjectService commonProjectService;
|
||||
|
||||
|
||||
public List<Project> getUserProject(String organizationId, String userId) {
|
||||
|
@ -82,6 +87,8 @@ public class ProjectService {
|
|||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
if (ObjectUtils.isNotEmpty(project)) {
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
Organization organization = organizationMapper.selectByPrimaryKey(project.getOrganizationId());
|
||||
projectExtendDTO.setOrganizationName(organization.getName());
|
||||
if (StringUtils.isNotEmpty(project.getModuleSetting())) {
|
||||
projectExtendDTO.setModuleIds(JSON.parseArray(project.getModuleSetting(), String.class));
|
||||
}
|
||||
|
@ -90,4 +97,60 @@ public class ProjectService {
|
|||
}
|
||||
return projectExtendDTO;
|
||||
}
|
||||
|
||||
public ProjectExtendDTO update(UpdateProjectRequest updateProjectDto, String updateUser) {
|
||||
Project project = new Project();
|
||||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
project.setId(updateProjectDto.getId());
|
||||
project.setName(updateProjectDto.getName());
|
||||
project.setDescription(updateProjectDto.getDescription());
|
||||
project.setOrganizationId(updateProjectDto.getOrganizationId());
|
||||
project.setEnable(updateProjectDto.getEnable());
|
||||
project.setUpdateUser(updateUser);
|
||||
project.setCreateUser(null);
|
||||
project.setCreateTime(null);
|
||||
project.setUpdateTime(System.currentTimeMillis());
|
||||
checkProjectExistByName(project);
|
||||
checkProjectNotExist(project.getId());
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(updateProjectDto.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
//判断是否有模块设置
|
||||
if (CollectionUtils.isNotEmpty(updateProjectDto.getModuleIds())) {
|
||||
project.setModuleSetting(JSON.toJSONString(updateProjectDto.getModuleIds()));
|
||||
projectExtendDTO.setModuleIds(updateProjectDto.getModuleIds());
|
||||
}
|
||||
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
return projectExtendDTO;
|
||||
}
|
||||
|
||||
private void checkProjectExistByName(Project project) {
|
||||
ProjectExample example = new ProjectExample();
|
||||
example.createCriteria().andNameEqualTo(project.getName()).andOrganizationIdEqualTo(project.getOrganizationId()).andIdNotEqualTo(project.getId());
|
||||
if (projectMapper.selectByExample(example).size() > 0) {
|
||||
throw new MSException(Translator.get("project_name_already_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
public void checkProjectNotExist(String id) {
|
||||
if (projectMapper.selectByPrimaryKey(id) == null) {
|
||||
throw new MSException(Translator.get("project_is_not_exist"));
|
||||
}
|
||||
}
|
||||
|
||||
public int delete(String id, String deleteUser) {
|
||||
return commonProjectService.delete(id,deleteUser);
|
||||
}
|
||||
|
||||
public int revoke(String id, String updateUser) {
|
||||
return commonProjectService.revoke(id, updateUser);
|
||||
}
|
||||
|
||||
public void enable(String id, String updateUser) {
|
||||
commonProjectService.enable(id, updateUser);
|
||||
}
|
||||
|
||||
public void disable(String id, String updateUser) {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
"permissions": [
|
||||
{
|
||||
"id": "PROJECT:READ"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT:READ+UPDATE"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -64,6 +67,12 @@
|
|||
},
|
||||
{
|
||||
"id": "PROJECT_ENVIRONMENT:READ+DELETE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_ENVIRONMENT:READ+IMPORT"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_ENVIRONMENT:READ+EXPORT"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -128,7 +137,6 @@
|
|||
"permissions": [
|
||||
{
|
||||
"id": "PROJECT_FAKE_ERROR:READ"
|
||||
|
||||
},
|
||||
{
|
||||
"id": "PROJECT_FAKE_ERROR:READ+ADD"
|
||||
|
|
|
@ -8,11 +8,15 @@ import io.metersphere.project.request.ProjectSwitchRequest;
|
|||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.UserDTO;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -21,9 +25,11 @@ import org.springframework.test.context.jdbc.Sql;
|
|||
import org.springframework.test.context.jdbc.SqlConfig;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.ResultMatcher;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
|
@ -38,6 +44,14 @@ public class ProjectControllerTests extends BaseTest {
|
|||
private MockMvc mockMvc;
|
||||
private static final String prefix = "/project";
|
||||
private static final String getOptions = prefix + "/list/options/";
|
||||
private final static String updateProject = prefix + "/update";
|
||||
private final static String deleteProject = prefix + "/delete/";
|
||||
private final static String revokeProject = prefix + "/revoke/";
|
||||
private final static String disableProject = prefix + "/disable/";
|
||||
private final static String enableProject = prefix + "/enable/";
|
||||
|
||||
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
|
||||
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
|
||||
|
@ -62,6 +76,57 @@ public class ProjectControllerTests extends BaseTest {
|
|||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
private void responseGet(String url, ResultMatcher resultMatcher) throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get(url)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(resultMatcher)
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
public UpdateProjectRequest generatorUpdate(String organizationId,
|
||||
String projectId,
|
||||
String name,
|
||||
String description,
|
||||
boolean enable,
|
||||
List<String> userIds) {
|
||||
UpdateProjectRequest updateProjectDTO = new UpdateProjectRequest();
|
||||
updateProjectDTO.setOrganizationId(organizationId);
|
||||
updateProjectDTO.setId(projectId);
|
||||
updateProjectDTO.setName(name);
|
||||
updateProjectDTO.setDescription(description);
|
||||
updateProjectDTO.setEnable(enable);
|
||||
updateProjectDTO.setUserIds(userIds);
|
||||
return updateProjectDTO;
|
||||
}
|
||||
|
||||
public static void compareProjectDTO(Project currentProject, Project result) {
|
||||
Assertions.assertNotNull(currentProject);
|
||||
Assertions.assertNotNull(result);
|
||||
//判断ID是否一样
|
||||
Assertions.assertTrue(StringUtils.equals(currentProject.getId(), result.getId()));
|
||||
//判断名称是否一样
|
||||
Assertions.assertTrue(StringUtils.equals(currentProject.getName(), result.getName()));
|
||||
//判断组织是否一样
|
||||
Assertions.assertTrue(StringUtils.equals(currentProject.getOrganizationId(), result.getOrganizationId()));
|
||||
//判断描述是否一样
|
||||
Assertions.assertTrue(StringUtils.equals(currentProject.getDescription(), result.getDescription()));
|
||||
//判断是否启用
|
||||
Assertions.assertSame(currentProject.getEnable(), result.getEnable());
|
||||
|
||||
}
|
||||
|
||||
private MvcResult responsePost(String url, Object param) throws Exception {
|
||||
return mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.content(JSON.toJSONString(param))
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
|
@ -197,4 +262,149 @@ public class ProjectControllerTests extends BaseTest {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(7)
|
||||
public void testUpdateProject() throws Exception {
|
||||
UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId1","project-TestName", "Edit name", true, List.of("admin1"));
|
||||
Project projectExtend = projectMapper.selectByPrimaryKey("projectId1");
|
||||
List<String> moduleIds = new ArrayList<>();
|
||||
if (StringUtils.isNotBlank(projectExtend.getModuleSetting())) {
|
||||
moduleIds = JSON.parseArray(projectExtend.getModuleSetting(), String.class);
|
||||
}
|
||||
project.setModuleIds(moduleIds);
|
||||
MvcResult mvcResult = this.responsePost(updateProject, project);
|
||||
ProjectExtendDTO result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//断言模块设置
|
||||
projectExtend = projectMapper.selectByPrimaryKey("projectId1");
|
||||
Assertions.assertEquals(projectExtend.getModuleSetting(), CollectionUtils.isEmpty(project.getModuleIds()) ? null : JSON.toJSONString(project.getModuleIds()));
|
||||
|
||||
// 校验日志
|
||||
checkLog("projectId1", OperationLogType.UPDATE);
|
||||
// 修改模块设置
|
||||
project = this.generatorUpdate("organizationId", "projectId3", "project-Module", "Edit name", true, new ArrayList<>());
|
||||
moduleIds = new ArrayList<>();
|
||||
moduleIds.add("apiTest");
|
||||
moduleIds.add("uiTest");
|
||||
project.setModuleIds(moduleIds);
|
||||
mvcResult = this.responsePost(updateProject, project);
|
||||
result = parseObjectFromMvcResult(mvcResult, ProjectExtendDTO.class);
|
||||
currentProject = projectMapper.selectByPrimaryKey(project.getId());
|
||||
compareProjectDTO(currentProject, result);
|
||||
//断言模块设置
|
||||
projectExtend = projectMapper.selectByPrimaryKey("projectId3");
|
||||
Assertions.assertEquals(projectExtend.getModuleSetting(), JSON.toJSONString(moduleIds));
|
||||
// @@校验权限
|
||||
project.setName("project-TestName2");
|
||||
project.setId(DEFAULT_PROJECT_ID);
|
||||
project.setOrganizationId(DEFAULT_ORGANIZATION_ID);
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE, updateProject, project);
|
||||
// 校验日志
|
||||
checkLog(DEFAULT_PROJECT_ID, OperationLogType.UPDATE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(8)
|
||||
public void testUpdateProjectError() throws Exception {
|
||||
//项目名称存在 500
|
||||
UpdateProjectRequest project = this.generatorUpdate("organizationId", "projectId3","project-TestName", "description", true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
//参数组织Id为空
|
||||
project = this.generatorUpdate(null, "projectId",null, null, true , List.of("admin"));
|
||||
this.requestPost(updateProject, project, BAD_REQUEST_MATCHER);
|
||||
//项目Id为空
|
||||
project = this.generatorUpdate("organizationId", null,null, null, true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, BAD_REQUEST_MATCHER);
|
||||
//项目名称为空
|
||||
project = this.generatorUpdate("organizationId", "projectId",null, null, true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, BAD_REQUEST_MATCHER);
|
||||
//项目不存在
|
||||
project = this.generatorUpdate("organizationId", "1111","123", null, true, List.of("admin"));
|
||||
this.requestPost(updateProject, project, ERROR_REQUEST_MATCHER);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
public void testDeleteProject() throws Exception {
|
||||
MvcResult mvcResult = this.responseGet(deleteProject + "projectId4");
|
||||
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey("projectId4");
|
||||
Assertions.assertEquals(currentProject.getDeleted(), true);
|
||||
Assertions.assertEquals(currentProject.getId(), "projectId4");
|
||||
Assertions.assertEquals(1, count);
|
||||
// 校验日志
|
||||
checkLog("projectId4", OperationLogType.DELETE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_DELETE, deleteProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
public void testDeleteProjectError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(deleteProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(11)
|
||||
public void revokeSuccess() throws Exception {
|
||||
MvcResult mvcResult = this.responseGet(revokeProject + "projectId4");
|
||||
int count = parseObjectFromMvcResult(mvcResult, Integer.class);
|
||||
Project currentProject = projectMapper.selectByPrimaryKey("projectId4");
|
||||
Assertions.assertEquals(currentProject.getDeleted(), false);
|
||||
Assertions.assertEquals(currentProject.getId(), "projectId4");
|
||||
Assertions.assertEquals(1, count);
|
||||
// 校验日志
|
||||
checkLog("projectId4", OperationLogType.RECOVER);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_RECOVER, revokeProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(12)
|
||||
public void testRevokeProjectError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(revokeProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
public void disableSuccess() throws Exception {
|
||||
String id = "projectId4";
|
||||
this.responseGet(disableProject + id,status().isOk());
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(id);
|
||||
Assertions.assertEquals(currentProject.getEnable(), false);
|
||||
checkLog(id, OperationLogType.UPDATE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE, disableProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
public void disableError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(disableProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
public void enableSuccess() throws Exception {
|
||||
String id = "projectId4";
|
||||
this.responseGet(enableProject + id,status().isOk());
|
||||
Project currentProject = projectMapper.selectByPrimaryKey(id);
|
||||
Assertions.assertEquals(currentProject.getEnable(), true);
|
||||
checkLog(id, OperationLogType.UPDATE);
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ_UPDATE, enableProject + DEFAULT_PROJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
public void enableError() throws Exception {
|
||||
String id = "1111";
|
||||
this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ replace INTO project (id, num, organization_id, name, description, create_user,
|
|||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable,module_setting) VALUES ('projectId5', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目5', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO organization(id,num, name, description, create_time, update_time, create_user, update_user, delete_user, delete_time) VALUE
|
||||
('organizationId',null, 'test-org', 'project', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, null);
|
||||
|
||||
|
||||
# 插入测试数据 给组织增加成员
|
||||
|
|
|
@ -52,7 +52,7 @@ public class OrganizationProjectController {
|
|||
@Operation(summary = "系统设置-组织-项目-根据ID获取项目信息")
|
||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
|
||||
public Project getProject(@PathVariable @NotBlank String id) {
|
||||
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||
return organizationProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class OrganizationProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.recoverLog(#id)", msClass = OrganizationProjectLogService.class)
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public int revokeProject(@PathVariable String id) {
|
||||
return organizationProjectService.revoke(id);
|
||||
return organizationProjectService.revoke(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/enable/{id}")
|
||||
|
@ -97,7 +97,7 @@ public class OrganizationProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = OrganizationProjectLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
public void enable(@PathVariable String id) {
|
||||
organizationProjectService.enable(id);
|
||||
organizationProjectService.enable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/disable/{id}")
|
||||
|
@ -106,7 +106,7 @@ public class OrganizationProjectController {
|
|||
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = OrganizationProjectLogService.class)
|
||||
public void disable(@PathVariable String id) {
|
||||
organizationProjectService.disable(id);
|
||||
organizationProjectService.disable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/member-list")
|
||||
|
|
|
@ -57,7 +57,7 @@ public class SystemProjectController {
|
|||
@Operation(summary = "系统设置-系统-组织与项目-项目-根据ID获取项目信息")
|
||||
@Parameter(name = "id", description = "项目id", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
public Project getProject(@PathVariable @NotBlank String id) {
|
||||
public ProjectExtendDTO getProject(@PathVariable @NotBlank String id) {
|
||||
return systemProjectService.get(id);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class SystemProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.recoverLog(#id)", msClass = SystemProjectLogService.class)
|
||||
@Parameter(name = "id", description = "项目", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED))
|
||||
public int revokeProject(@PathVariable String id) {
|
||||
return systemProjectService.revoke(id);
|
||||
return systemProjectService.revoke(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/enable/{id}")
|
||||
|
@ -102,7 +102,7 @@ public class SystemProjectController {
|
|||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = SystemProjectLogService.class)
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
public void enable(@PathVariable String id) {
|
||||
systemProjectService.enable(id);
|
||||
systemProjectService.enable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@GetMapping("/disable/{id}")
|
||||
|
@ -111,7 +111,7 @@ public class SystemProjectController {
|
|||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_UPDATE)
|
||||
@Log(type = OperationLogType.UPDATE, expression = "#msClass.updateLog(#id)", msClass = SystemProjectLogService.class)
|
||||
public void disable(@PathVariable String id) {
|
||||
systemProjectService.disable(id);
|
||||
systemProjectService.disable(id, SessionUtils.getUserId());
|
||||
}
|
||||
|
||||
@PostMapping("/member-list")
|
||||
|
|
|
@ -117,6 +117,7 @@ public class BaseUserRoleService {
|
|||
put("READ+DELETE", "permission.delete");
|
||||
put("READ+IMPORT", "permission.import");
|
||||
put("READ+RECOVER", "permission.recover");
|
||||
put("READ+EXPORT", "permission.export");
|
||||
}};
|
||||
return Translator.get(translationMap.get(permissionKey));
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ public class CommonProjectService {
|
|||
@Resource
|
||||
private BaseUserService baseUserService;
|
||||
private final ProjectServiceInvoker serviceInvoker;
|
||||
@Resource
|
||||
private OrganizationMapper organizationMapper;
|
||||
|
||||
@Autowired
|
||||
public CommonProjectService(ProjectServiceInvoker serviceInvoker) {
|
||||
|
@ -68,6 +70,7 @@ public class CommonProjectService {
|
|||
ProjectExtendDTO projectExtendDTO = new ProjectExtendDTO();
|
||||
if (ObjectUtils.isNotEmpty(project)) {
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
if (StringUtils.isNotEmpty(project.getModuleSetting())) {
|
||||
projectExtendDTO.setModuleIds(JSON.parseArray(project.getModuleSetting(), String.class));
|
||||
}
|
||||
|
@ -100,7 +103,7 @@ public class CommonProjectService {
|
|||
project.setDescription(addProjectDTO.getDescription());
|
||||
addProjectDTO.setId(project.getId());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
//判断是否有模块设置
|
||||
if (CollectionUtils.isNotEmpty(addProjectDTO.getModuleIds())) {
|
||||
project.setModuleSetting(JSON.toJSONString(addProjectDTO.getModuleIds()));
|
||||
|
@ -229,6 +232,7 @@ public class CommonProjectService {
|
|||
project.setUpdateTime(System.currentTimeMillis());
|
||||
checkProjectExistByName(project);
|
||||
checkProjectNotExist(project.getId());
|
||||
projectExtendDTO.setOrganizationName(organizationMapper.selectByPrimaryKey(project.getOrganizationId()).getName());
|
||||
BeanUtils.copyBean(projectExtendDTO, project);
|
||||
UserRoleRelationExample example = new UserRoleRelationExample();
|
||||
example.createCriteria().andSourceIdEqualTo(project.getId()).andRoleIdEqualTo(InternalUserRole.PROJECT_ADMIN.getValue());
|
||||
|
@ -422,13 +426,15 @@ public class CommonProjectService {
|
|||
return userRoleRelationMapper.deleteByExample(userRoleRelationExample);
|
||||
}
|
||||
|
||||
public int revoke(String id) {
|
||||
public int revoke(String id, String updateUser) {
|
||||
checkProjectNotExist(id);
|
||||
Project project = new Project();
|
||||
project.setId(id);
|
||||
project.setDeleted(false);
|
||||
project.setDeleteTime(null);
|
||||
project.setDeleteUser(null);
|
||||
project.setUpdateUser(updateUser);
|
||||
project.setUpdateTime(System.currentTimeMillis());
|
||||
return projectMapper.updateByPrimaryKeySelective(project);
|
||||
}
|
||||
|
||||
|
@ -487,20 +493,22 @@ public class CommonProjectService {
|
|||
logDTOList.add(dto);
|
||||
}
|
||||
|
||||
public void enable(String id) {
|
||||
public void enable(String id, String updateUser) {
|
||||
checkProjectNotExist(id);
|
||||
Project project = new Project();
|
||||
project.setId(id);
|
||||
project.setEnable(true);
|
||||
project.setUpdateUser(updateUser);
|
||||
project.setUpdateTime(System.currentTimeMillis());
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
}
|
||||
|
||||
public void disable(String id) {
|
||||
public void disable(String id, String updateUser) {
|
||||
checkProjectNotExist(id);
|
||||
Project project = new Project();
|
||||
project.setId(id);
|
||||
project.setEnable(false);
|
||||
project.setUpdateUser(updateUser);
|
||||
project.setUpdateTime(System.currentTimeMillis());
|
||||
projectMapper.updateByPrimaryKeySelective(project);
|
||||
}
|
||||
|
|
|
@ -89,16 +89,16 @@ public class OrganizationProjectService {
|
|||
return commonProjectService.removeProjectMember(projectId, userId, createUser, OperationLogModule.SETTING_ORGANIZATION_PROJECT, StringUtils.join(REMOVE_PROJECT_MEMBER, projectId, "/", userId));
|
||||
}
|
||||
|
||||
public int revoke(String id) {
|
||||
return commonProjectService.revoke(id);
|
||||
public int revoke(String id, String updateUser) {
|
||||
return commonProjectService.revoke(id, updateUser);
|
||||
}
|
||||
|
||||
public void enable(String id) {
|
||||
commonProjectService.enable(id);
|
||||
public void enable(String id, String updateUser) {
|
||||
commonProjectService.enable(id, updateUser);
|
||||
}
|
||||
|
||||
public void disable(String id) {
|
||||
commonProjectService.disable(id);
|
||||
public void disable(String id, String updateUser) {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
}
|
||||
|
||||
public List<UserExtend> getUserAdminList(String organizationId, String keyword) {
|
||||
|
|
|
@ -79,8 +79,8 @@ public class SystemProjectService {
|
|||
return commonProjectService.removeProjectMember(projectId, userId, createUser, OperationLogModule.SETTING_SYSTEM_ORGANIZATION, StringUtils.join(REMOVE_PROJECT_MEMBER, projectId, "/", userId));
|
||||
}
|
||||
|
||||
public int revoke(String id) {
|
||||
return commonProjectService.revoke(id);
|
||||
public int revoke(String id, String updateUser) {
|
||||
return commonProjectService.revoke(id, updateUser);
|
||||
}
|
||||
|
||||
public void deleteProject(List<Project> projects) {
|
||||
|
@ -91,11 +91,11 @@ public class SystemProjectService {
|
|||
return extSystemProjectMapper.selectProjectOptions(organizationId);
|
||||
}
|
||||
|
||||
public void enable(String id) {
|
||||
commonProjectService.enable(id);
|
||||
public void enable(String id, String updateUser) {
|
||||
commonProjectService.enable(id, updateUser);
|
||||
}
|
||||
|
||||
public void disable(String id) {
|
||||
commonProjectService.disable(id);
|
||||
public void disable(String id, String updateUser) {
|
||||
commonProjectService.disable(id, updateUser);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ replace INTO project (id, num, organization_id, name, description, create_user,
|
|||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable,module_setting) VALUES ('projectId5', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目5', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO organization(id,num, name, description, create_time, update_time, create_user, update_user, delete_user, delete_time) VALUE
|
||||
('organizationId',null, 'test-org', 'project', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, null);
|
||||
|
||||
|
||||
# 插入测试数据 给组织增加成员
|
||||
|
|
|
@ -7,6 +7,9 @@ replace INTO project (id, num, organization_id, name, description, create_user,
|
|||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable,module_setting) VALUES ('projectId5', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目5', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
|
||||
replace INTO organization(id,num, name, description, create_time, update_time, create_user, update_user, delete_user, delete_time) VALUE
|
||||
('organizationId',null, 'test-org', 'project', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'admin', null, null);
|
||||
|
||||
replace into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source,
|
||||
last_project_id, create_user, update_user)
|
||||
VALUES ('admin1', 'test1', 'admin1@metersphere.io', MD5('admin1@metersphere.io'),
|
||||
|
|
Loading…
Reference in New Issue