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) {
|
||||
this.iniApiDocumentRequest(apiDocumentRequest);
|
||||
Map<String, User> userIdMap = userService.queryName();
|
||||
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<ApiDefinitionWithBLOBs> apiDocumentInfoDTOS = new ArrayList<>();
|
||||
|
@ -81,14 +80,22 @@ public class ShareInfoService {
|
|||
|
||||
List<String> apiModuleIdList = new ArrayList<>();
|
||||
LogUtil.info("查找模块相关信息");
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
apiDocumentInfoDTOS.forEach(item -> {
|
||||
if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(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);
|
||||
LogUtil.info("开始遍历组装数据");
|
||||
List<ApiDocumentInfoDTO> returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, userIdMap, moduleNameMap);
|
||||
List<ApiDocumentInfoDTO> returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, seletedUserMap, moduleNameMap);
|
||||
|
||||
return PageUtils.setPageInfo(page, returnList);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,6 @@ public interface ExtUserMapper {
|
|||
@MapKey("id")
|
||||
Map<String, User> queryNameByIds(List<String> userIds);
|
||||
|
||||
@MapKey("id")
|
||||
Map<String, User> queryName();
|
||||
|
||||
List<String> selectAllId();
|
||||
|
||||
List<String> selectIdsByQuery(@Param("request") UserRequest request);
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</if>
|
||||
<if test="userRequest.name != null">
|
||||
AND (u.name like CONCAT('%', #{userRequest.name},'%')
|
||||
or u.id like CONCAT('%', #{userRequest.name},'%'))
|
||||
or u.id like CONCAT('%', #{userRequest.name},'%'))
|
||||
</if>
|
||||
<if test="userRequest.email != null">
|
||||
AND u.email like CONCAT('%', #{userRequest.email},'%')
|
||||
|
@ -73,19 +73,22 @@
|
|||
|
||||
<!--修改密码-->
|
||||
<update id="updatePassword" parameterType="io.metersphere.base.domain.User">
|
||||
update user
|
||||
set
|
||||
password=#{password,jdbcType=VARCHAR},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
where id=#{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
update user
|
||||
set password=#{password,jdbcType=VARCHAR},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<select id="getDefaultLanguage" parameterType="java.lang.String" resultType="java.lang.String">
|
||||
select param_value from system_parameter
|
||||
where param_key=#{paramKey,jdbcType=VARCHAR}
|
||||
</select>
|
||||
select param_value
|
||||
from system_parameter
|
||||
where param_key = #{paramKey,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<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 id="queryNameByIds" resultType="io.metersphere.base.domain.User">
|
||||
|
@ -98,13 +101,9 @@
|
|||
</foreach>
|
||||
</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 from `user`
|
||||
select id
|
||||
from `user`
|
||||
</select>
|
||||
|
||||
<select id="selectIdsByQuery" resultType="java.lang.String">
|
||||
|
@ -114,12 +113,16 @@
|
|||
</select>
|
||||
|
||||
<update id="updateLastProjectIdIfNull">
|
||||
update user set last_project_id = #{projectId} where id = #{userId}
|
||||
and (last_project_id is null or last_project_id = '')
|
||||
update user
|
||||
set last_project_id = #{projectId}
|
||||
where id = #{userId}
|
||||
and (last_project_id is null or last_project_id = '')
|
||||
</update>
|
||||
|
||||
<update id="updateLastWorkspaceIdIfNull">
|
||||
update user set last_workspace_id = #{workspaceId} where id = #{userId}
|
||||
and (last_workspace_id is null or last_workspace_id = '')
|
||||
update user
|
||||
set last_workspace_id = #{workspaceId}
|
||||
where id = #{userId}
|
||||
and (last_workspace_id is null or last_workspace_id = '')
|
||||
</update>
|
||||
</mapper>
|
|
@ -101,10 +101,6 @@ public class UserService {
|
|||
return extUserMapper.queryNameByIds(userIds);
|
||||
}
|
||||
|
||||
public Map<String, User> queryName() {
|
||||
return extUserMapper.queryName();
|
||||
}
|
||||
|
||||
public UserDTO insert(UserRequest userRequest) {
|
||||
checkUserParam(userRequest);
|
||||
String id = userRequest.getId();
|
||||
|
@ -1502,4 +1498,12 @@ public class UserService {
|
|||
public List<User> getProjectMemberOption(String 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