refactor(接口测试): 优化接口测试执行过程中的部分对用户操作的步骤
优化接口测试执行过程中的部分对用户操作的步骤,避免一次性查出数据库中的全部用户信息
This commit is contained in:
parent
3db9e9374c
commit
7d85370e86
|
@ -70,7 +70,6 @@ public class ShareInfoService {
|
||||||
|
|
||||||
public Pager<List<ApiDocumentInfoDTO>> selectApiInfoByParam(ApiDocumentRequest apiDocumentRequest, int goPage, int pageSize) {
|
public Pager<List<ApiDocumentInfoDTO>> selectApiInfoByParam(ApiDocumentRequest apiDocumentRequest, int goPage, int pageSize) {
|
||||||
this.iniApiDocumentRequest(apiDocumentRequest);
|
this.iniApiDocumentRequest(apiDocumentRequest);
|
||||||
Map<String, User> userIdMap = userService.queryName();
|
|
||||||
|
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
List<ApiDefinitionWithBLOBs> apiDocumentInfoDTOS = new ArrayList<>();
|
List<ApiDefinitionWithBLOBs> apiDocumentInfoDTOS = new ArrayList<>();
|
||||||
|
@ -81,14 +80,22 @@ public class ShareInfoService {
|
||||||
|
|
||||||
List<String> apiModuleIdList = new ArrayList<>();
|
List<String> apiModuleIdList = new ArrayList<>();
|
||||||
LogUtil.info("查找模块相关信息");
|
LogUtil.info("查找模块相关信息");
|
||||||
|
List<String> userIdList = new ArrayList<>();
|
||||||
apiDocumentInfoDTOS.forEach(item -> {
|
apiDocumentInfoDTOS.forEach(item -> {
|
||||||
if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(item.getModuleId())) {
|
if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(item.getModuleId())) {
|
||||||
apiModuleIdList.add(item.getModuleId());
|
apiModuleIdList.add(item.getModuleId());
|
||||||
|
if (!userIdList.contains(item.getUserId())) {
|
||||||
|
userIdList.add(item.getUserId());
|
||||||
|
}
|
||||||
|
if (!userIdList.contains(item.getCreateUser())) {
|
||||||
|
userIdList.add(item.getCreateUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Map<String, User> seletedUserMap = userService.getUserIdMapByIds(userIdList);
|
||||||
Map<String, String> moduleNameMap = apiModuleService.getApiModuleNameDicByIds(apiModuleIdList);
|
Map<String, String> moduleNameMap = apiModuleService.getApiModuleNameDicByIds(apiModuleIdList);
|
||||||
LogUtil.info("开始遍历组装数据");
|
LogUtil.info("开始遍历组装数据");
|
||||||
List<ApiDocumentInfoDTO> returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, userIdMap, moduleNameMap);
|
List<ApiDocumentInfoDTO> returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, seletedUserMap, moduleNameMap);
|
||||||
|
|
||||||
return PageUtils.setPageInfo(page, returnList);
|
return PageUtils.setPageInfo(page, returnList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,6 @@ public interface ExtUserMapper {
|
||||||
@MapKey("id")
|
@MapKey("id")
|
||||||
Map<String, User> queryNameByIds(List<String> userIds);
|
Map<String, User> queryNameByIds(List<String> userIds);
|
||||||
|
|
||||||
@MapKey("id")
|
|
||||||
Map<String, User> queryName();
|
|
||||||
|
|
||||||
List<String> selectAllId();
|
List<String> selectAllId();
|
||||||
|
|
||||||
List<String> selectIdsByQuery(@Param("request") UserRequest request);
|
List<String> selectIdsByQuery(@Param("request") UserRequest request);
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</if>
|
</if>
|
||||||
<if test="userRequest.name != null">
|
<if test="userRequest.name != null">
|
||||||
AND (u.name like CONCAT('%', #{userRequest.name},'%')
|
AND (u.name like CONCAT('%', #{userRequest.name},'%')
|
||||||
or u.id like CONCAT('%', #{userRequest.name},'%'))
|
or u.id like CONCAT('%', #{userRequest.name},'%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="userRequest.email != null">
|
<if test="userRequest.email != null">
|
||||||
AND u.email like CONCAT('%', #{userRequest.email},'%')
|
AND u.email like CONCAT('%', #{userRequest.email},'%')
|
||||||
|
@ -73,19 +73,22 @@
|
||||||
|
|
||||||
<!--修改密码-->
|
<!--修改密码-->
|
||||||
<update id="updatePassword" parameterType="io.metersphere.base.domain.User">
|
<update id="updatePassword" parameterType="io.metersphere.base.domain.User">
|
||||||
update user
|
update user
|
||||||
set
|
set password=#{password,jdbcType=VARCHAR},
|
||||||
password=#{password,jdbcType=VARCHAR},
|
update_time = #{updateTime,jdbcType=BIGINT}
|
||||||
update_time = #{updateTime,jdbcType=BIGINT}
|
where id = #{id,jdbcType=VARCHAR}
|
||||||
where id=#{id,jdbcType=VARCHAR}
|
</update>
|
||||||
</update>
|
|
||||||
<select id="getDefaultLanguage" parameterType="java.lang.String" resultType="java.lang.String">
|
<select id="getDefaultLanguage" parameterType="java.lang.String" resultType="java.lang.String">
|
||||||
select param_value from system_parameter
|
select param_value
|
||||||
where param_key=#{paramKey,jdbcType=VARCHAR}
|
from system_parameter
|
||||||
</select>
|
where param_key = #{paramKey,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="searchUser" parameterType="java.lang.String" resultType="io.metersphere.base.domain.User">
|
<select id="searchUser" parameterType="java.lang.String" resultType="io.metersphere.base.domain.User">
|
||||||
select id, name, email, last_workspace_id from `user` where id like CONCAT('%', #{condition},'%') or email like CONCAT('%', #{condition},'%') limit 100;
|
select id, name, email, last_workspace_id
|
||||||
|
from `user`
|
||||||
|
where id like CONCAT('%', #{condition}, '%')
|
||||||
|
or email like CONCAT('%', #{condition}, '%') limit 100;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryNameByIds" resultType="io.metersphere.base.domain.User">
|
<select id="queryNameByIds" resultType="io.metersphere.base.domain.User">
|
||||||
|
@ -98,13 +101,9 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="queryName" resultType="io.metersphere.base.domain.User">
|
|
||||||
select id, name
|
|
||||||
from `user`
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectAllId" resultType="java.lang.String">
|
<select id="selectAllId" resultType="java.lang.String">
|
||||||
select id from `user`
|
select id
|
||||||
|
from `user`
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectIdsByQuery" resultType="java.lang.String">
|
<select id="selectIdsByQuery" resultType="java.lang.String">
|
||||||
|
@ -114,12 +113,16 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateLastProjectIdIfNull">
|
<update id="updateLastProjectIdIfNull">
|
||||||
update user set last_project_id = #{projectId} where id = #{userId}
|
update user
|
||||||
and (last_project_id is null or last_project_id = '')
|
set last_project_id = #{projectId}
|
||||||
|
where id = #{userId}
|
||||||
|
and (last_project_id is null or last_project_id = '')
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateLastWorkspaceIdIfNull">
|
<update id="updateLastWorkspaceIdIfNull">
|
||||||
update user set last_workspace_id = #{workspaceId} where id = #{userId}
|
update user
|
||||||
and (last_workspace_id is null or last_workspace_id = '')
|
set last_workspace_id = #{workspaceId}
|
||||||
|
where id = #{userId}
|
||||||
|
and (last_workspace_id is null or last_workspace_id = '')
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
|
@ -101,10 +101,6 @@ public class UserService {
|
||||||
return extUserMapper.queryNameByIds(userIds);
|
return extUserMapper.queryNameByIds(userIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, User> queryName() {
|
|
||||||
return extUserMapper.queryName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserDTO insert(UserRequest userRequest) {
|
public UserDTO insert(UserRequest userRequest) {
|
||||||
checkUserParam(userRequest);
|
checkUserParam(userRequest);
|
||||||
String id = userRequest.getId();
|
String id = userRequest.getId();
|
||||||
|
@ -1502,4 +1498,12 @@ public class UserService {
|
||||||
public List<User> getProjectMemberOption(String projectId) {
|
public List<User> getProjectMemberOption(String projectId) {
|
||||||
return extUserGroupMapper.getProjectMemberOption(projectId);
|
return extUserGroupMapper.getProjectMemberOption(projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, User> getUserIdMapByIds(List<String> userIdList) {
|
||||||
|
return extUserMapper.queryNameByIds(userIdList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public User selectById(String id) {
|
||||||
|
return userMapper.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue