refactor(系统设置): 系统日志-查询用户接口支持远程搜索
This commit is contained in:
parent
fecf72d108
commit
9c555775a6
|
@ -16,6 +16,7 @@ import io.metersphere.system.service.OrganizationService;
|
|||
import io.metersphere.system.service.SystemProjectService;
|
||||
import io.metersphere.system.service.UserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -74,8 +75,9 @@ public class OperationLogController {
|
|||
@GetMapping("/user/list")
|
||||
@Operation(summary = "系统设置-系统-日志-系统日志页面,获取用户列表")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_LOG_READ)
|
||||
public List<User> getUserList() {
|
||||
List<User> userList = userService.getUserList();
|
||||
public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
List<User> userList = userService.getUserList(keyword);
|
||||
return userList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,7 @@ import com.github.pagehelper.Page;
|
|||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.log.annotation.Log;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
|
@ -149,8 +146,9 @@ public class SystemProjectController {
|
|||
@GetMapping("/user-list")
|
||||
@Operation(summary = "系统设置-系统-组织与项目-项目-系统-组织及项目, 获取管理员下拉选项")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ)
|
||||
public List<User> getUserList() {
|
||||
return userService.getUserList();
|
||||
public List<User> getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return userService.getUserList(keyword);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,4 +11,6 @@ public interface ExtUserMapper {
|
|||
List<UserExtend> getMemberOption(String sourceId);
|
||||
|
||||
List<User> getUserListByOrgId(@Param("sourceId") String sourceId);
|
||||
|
||||
List<User> selectUserList(@Param("keyword") String keyword);
|
||||
}
|
||||
|
|
|
@ -19,4 +19,22 @@
|
|||
WHERE
|
||||
urr.source_id = #{sourceId} and u.deleted = false
|
||||
</select>
|
||||
|
||||
<select id="selectUserList" resultType="io.metersphere.system.domain.User">
|
||||
SELECT DISTINCT
|
||||
u.id,
|
||||
u.NAME,
|
||||
u.email
|
||||
FROM
|
||||
`user` u
|
||||
WHERE
|
||||
u.deleted = false
|
||||
<if test="keyword != null and keyword != ''">
|
||||
and (LOCATE(#{keyword},name)>0 or LOCATE(#{keyword},email)>0)
|
||||
</if>
|
||||
order by u.create_time desc
|
||||
limit 100
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -297,11 +297,8 @@ public class UserService {
|
|||
return insertIndex;
|
||||
}
|
||||
|
||||
public List<User> getUserList() {
|
||||
UserExample example = new UserExample();
|
||||
example.createCriteria().andDeletedEqualTo(false);
|
||||
example.setOrderByClause("update_time desc");
|
||||
return userMapper.selectByExample(example);
|
||||
public List<User> getUserList(String keyword) {
|
||||
return extUserMapper.selectUserList(keyword.trim());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -138,10 +138,11 @@ public class OperationLogControllerTests extends BaseTest {
|
|||
@Test
|
||||
@Order(3)
|
||||
public void testUserList() throws Exception {
|
||||
this.requestGetWithOkAndReturn(USER_LIST);
|
||||
String keyword = "a";
|
||||
this.requestGetWithOkAndReturn(USER_LIST + "?keyword=" + keyword);
|
||||
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_LOG_READ, USER_LIST);
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_LOG_READ, USER_LIST + "?keyword=" + keyword);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -8,10 +8,7 @@ import io.metersphere.sdk.constants.InternalUserRole;
|
|||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.controller.handler.ResultHolder;
|
||||
import io.metersphere.sdk.dto.AddProjectRequest;
|
||||
import io.metersphere.sdk.dto.ProjectDTO;
|
||||
import io.metersphere.sdk.dto.ProjectExtendDTO;
|
||||
import io.metersphere.sdk.dto.UpdateProjectRequest;
|
||||
import io.metersphere.sdk.dto.*;
|
||||
import io.metersphere.sdk.log.constants.OperationLogType;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
|
@ -708,9 +705,10 @@ public class SystemProjectControllerTests extends BaseTest {
|
|||
@Test
|
||||
@Order(21)
|
||||
public void testUserList() throws Exception {
|
||||
this.requestGetWithOkAndReturn(userList);
|
||||
String keyword = "a";
|
||||
this.requestGetWithOkAndReturn(userList + "?keyword=" + keyword);
|
||||
|
||||
// @@校验权限
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList);
|
||||
requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList + "?keyword=" + keyword);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue