refactor(系统设置): 项目增加查询用户列表的接口

This commit is contained in:
wxg0103 2023-08-21 15:54:26 +08:00 committed by wxg0103
parent 887077cdc3
commit 78948351a1
5 changed files with 44 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import io.metersphere.sdk.log.constants.OperationLogType;
import io.metersphere.sdk.util.PageUtils;
import io.metersphere.sdk.util.Pager;
import io.metersphere.sdk.util.SessionUtils;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.UserExtend;
import io.metersphere.system.request.OrganizationProjectRequest;
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
@ -20,6 +21,7 @@ import io.metersphere.system.request.ProjectAddMemberRequest;
import io.metersphere.system.request.ProjectMemberRequest;
import io.metersphere.system.service.OrganizationProjectLogService;
import io.metersphere.system.service.OrganizationProjectService;
import io.metersphere.system.service.UserService;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.Operation;
@ -41,6 +43,8 @@ import java.util.List;
public class OrganizationProjectController {
@Resource
private OrganizationProjectService organizationProjectService;
@Resource
private UserService userService;
@PostMapping("/add")
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_ADD)
@ -141,5 +145,11 @@ public class OrganizationProjectController {
return organizationProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
}
@GetMapping("/user-list")
@Operation(summary = "获取用户列表")
@RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ)
public List<User> getUserList() {
return userService.getUserList();
}
}

View File

@ -13,6 +13,7 @@ import io.metersphere.sdk.log.constants.OperationLogType;
import io.metersphere.sdk.util.PageUtils;
import io.metersphere.sdk.util.Pager;
import io.metersphere.sdk.util.SessionUtils;
import io.metersphere.system.domain.User;
import io.metersphere.system.dto.UserExtend;
import io.metersphere.system.request.ProjectAddMemberBatchRequest;
import io.metersphere.system.request.ProjectAddMemberRequest;
@ -20,6 +21,7 @@ import io.metersphere.system.request.ProjectMemberRequest;
import io.metersphere.system.request.ProjectRequest;
import io.metersphere.system.service.SystemProjectLogService;
import io.metersphere.system.service.SystemProjectService;
import io.metersphere.system.service.UserService;
import io.metersphere.validation.groups.Created;
import io.metersphere.validation.groups.Updated;
import io.swagger.v3.oas.annotations.Operation;
@ -41,6 +43,8 @@ import java.util.List;
public class SystemProjectController {
@Resource
private SystemProjectService systemProjectService;
@Resource
private UserService userService;
@PostMapping("/add")
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD)
@ -141,5 +145,11 @@ public class SystemProjectController {
return systemProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId());
}
@GetMapping("/user-list")
@Operation(summary = "获取用户列表")
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
public List<User> getUserList() {
return userService.getUserList();
}
}

View File

@ -4,12 +4,14 @@ import io.metersphere.system.domain.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @author song-cc-rock
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class UserExtend extends User {
public class UserExtend extends User implements Serializable {
/**
* 是否管理员(组织, 项目)
@ -20,4 +22,6 @@ public class UserExtend extends User {
* 是否成员(组织, 项目)
*/
private boolean memberFlag;
private static final long serialVersionUID = 1L;
}

View File

@ -65,6 +65,7 @@ public class OrganizationProjectControllerTests extends BaseTest {
private final static String removeProjectMember = prefix + "/remove-member/";
private final static String disableProject = prefix + "/disable/";
private final static String enableProject = prefix + "/enable/";
private final static String userList = prefix + "/user-list";
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
@ -706,4 +707,13 @@ public class OrganizationProjectControllerTests extends BaseTest {
this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER);
}
@Test
@Order(21)
public void testUserList() throws Exception {
this.requestGetWithOkAndReturn(userList);
// @@校验权限
requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, userList);
}
}

View File

@ -63,6 +63,7 @@ public class SystemProjectControllerTests extends BaseTest {
private final static String removeProjectMember = prefix + "/remove-member/";
private final static String disableProject = prefix + "/disable/";
private final static String enableProject = prefix + "/enable/";
private final static String userList = prefix + "/user-list";
private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest();
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
@ -669,4 +670,12 @@ public class SystemProjectControllerTests extends BaseTest {
this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER);
}
@Test
@Order(21)
public void testUserList() throws Exception {
this.requestGetWithOkAndReturn(userList);
// @@校验权限
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList);
}
}