feat(系统设置): 日志接口-组织菜单日志
This commit is contained in:
parent
78948351a1
commit
57c6b654df
|
@ -8,6 +8,7 @@
|
|||
t.organization_id,
|
||||
t.create_time,
|
||||
t.create_user,
|
||||
t.source_id,
|
||||
t.module,
|
||||
t.type,
|
||||
t.content
|
||||
|
@ -42,10 +43,12 @@
|
|||
AND t.type = #{request.type}
|
||||
</if>
|
||||
<if test="request.module != null and request.module != ''">
|
||||
AND t.module = #{request.module}
|
||||
<bind name="module" value="request.module+'%'"/>
|
||||
AND t.module like #{module}
|
||||
</if>
|
||||
<if test="request.content != null and request.content != ''">
|
||||
AND t.content like CONCAT('%', #{request.content},'%')
|
||||
<bind name="content" value="'%'+request.content+'%'"/>
|
||||
AND t.content like #{content}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY t.create_time DESC
|
||||
|
|
|
@ -51,7 +51,7 @@ public class OperationLogController {
|
|||
//获取全部组织
|
||||
List<OrganizationProjectOptionsDTO> organizationList = organizationService.getOrganizationOptions();
|
||||
//获取全部项目
|
||||
List<OrganizationProjectOptionsDTO> projectList = systemProjectService.getProjectOptions();
|
||||
List<OrganizationProjectOptionsDTO> projectList = systemProjectService.getProjectOptions(null);
|
||||
|
||||
OrganizationProjectOptionsResponse optionsResponse = new OrganizationProjectOptionsResponse();
|
||||
optionsResponse.setOrganizationList(organizationList);
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.log.service.OperationLogService;
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.sdk.log.vo.OperationLogResponse;
|
||||
import io.metersphere.sdk.util.PageUtils;
|
||||
import io.metersphere.sdk.util.Pager;
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.OrganizationProjectOptionsDTO;
|
||||
import io.metersphere.system.dto.response.OrganizationProjectOptionsResponse;
|
||||
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.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author wx
|
||||
*/
|
||||
@Tag(name = "组织日志")
|
||||
@RestController
|
||||
@RequestMapping("/organization/log")
|
||||
public class OrganizationLogController {
|
||||
|
||||
@Resource
|
||||
private SystemProjectService systemProjectService;
|
||||
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
|
||||
@GetMapping("/get/options/{organizationId}")
|
||||
@Operation(summary = "组织日志-获取项目级联下拉框选项")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_OPERATING_LOG_READ)
|
||||
public OrganizationProjectOptionsResponse getOrganizationOptions(@PathVariable(value = "organizationId") String organizationId) {
|
||||
//获取全部项目
|
||||
List<OrganizationProjectOptionsDTO> projectList = systemProjectService.getProjectOptions(organizationId);
|
||||
OrganizationProjectOptionsResponse optionsResponse = new OrganizationProjectOptionsResponse();
|
||||
optionsResponse.setProjectList(projectList);
|
||||
|
||||
return optionsResponse;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/user/list/{organizationId}")
|
||||
@Operation(summary = "组织日志-获取用户列表")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_OPERATING_LOG_READ)
|
||||
public List<User> getLogUserList(@PathVariable(value = "organizationId") String organizationId) {
|
||||
return userService.getUserListByOrgId(organizationId);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/list")
|
||||
@Operation(summary = "组织菜单下操作日志列表查询")
|
||||
@RequiresPermissions(PermissionConstants.ORGANIZATION_OPERATING_LOG_READ)
|
||||
public Pager<List<OperationLogResponse>> organizationLogList(@Validated @RequestBody OperationLogRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(),
|
||||
StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "create_time desc");
|
||||
return PageUtils.setPageInfo(page, operationLogService.list(request));
|
||||
}
|
||||
|
||||
}
|
|
@ -18,5 +18,5 @@ public interface ExtSystemProjectMapper {
|
|||
|
||||
List<User> getProjectAdminList(String projectId);
|
||||
|
||||
List<OrganizationProjectOptionsDTO> selectProjectOptions();
|
||||
List<OrganizationProjectOptionsDTO> selectProjectOptions(@Param("organizationId") String organizationId);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,14 @@
|
|||
|
||||
|
||||
<select id="selectProjectOptions" resultType="io.metersphere.system.dto.OrganizationProjectOptionsDTO">
|
||||
select id, name from project order by create_time desc
|
||||
select id, name
|
||||
from project
|
||||
<where>
|
||||
<if test="organizationId != null and organizationId != ''">
|
||||
and organization_id = #{organizationId}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<sql id="queryWhereCondition">
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.system.domain.User;
|
||||
import io.metersphere.system.dto.UserExtend;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtUserMapper {
|
||||
|
||||
List<UserExtend> getMemberOption(String sourceId);
|
||||
|
||||
List<User> getUserListByOrgId(@Param("sourceId") String sourceId);
|
||||
}
|
||||
|
|
|
@ -6,4 +6,15 @@
|
|||
from `user` u left join user_role_relation urr on urr.user_id = u.id and urr.source_id = #{sourceId}
|
||||
group by u.id
|
||||
</select>
|
||||
|
||||
<select id="getUserListByOrgId" resultType="io.metersphere.system.domain.User">
|
||||
SELECT DISTINCT
|
||||
u.id,
|
||||
u.NAME
|
||||
FROM
|
||||
`user` u
|
||||
LEFT JOIN user_role_relation urr ON u.id = urr.user_id
|
||||
WHERE
|
||||
urr.source_id = #{sourceId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -87,8 +87,8 @@ public class SystemProjectService {
|
|||
commonProjectService.deleteProject(projects);
|
||||
}
|
||||
|
||||
public List<OrganizationProjectOptionsDTO> getProjectOptions() {
|
||||
return extSystemProjectMapper.selectProjectOptions();
|
||||
public List<OrganizationProjectOptionsDTO> getProjectOptions(String organizationId) {
|
||||
return extSystemProjectMapper.selectProjectOptions(organizationId);
|
||||
}
|
||||
|
||||
public void enable(String id) {
|
||||
|
|
|
@ -476,4 +476,8 @@ public class UserService {
|
|||
return request.getUserIds();
|
||||
}
|
||||
}
|
||||
|
||||
public List<User> getUserListByOrgId(String organizationId) {
|
||||
return extUserMapper.getUserListByOrgId(organizationId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.sdk.base.BaseTest;
|
||||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.log.vo.OperationLogRequest;
|
||||
import io.metersphere.system.controller.param.OperationLogRequestDefinition;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class OrganizationLogControllerTests extends BaseTest {
|
||||
|
||||
public static final String ORGANIZATION = "ORGANIZATION";
|
||||
public static final String ORGANIZATION_OPTIONS_LIST = "/organization/log/get/options";
|
||||
public static final String ORGANIZATION_USER_LIST = "/organization/log/user/list";
|
||||
public static final String ORGANIZATION_LOG_LIST = "/organization/log/list";
|
||||
|
||||
|
||||
/**
|
||||
* 组织菜单-操作日志接口 测试用例
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Order(1)
|
||||
public void testGetOrganizationOptions() throws Exception {
|
||||
this.requestGetWithOkAndReturn(ORGANIZATION_OPTIONS_LIST + "/organization_id_001");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testOrganizationUserList() throws Exception {
|
||||
this.requestGetWithOkAndReturn(ORGANIZATION_USER_LIST + "/organization_id_001");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Order(3)
|
||||
public void testOrganizationLogList() throws Exception {
|
||||
OperationLogRequest request = buildParam(ORGANIZATION);
|
||||
//项目级别 全部
|
||||
this.requestPostWithOkAndReturn(ORGANIZATION_LOG_LIST, request);
|
||||
|
||||
//其他查询条件
|
||||
request.setOperUser("admin");
|
||||
request.setType("add");
|
||||
request.setModule("SYSTEM_PARAMETER_SETTING");
|
||||
request.setContent("认证配置");
|
||||
this.requestPostWithOkAndReturn(ORGANIZATION_LOG_LIST, request);
|
||||
|
||||
//项目级别 指定项目查询
|
||||
request.setProjectIds(Arrays.asList("project_id_001", "project_id_002"));
|
||||
request.setSort(new HashMap<>() {{
|
||||
put("createTime", "desc");
|
||||
}});
|
||||
|
||||
this.requestPostWithOkAndReturn(ORGANIZATION_LOG_LIST, request);
|
||||
// @@异常参数校验
|
||||
updatedGroupParamValidateTest(OperationLogRequestDefinition.class, ORGANIZATION_LOG_LIST);
|
||||
|
||||
requestPostPermissionTest(PermissionConstants.ORGANIZATION_OPERATING_LOG_READ, ORGANIZATION_LOG_LIST, request);
|
||||
|
||||
}
|
||||
|
||||
private OperationLogRequest buildParam(String level) {
|
||||
OperationLogRequest request = new OperationLogRequest();
|
||||
request.setCurrent(1);
|
||||
request.setPageSize(10);
|
||||
request.setStartTime(1689131059000l);
|
||||
request.setEndTime(1689149059000l);
|
||||
request.setLevel(level);
|
||||
return request;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue