fix(工作台): 修复工作台一些数据显示问题的bug
This commit is contained in:
parent
6477bca961
commit
b36f2825a7
|
@ -17,11 +17,13 @@ import io.metersphere.project.service.PermissionCheckService;
|
|||
import io.metersphere.sdk.constants.PermissionConstants;
|
||||
import io.metersphere.sdk.exception.MSException;
|
||||
import io.metersphere.system.dto.sdk.TemplateCustomFieldDTO;
|
||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||
import io.metersphere.system.security.CheckOwner;
|
||||
import io.metersphere.system.utils.PageUtils;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import io.metersphere.system.utils.SessionUtils;
|
||||
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.springframework.validation.annotation.Validated;
|
||||
|
@ -48,7 +50,7 @@ public class DashboardController {
|
|||
@PostMapping("/layout/edit/{organizationId}")
|
||||
@Operation(summary = "编辑用户布局")
|
||||
@CheckOwner(resourceId = "#organizationId", resourceType = "organization")
|
||||
public List<LayoutDTO> editLayout(@PathVariable String organizationId, @Validated @RequestBody List<LayoutDTO> layoutDTO) {
|
||||
public List<LayoutDTO> editLayout(@PathVariable String organizationId, @RequestBody List<LayoutDTO> layoutDTO ) {
|
||||
return dashboardService.editLayout(organizationId, SessionUtils.getUserId(), layoutDTO);
|
||||
}
|
||||
|
||||
|
@ -94,6 +96,15 @@ public class DashboardController {
|
|||
return dashboardService.getBugHandleUserList(projectId);
|
||||
}
|
||||
|
||||
@GetMapping("/member/get-project-member/option/{projectId}")
|
||||
@Operation(summary = "获取项目成员列表")
|
||||
@CheckOwner(resourceId = "#projectId", resourceType = "project")
|
||||
public List<UserExtendDTO> getMemberOption(@PathVariable String projectId,
|
||||
@Schema(description = "查询关键字,根据邮箱和用户名查询")
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
return dashboardService.getMemberOption(projectId, keyword);
|
||||
}
|
||||
|
||||
@PostMapping("/case_count")
|
||||
@Operation(summary = "用例数")
|
||||
@CheckOwner(resourceId = "#request.getOrganizationId()", resourceType = "organization")
|
||||
|
|
|
@ -5,12 +5,17 @@ import lombok.AllArgsConstructor;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LayoutDTO {
|
||||
public class LayoutDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "布局卡片id")
|
||||
private String id;
|
||||
@Schema(description = "布局卡片key")
|
||||
|
|
|
@ -59,7 +59,9 @@ import io.metersphere.system.domain.UserLayoutExample;
|
|||
import io.metersphere.system.dto.ProtocolDTO;
|
||||
import io.metersphere.system.dto.sdk.OptionDTO;
|
||||
import io.metersphere.system.dto.user.ProjectUserMemberDTO;
|
||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||
import io.metersphere.system.mapper.ExtExecTaskItemMapper;
|
||||
import io.metersphere.system.mapper.ExtSystemProjectMapper;
|
||||
import io.metersphere.system.mapper.UserLayoutMapper;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import io.metersphere.system.utils.PageUtils;
|
||||
|
@ -127,6 +129,8 @@ public class DashboardService {
|
|||
private CaseReviewService caseReviewService;
|
||||
@Resource
|
||||
private ApiTestService apiTestService;
|
||||
@Resource
|
||||
private ExtSystemProjectMapper extSystemProjectMapper;
|
||||
|
||||
|
||||
public static final String FUNCTIONAL = "FUNCTIONAL"; // 功能用例
|
||||
|
@ -366,10 +370,10 @@ public class DashboardService {
|
|||
}
|
||||
|
||||
public List<LayoutDTO> getLayout(String organizationId, String userId) {
|
||||
List<Project> allPermissionProjects = projectService.getUserProject(organizationId, userId);
|
||||
UserLayoutExample userLayoutExample = new UserLayoutExample();
|
||||
userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId);
|
||||
List<UserLayout> userLayouts = userLayoutMapper.selectByExampleWithBLOBs(userLayoutExample);
|
||||
List<Project>allPermissionProjects = extProjectMapper.getProjectNameModule(organizationId, null);
|
||||
if (CollectionUtils.isEmpty(allPermissionProjects)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -379,6 +383,9 @@ public class DashboardService {
|
|||
UserLayout userLayout = userLayouts.getFirst();
|
||||
byte[] configuration = userLayout.getConfiguration();
|
||||
String layoutDTOStr = new String(configuration);
|
||||
if (StringUtils.isBlank(layoutDTOStr)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<LayoutDTO> layoutDTOS = JSON.parseArray(layoutDTOStr, LayoutDTO.class);
|
||||
Map<String, Set<String>> permissionModuleProjectIdMap = dashboardProjectService.getPermissionModuleProjectIds(allPermissionProjects, userId);
|
||||
List<ProjectUserMemberDTO> orgProjectMemberList = extProjectMemberMapper.getOrgProjectMemberList(organizationId, null);
|
||||
|
@ -1399,6 +1406,14 @@ public class DashboardService {
|
|||
statisticsDTO.setStatusPercentList(statusPercentList);
|
||||
return statisticsDTO;
|
||||
}
|
||||
|
||||
public List<UserExtendDTO> getMemberOption(String projectId, String keyword) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
if (project == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return extSystemProjectMapper.getMemberByProjectId(projectId, keyword);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import io.metersphere.sdk.util.JSON;
|
|||
import io.metersphere.system.base.BasePluginTestService;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.dto.user.UserExtendDTO;
|
||||
import io.metersphere.system.utils.Pager;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
@ -101,6 +102,8 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
private static final String API_CHANGE = "/dashboard/api_change";
|
||||
private static final String BUG_HANDLE_USER_LIST = "/dashboard/bug_handle_user/list/";
|
||||
|
||||
private static final String PROJECT_MEMBER_USER_LIST = "/dashboard/member/get-project-member/option/";
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
@Sql(scripts = {"/dml/init_dashboard.sql"}, config = @SqlConfig(encoding = "utf-8", transactionMode = SqlConfig.TransactionMode.ISOLATED))
|
||||
|
@ -202,11 +205,7 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
@Test
|
||||
@Order(2)
|
||||
public void testLayout() throws Exception {
|
||||
MvcResult mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + "DEFAULT_ORGANIZATION_ID");
|
||||
String contentAsString = mvcResultGrt.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
List<LayoutDTO> layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class);
|
||||
Assertions.assertEquals(0, layoutDTOS.size());
|
||||
this.requestGet(GET_LAYOUT + "DEFAULT_ORGANIZATION_ID").andExpect(status().is5xxServerError());
|
||||
|
||||
ProjectExample projectExample = new ProjectExample();
|
||||
projectExample.createCriteria().andOrganizationIdEqualTo(DEFAULT_ORGANIZATION_ID);
|
||||
|
@ -261,12 +260,12 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
layoutDTO1.setFullScreen(false);
|
||||
layoutDTO.add(layoutDTO1);
|
||||
MvcResult mvcResult = this.requestPostWithOkAndReturn(EDIT_LAYOUT + DEFAULT_ORGANIZATION_ID, layoutDTO);
|
||||
contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class);
|
||||
String contentAsString = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
List<LayoutDTO>layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class);
|
||||
Assertions.assertNotNull(layoutDTOS);
|
||||
|
||||
mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + DEFAULT_ORGANIZATION_ID);
|
||||
MvcResult mvcResultGrt = this.requestGetWithOkAndReturn(GET_LAYOUT + DEFAULT_ORGANIZATION_ID);
|
||||
contentAsString = mvcResultGrt.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(contentAsString, ResultHolder.class);
|
||||
layoutDTOS = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), LayoutDTO.class);
|
||||
|
@ -546,6 +545,22 @@ public class DashboardFrontPageControllerTests extends BaseTest {
|
|||
Assertions.assertNotNull(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(6)
|
||||
public void testProjectUserList() throws Exception {
|
||||
MvcResult mvcResult = this.requestGetWithOkAndReturn(PROJECT_MEMBER_USER_LIST + DEFAULT_PROJECT_ID);
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
List<UserExtendDTO> list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), UserExtendDTO.class);
|
||||
Assertions.assertNotNull(list);
|
||||
|
||||
mvcResult = this.requestGetWithOkAndReturn(PROJECT_MEMBER_USER_LIST + "id");
|
||||
returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
list = JSON.parseArray(JSON.toJSONString(resultHolder.getData()), UserExtendDTO.class);
|
||||
Assertions.assertNotNull(list);
|
||||
}
|
||||
|
||||
private void enableDefaultPlatformConfig() {
|
||||
ProjectApplication record = new ProjectApplication();
|
||||
record.setTypeValue("true");
|
||||
|
|
|
@ -82,7 +82,6 @@ public interface ExtTestPlanMapper {
|
|||
@BaseConditionFilter
|
||||
List<TestPlanResponse> selectMyFollowByConditions(@Param("request") TestPlanTableRequest request);
|
||||
|
||||
List<TestPlan> getSimpleTestPlanList(@Param("projectId") String projectId, @Param("startTime") Long startTime, @Param("endTime") Long endTime);
|
||||
|
||||
/**
|
||||
* 获取项目下的计划关联缺陷
|
||||
|
|
|
@ -789,6 +789,7 @@
|
|||
<if test="userId != null and userId != ''">
|
||||
AND test_plan.create_user = #{userId}
|
||||
</if>
|
||||
AND test_plan.type = 'TEST_PLAN'
|
||||
group by test_plan.project_id;
|
||||
</select>
|
||||
|
||||
|
@ -806,6 +807,7 @@
|
|||
#{userId}
|
||||
</foreach>
|
||||
</if>
|
||||
AND test_plan.type = 'TEST_PLAN'
|
||||
group by test_plan.create_user;
|
||||
</select>
|
||||
|
||||
|
@ -860,14 +862,7 @@
|
|||
) t
|
||||
</select>
|
||||
|
||||
<select id="getSimpleTestPlanList" resultType="io.metersphere.plan.domain.TestPlan">
|
||||
SELECT test_plan.id, test_plan.status
|
||||
FROM test_plan
|
||||
WHERE test_plan.project_id = #{projectId}
|
||||
<if test="startTime != null and endTime != null">
|
||||
AND test_plan.create_time BETWEEN #{startTime} AND #{endTime}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectIdAndStatusByProjectIdAndCreateTimeRangeAndType" resultType="io.metersphere.plan.domain.TestPlan">
|
||||
SELECT id, status
|
||||
FROM test_plan
|
||||
|
|
|
@ -44,7 +44,11 @@ const transform: AxiosTransform = {
|
|||
config.url += params;
|
||||
config.params = undefined;
|
||||
} else {
|
||||
if (Reflect.has(config, 'data') && config.data && Object.keys(config.data).length > 0) {
|
||||
if (
|
||||
Reflect.has(config, 'data') &&
|
||||
config.data &&
|
||||
(Object.keys(config.data).length > 0 || Array.isArray(config.data))
|
||||
) {
|
||||
config.data = data;
|
||||
config.params = params;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue