mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 20:19:16 +08:00
feat(系统设置): 超级管理员的项目列表进行排序处理
This commit is contained in:
parent
b8ca3b5e96
commit
06c03d5982
@ -10,11 +10,11 @@ import io.metersphere.dto.ProjectDTO;
|
||||
import io.metersphere.log.annotation.MsAuditLog;
|
||||
import io.metersphere.request.ProjectRequest;
|
||||
import io.metersphere.service.BaseProjectService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@ -33,7 +33,7 @@ public class BaseProjectController {
|
||||
public List<Project> getUserProject(@RequestBody ProjectRequest request) {
|
||||
// 仅支持查询当前用户的项目
|
||||
request.setUserId(SessionUtils.getUserId());
|
||||
return baseProjectService.getUserProject(request);
|
||||
return baseProjectService.getUserProject(request, SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
@PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"})
|
||||
|
@ -99,7 +99,7 @@ public class BaseProjectService {
|
||||
return baseProjectMapper.getProjectWithWorkspace(request);
|
||||
}
|
||||
|
||||
public List<Project> getUserProject(ProjectRequest request) {
|
||||
public List<Project> getUserProject(ProjectRequest request, String sessionProjectId) {
|
||||
boolean isSuper = baseUserMapper.isSuperUser(SessionUtils.getUserId());
|
||||
if (isSuper) {
|
||||
ProjectExample example = new ProjectExample();
|
||||
@ -110,22 +110,29 @@ public class BaseProjectService {
|
||||
if (StringUtils.isNotBlank(request.getWorkspaceId())) {
|
||||
criteria.andWorkspaceIdEqualTo(request.getWorkspaceId());
|
||||
}
|
||||
return projectMapper.selectByExample(example);
|
||||
example.setOrderByClause(" CONVERT(name USING gbk) COLLATE gbk_chinese_ci ASC ");
|
||||
List<Project> returnProject = projectMapper.selectByExample(example);
|
||||
this.swapProject(returnProject, sessionProjectId);
|
||||
return returnProject;
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getName())) {
|
||||
request.setName(StringUtils.wrapIfMissing(request.getName(), "%"));
|
||||
}
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
List<Project> returnList = baseProjectMapper.getUserProject(request);
|
||||
this.swapProject(returnList, sessionProjectId);
|
||||
return returnList;
|
||||
}
|
||||
|
||||
private void swapProject(List<Project> projectList, String sessionProjectId) {
|
||||
int ownerProjectIndex = 0;
|
||||
for (int i = 0; i < returnList.size(); i++) {
|
||||
if (StringUtils.equals(returnList.get(i).getId(), SessionUtils.getCurrentProjectId())) {
|
||||
for (int i = 0; i < projectList.size(); i++) {
|
||||
if (StringUtils.equals(projectList.get(i).getId(), sessionProjectId)) {
|
||||
ownerProjectIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Collections.swap(returnList, 0, ownerProjectIndex);
|
||||
return returnList;
|
||||
Collections.swap(projectList, 0, ownerProjectIndex);
|
||||
}
|
||||
|
||||
public List<Project> getProjectByIds(List<String> ids) {
|
||||
|
Loading…
Reference in New Issue
Block a user