refactor(系统设置): 优化环境组名称在边界值时的复制问题

--bug=1027794 --user=王孝刚
【系统设置】github#25592,系统设置-环境组名称为边界值50,在列表里面点复制字符超长 会提示sql error。
_copy边界值复制问题请优化 https://www.tapd.cn/55049933/s/1396374
This commit is contained in:
wxg0103 2023-07-24 11:19:25 +08:00 committed by fit2-zhao
parent 4dc42df9b6
commit ba0036eccb
2 changed files with 6 additions and 2 deletions

View File

@ -236,7 +236,7 @@ public class PermissionConstants {
public static final String WORKSPACE_PROJECT_ENVIRONMENT_GROUP_READ = "WORKSPACE_PROJECT_ENVIRONMENT:READ+CREATE_GROUP";
public static final String WORKSPACE_PROJECT_ENVIRONMENT_GROUP_DELETE = "WORKSPACE_PROJECT_ENVIRONMENT:READ+DELETE_GROUP";
public static final String WORKSPACE_PROJECT_ENVIRONMENT_GROUP_EDIT = "WORKSPACE_PROJECT_ENVIRONMENT:READ+EDIT_GROUP";
public static final String WORKSPACE_PROJECT_ENVIRONMENT_GROUP_COPY = "WORKSPACE_PROJECT_ENVIRONMENT:READ+COPY_GROU";
public static final String WORKSPACE_PROJECT_ENVIRONMENT_GROUP_COPY = "WORKSPACE_PROJECT_ENVIRONMENT:READ+COPY_GROUP";
public static final String SYSTEM_PLUGIN_DEL = "SYSTEM_PLUGIN:DEL";
public static final String SYSTEM_PLUGIN_UPLOAD = "SYSTEM_PLUGIN:UPLOAD";

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.dto.EnvironmentGroupDTO;
import io.metersphere.environment.dto.EnvironmentGroupRequest;
import io.metersphere.i18n.Translator;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@ -22,7 +23,6 @@ import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import jakarta.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -184,6 +184,10 @@ public class EnvironmentGroupService {
copy.setId(copyId);
String copyNameId = copyId.substring(0, 3);
//名字长度大于50 则截取前四十个字符
if (environmentGroup.getName().length() + 9 > 50) {
environmentGroup.setName(environmentGroup.getName().substring(0, 41));
}
String copyName = environmentGroup.getName() + "_" + copyNameId + "_COPY";
copy.setName(copyName);
copy.setWorkspaceId(environmentGroup.getWorkspaceId());