refactor(接口测试): 优化获取本地时区

This commit is contained in:
wxg0103 2024-06-25 15:49:03 +08:00 committed by 刘瑞斌
parent 99b1b4eb48
commit 748eef36b5
3 changed files with 156 additions and 149 deletions

View File

@ -107,7 +107,7 @@ public class ApiReportShareService {
public ShareInfoDTO gen(ApiReportShareRequest shareRequest, String userId) { public ShareInfoDTO gen(ApiReportShareRequest shareRequest, String userId) {
UserDTO userDTO = baseUserMapper.selectById(userId); UserDTO userDTO = baseUserMapper.selectById(userId);
String lang = userDTO.getLanguage() == null ? LocaleContextHolder.getLocale().toString() : userDTO.getLanguage(); String lang = userDTO.getLanguage() == null ? LocaleContextHolder.getLocale().toString().split("_#")[0] : userDTO.getLanguage();
ShareInfo request = new ShareInfo(); ShareInfo request = new ShareInfo();
BeanUtils.copyBean(request, shareRequest); BeanUtils.copyBean(request, shareRequest);
request.setLang(lang); request.setLang(lang);

View File

@ -47,7 +47,7 @@ public class ApiShareService {
public ShareInfoDTO genApiDocShareInfo(ApiDefinitionDocRequest request, SessionUser user) { public ShareInfoDTO genApiDocShareInfo(ApiDefinitionDocRequest request, SessionUser user) {
ShareInfo shareInfoRequest = new ShareInfo(); ShareInfo shareInfoRequest = new ShareInfo();
String customData = genCustomData(request, shareInfoRequest); String customData = genCustomData(request, shareInfoRequest);
String lang = user.getLanguage() == null ? LocaleContextHolder.getLocale().toString() : user.getLanguage(); String lang = user.getLanguage() == null ? LocaleContextHolder.getLocale().toString().split("_#")[0] : user.getLanguage();
Optional.ofNullable(customData) Optional.ofNullable(customData)
.ifPresent(data -> { .ifPresent(data -> {

View File

@ -72,13 +72,14 @@ public class TestPlanReportShareService {
/** /**
* 生成计划报告分享信息 * 生成计划报告分享信息
*
* @param shareRequest 分享请求参数 * @param shareRequest 分享请求参数
* @param currentUser 当前用户 * @param currentUser 当前用户
* @return 计划报告分享信息 * @return 计划报告分享信息
*/ */
public TestPlanShareInfo gen(TestPlanReportShareRequest shareRequest, String currentUser) { public TestPlanShareInfo gen(TestPlanReportShareRequest shareRequest, String currentUser) {
UserDTO userDTO = baseUserMapper.selectById(currentUser); UserDTO userDTO = baseUserMapper.selectById(currentUser);
String lang = userDTO.getLanguage() == null ? LocaleContextHolder.getLocale().toString() : userDTO.getLanguage(); String lang = userDTO.getLanguage() == null ? LocaleContextHolder.getLocale().toString().split("_#")[0] : userDTO.getLanguage();
ShareInfo request = new ShareInfo(); ShareInfo request = new ShareInfo();
BeanUtils.copyBean(request, shareRequest); BeanUtils.copyBean(request, shareRequest);
request.setLang(lang); request.setLang(lang);
@ -91,6 +92,7 @@ public class TestPlanReportShareService {
/** /**
* 获取分享信息 * 获取分享信息
*
* @param id 分享ID * @param id 分享ID
* @return 分享信息 * @return 分享信息
*/ */
@ -122,6 +124,7 @@ public class TestPlanReportShareService {
/** /**
* 获取项目计划报告分享有效期 * 获取项目计划报告分享有效期
*
* @param projectId 项目ID * @param projectId 项目ID
* @return 有效期 * @return 有效期
*/ */
@ -138,6 +141,7 @@ public class TestPlanReportShareService {
/** /**
* 校验分享的资源是否存在 * 校验分享的资源是否存在
*
* @param id 分享ID * @param id 分享ID
* @return 分享资源信息 * @return 分享资源信息
*/ */
@ -151,6 +155,7 @@ public class TestPlanReportShareService {
/** /**
* 创建分享信息 * 创建分享信息
*
* @param shareInfo 分享的信息 * @param shareInfo 分享的信息
* @return 分享信息 * @return 分享信息
*/ */
@ -165,6 +170,7 @@ public class TestPlanReportShareService {
/** /**
* 设置分享信息并返回 * 设置分享信息并返回
*
* @param shareInfo 分享信息 * @param shareInfo 分享信息
* @return 计划报告分享信息返回 * @return 计划报告分享信息返回
*/ */
@ -180,6 +186,7 @@ public class TestPlanReportShareService {
/** /**
* 校验时间是否过期 * 校验时间是否过期
*
* @param compareMillis 比较时间 * @param compareMillis 比较时间
* @param millis 分享时间 * @param millis 分享时间
* @param shareInfoId 分享ID * @param shareInfoId 分享ID