refactor(配额管理): 新建的项目或工作空间使用默认配额
--bug=1012459 --user=李玉号 新创建的空间和项目,配额列表的“使用默认配额”按钮未默认开启 https://www.tapd.cn/55049933/s/1140929
This commit is contained in:
parent
77280c7443
commit
b1a06a2b36
|
@ -142,7 +142,8 @@ public class ProjectService {
|
|||
if (StringUtils.isBlank(project.getPlatform())) {
|
||||
project.setPlatform(IssuesManagePlatform.Local.name());
|
||||
}
|
||||
project.setId(UUID.randomUUID().toString());
|
||||
String pjId = UUID.randomUUID().toString();
|
||||
project.setId(pjId);
|
||||
|
||||
String systemId = this.genSystemId();
|
||||
long createTime = System.currentTimeMillis();
|
||||
|
@ -167,6 +168,10 @@ public class ProjectService {
|
|||
// 设置默认的通知
|
||||
extProjectMapper.setDefaultMessageTask(project.getId());
|
||||
|
||||
if (quotaService != null) {
|
||||
quotaService.projectUseDefaultQuota(pjId);
|
||||
}
|
||||
|
||||
ProjectVersionService projectVersionService = CommonBeanFactory.getBean(ProjectVersionService.class);
|
||||
if (projectVersionService != null) {
|
||||
ProjectVersion projectVersion = new ProjectVersion();
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.service;
|
|||
|
||||
|
||||
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||
import io.metersphere.base.domain.Quota;
|
||||
import io.metersphere.performance.request.TestPlanRequest;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -80,4 +81,19 @@ public interface QuotaService {
|
|||
*/
|
||||
BigDecimal getReduceVumUsed(LoadTestReportWithBLOBs report);
|
||||
|
||||
/**
|
||||
* 如果有该项目配额,修改为使用工作空间下项目默认配额
|
||||
* 无该配额,新建配额并默认使用工作空间下项目默认配额
|
||||
* @return 操作后的配额
|
||||
*/
|
||||
Quota projectUseDefaultQuota(String projectId);
|
||||
|
||||
/**
|
||||
* 如果有该工作空间配额,修改为使用系统默认配额,
|
||||
* 无该配额,新建配额并默认使用系统配额
|
||||
* @param workspaceId 工作空间ID
|
||||
* @return 操作后的配额
|
||||
*/
|
||||
Quota workspaceUseDefaultQuota(String workspaceId);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import io.metersphere.base.mapper.ext.ExtWorkspaceMapper;
|
|||
import io.metersphere.commons.constants.UserGroupConstants;
|
||||
import io.metersphere.commons.constants.UserGroupType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
import io.metersphere.controller.request.WorkspaceRequest;
|
||||
import io.metersphere.dto.RelatedSource;
|
||||
|
@ -202,12 +203,19 @@ public class WorkspaceService {
|
|||
|
||||
public Workspace addWorkspaceByAdmin(Workspace workspace) {
|
||||
checkWorkspace(workspace);
|
||||
workspace.setId(UUID.randomUUID().toString());
|
||||
String wsId = UUID.randomUUID().toString();
|
||||
workspace.setId(wsId);
|
||||
workspace.setCreateTime(System.currentTimeMillis());
|
||||
workspace.setUpdateTime(System.currentTimeMillis());
|
||||
workspace.setCreateUser(SessionUtils.getUserId());
|
||||
workspaceMapper.insertSelective(workspace);
|
||||
|
||||
|
||||
QuotaService quotaService = CommonBeanFactory.getBean(QuotaService.class);
|
||||
if (quotaService != null) {
|
||||
quotaService.workspaceUseDefaultQuota(wsId);
|
||||
}
|
||||
|
||||
// 创建工作空间为当前用户添加用户组
|
||||
UserGroup userGroup = new UserGroup();
|
||||
userGroup.setId(UUID.randomUUID().toString());
|
||||
|
|
Loading…
Reference in New Issue