Unverified Commit f6f19e33 authored by jianxing's avatar jianxing Committed by GitHub
Browse files

Merge branch 'dev' into pr@dev@fix_文件上传接口优化

parents 11efdbd5 a4c6d24e
Showing with 96 additions and 35 deletions
+96 -35
...@@ -11,6 +11,7 @@ import io.metersphere.api.dto.definition.request.MsScenario; ...@@ -11,6 +11,7 @@ import io.metersphere.api.dto.definition.request.MsScenario;
import io.metersphere.api.dto.definition.request.MsTestElement; import io.metersphere.api.dto.definition.request.MsTestElement;
import io.metersphere.api.dto.definition.request.assertions.*; import io.metersphere.api.dto.definition.request.assertions.*;
import io.metersphere.api.dto.definition.request.controller.MsLoopController; import io.metersphere.api.dto.definition.request.controller.MsLoopController;
import io.metersphere.api.dto.definition.request.controller.MsTransactionController;
import io.metersphere.api.dto.definition.request.controller.loop.CountController; import io.metersphere.api.dto.definition.request.controller.loop.CountController;
import io.metersphere.api.dto.definition.request.controller.loop.MsForEachController; import io.metersphere.api.dto.definition.request.controller.loop.MsForEachController;
import io.metersphere.api.dto.definition.request.controller.loop.MsWhileController; import io.metersphere.api.dto.definition.request.controller.loop.MsWhileController;
...@@ -53,6 +54,7 @@ import org.apache.jmeter.assertions.*; ...@@ -53,6 +54,7 @@ import org.apache.jmeter.assertions.*;
import org.apache.jmeter.config.ConfigTestElement; import org.apache.jmeter.config.ConfigTestElement;
import org.apache.jmeter.control.ForeachController; import org.apache.jmeter.control.ForeachController;
import org.apache.jmeter.control.LoopController; import org.apache.jmeter.control.LoopController;
import org.apache.jmeter.control.TransactionController;
import org.apache.jmeter.control.WhileController; import org.apache.jmeter.control.WhileController;
import org.apache.jmeter.extractor.JSR223PostProcessor; import org.apache.jmeter.extractor.JSR223PostProcessor;
import org.apache.jmeter.extractor.RegexExtractor; import org.apache.jmeter.extractor.RegexExtractor;
...@@ -742,6 +744,12 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> { ...@@ -742,6 +744,12 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
countController.setInputVal(foreachController.getInputValString()); countController.setInputVal(foreachController.getInputValString());
countController.setReturnVal(foreachController.getReturnValString()); countController.setReturnVal(foreachController.getReturnValString());
((MsLoopController) elementNode).setForEachController(countController); ((MsLoopController) elementNode).setForEachController(countController);
}else if(key instanceof TransactionController){
TransactionController transactionController = (TransactionController) key;
elementNode = new MsTransactionController();
elementNode.setName(transactionController.getName());
((MsTransactionController)elementNode).setGenerateParentSample(transactionController.isGenerateParentSample());
((MsTransactionController)elementNode).setIncludeTimers(transactionController.isIncludeTimers());
} }
// 平台不能识别的Jmeter步骤 // 平台不能识别的Jmeter步骤
else { else {
......
...@@ -197,6 +197,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { ...@@ -197,6 +197,7 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} }
compatible(config); compatible(config);
HttpConfig httpConfig = null; HttpConfig httpConfig = null;
try { try {
if (config.isEffective(this.getProjectId())) { if (config.isEffective(this.getProjectId())) {
...@@ -204,6 +205,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { ...@@ -204,6 +205,9 @@ public class MsHTTPSamplerProxy extends MsTestElement {
if (httpConfig == null && !isURL(this.getUrl())) { if (httpConfig == null && !isURL(this.getUrl())) {
MSException.throwException("未匹配到环境,请检查环境配置"); MSException.throwException("未匹配到环境,请检查环境配置");
} }
if(StringUtils.isEmpty(httpConfig.getProtocol())){
MSException.throwException(this.getName() +"接口,对应的环境无协议,请完善环境信息");
}
if (StringUtils.isEmpty(this.useEnvironment)) { if (StringUtils.isEmpty(this.useEnvironment)) {
this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid(); this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid();
} }
...@@ -428,11 +432,11 @@ public class MsHTTPSamplerProxy extends MsTestElement { ...@@ -428,11 +432,11 @@ public class MsHTTPSamplerProxy extends MsTestElement {
} }
// 数据兼容处理 // 数据兼容处理
if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) { if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) {
// 1.8 之后 当前正常数据
} else if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) {
// 1.8 前后 混合数据 // 1.8 前后 混合数据
this.setProjectId(getParentProjectId()); this.setProjectId(getParentProjectId());
} else if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) {
// 1.8 之后 当前正常数据
} else { } else {
// 1.8 之前 数据 // 1.8 之前 数据
if (config.getConfig() != null) { if (config.getConfig() != null) {
......
...@@ -883,7 +883,6 @@ public class ApiAutomationService { ...@@ -883,7 +883,6 @@ public class ApiAutomationService {
request.setTriggerMode(ReportTriggerMode.MANUAL.name()); request.setTriggerMode(ReportTriggerMode.MANUAL.name());
} }
String reportId = request.getId(); String reportId = request.getId();
Map<APIScenarioReportResult, HashTree> map = new LinkedHashMap<>(); Map<APIScenarioReportResult, HashTree> map = new LinkedHashMap<>();
List<String> scenarioIds = new ArrayList<>(); List<String> scenarioIds = new ArrayList<>();
StringBuilder scenarioNames = new StringBuilder(); StringBuilder scenarioNames = new StringBuilder();
......
...@@ -568,9 +568,11 @@ public class ApiDefinitionService { ...@@ -568,9 +568,11 @@ public class ApiDefinitionService {
Map<String, String> map = request.getEnvironmentMap(); Map<String, String> map = request.getEnvironmentMap();
if (map != null && map.size() > 0) { if (map != null && map.size() > 0) {
ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(request.getProjectId())); ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(request.getProjectId()));
EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); if (environment != null) {
envConfig.put(request.getProjectId(), env); EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class);
config.setConfig(envConfig); envConfig.put(request.getProjectId(), env);
config.setConfig(envConfig);
}
} }
if (CollectionUtils.isNotEmpty(bodyFiles)) { if (CollectionUtils.isNotEmpty(bodyFiles)) {
......
...@@ -326,8 +326,12 @@ public class ApiScenarioReportService { ...@@ -326,8 +326,12 @@ public class ApiScenarioReportService {
*/ */
private void updateScenarioStatus(String reportId) { private void updateScenarioStatus(String reportId) {
if (StringUtils.isNotEmpty(reportId)) { if (StringUtils.isNotEmpty(reportId)) {
List<String> list = new ArrayList<>(); List<String> list = new LinkedList<>();
list.add(reportId); try {
list = JSON.parseObject(reportId, List.class);
} catch (Exception e) {
list.add(reportId);
}
ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample(); ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample();
scenarioReportExample.createCriteria().andIdIn(list); scenarioReportExample.createCriteria().andIdIn(list);
List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample); List<ApiScenarioReport> reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample);
...@@ -336,7 +340,7 @@ public class ApiScenarioReportService { ...@@ -336,7 +340,7 @@ public class ApiScenarioReportService {
if (CollectionUtils.isNotEmpty(reportList)) { if (CollectionUtils.isNotEmpty(reportList)) {
reportList.forEach(report -> { reportList.forEach(report -> {
report.setUpdateTime(System.currentTimeMillis()); report.setUpdateTime(System.currentTimeMillis());
String status = "Success"; String status = "Error";
report.setStatus(status); report.setStatus(status);
scenarioReportMapper.updateByPrimaryKeySelective(report); scenarioReportMapper.updateByPrimaryKeySelective(report);
// 把上一条调试的数据内容清空 // 把上一条调试的数据内容清空
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
package io.metersphere.api.service.task; package io.metersphere.api.service.task;
import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.automation.RunScenarioRequest; import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.commons.exception.MSException; import io.metersphere.commons.exception.MSException;
...@@ -28,7 +27,7 @@ public class ParallelScenarioExecTask<T> implements Callable<T> { ...@@ -28,7 +27,7 @@ public class ParallelScenarioExecTask<T> implements Callable<T> {
@Override @Override
public T call() { public T call() {
try { try {
jMeterService.runSerial(JSON.toJSONString(id), hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); jMeterService.runSerial(id, hashTree, request.getReportId(), request.getRunMode(), request.getConfig());
return null; return null;
} catch (Exception ex) { } catch (Exception ex) {
LogUtil.error(ex.getMessage()); LogUtil.error(ex.getMessage());
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
*/ */
package io.metersphere.api.service.task; package io.metersphere.api.service.task;
import com.alibaba.fastjson.JSON;
import io.metersphere.api.dto.automation.RunScenarioRequest; import io.metersphere.api.dto.automation.RunScenarioRequest;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.base.domain.ApiScenarioReport;
...@@ -34,7 +33,7 @@ public class SerialScenarioExecTask<T> implements Callable<T> { ...@@ -34,7 +33,7 @@ public class SerialScenarioExecTask<T> implements Callable<T> {
@Override @Override
public T call() { public T call() {
try { try {
jMeterService.runSerial(JSON.toJSONString(id), hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); jMeterService.runSerial(id, hashTree, request.getReportId(), request.getRunMode(), request.getConfig());
// 轮询查看报告状态,最多200次,防止死循环 // 轮询查看报告状态,最多200次,防止死循环
int index = 1; int index = 1;
while (index < 200) { while (index < 200) {
......
...@@ -13,4 +13,6 @@ public interface ExtProjectMapper { ...@@ -13,4 +13,6 @@ public interface ExtProjectMapper {
List<String> getProjectIdByWorkspaceId(String workspaceId); List<String> getProjectIdByWorkspaceId(String workspaceId);
int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId); int removeIssuePlatform(@Param("platform") String platform, @Param("orgId") String orgId);
List<ProjectDTO> getSwitchProject(@Param("proRequest") ProjectRequest request);
} }
...@@ -82,6 +82,17 @@ ...@@ -82,6 +82,17 @@
from project from project
where workspace_id = #{workspaceId} where workspace_id = #{workspaceId}
</select> </select>
<select id="getSwitchProject" resultType="io.metersphere.dto.ProjectDTO">
select distinct p.* from `group` g join user_group ug on g.id = ug.group_id
join project p on p.id = ug.source_id
<where>
g.type = 'PROJECT' and ug.user_id = #{proRequest.userId}
and p.workspace_id = #{proRequest.workspaceId}
<if test="proRequest.name != null and proRequest.name != ''">
and p.name like #{proRequest.name, jdbcType=VARCHAR}
</if>
</where>
</select>
<update id="removeIssuePlatform"> <update id="removeIssuePlatform">
update project update project
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
</select> </select>
<select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase"> <select id="getTestCaseNames" resultType="io.metersphere.base.domain.TestCase">
select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status select test_case.id, test_case.name, test_case.priority, test_case.type, test_case.review_status,test_case.num,test_case.custom_num
from test_case from test_case
<where> <where>
<if test="request.combine != null"> <if test="request.combine != null">
......
package io.metersphere.commons.constants; package io.metersphere.commons.constants;
public enum OperLogConstants { public enum OperLogConstants {
CREATE, DELETE, GC, RESTORE, DEBUG, UPDATE, BATCH_DEL, BATCH_UPDATE, BATCH_ADD, BATCH_RESTORE, BATCH_GC, IMPORT, EXPORT, ASSOCIATE_CASE, UN_ASSOCIATE_CASE, REVIEW, COPY, EXECUTE, SHARE, LOGIN, CREATE_PRE_TEST, OTHER CREATE, DELETE, GC, RESTORE, DEBUG, UPDATE, BATCH_DEL, BATCH_UPDATE, BATCH_ADD, BATCH_RESTORE, BATCH_GC, IMPORT, EXPORT, ASSOCIATE_CASE, ASSOCIATE_ISSUE, UN_ASSOCIATE_CASE, REVIEW, COPY, EXECUTE, SHARE, LOGIN, CREATE_PRE_TEST, OTHER
} }
...@@ -4,7 +4,6 @@ import com.github.pagehelper.Page; ...@@ -4,7 +4,6 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Organization; import io.metersphere.base.domain.Organization;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.controller.request.OrganizationRequest; import io.metersphere.controller.request.OrganizationRequest;
...@@ -13,8 +12,6 @@ import io.metersphere.dto.OrganizationResource; ...@@ -13,8 +12,6 @@ import io.metersphere.dto.OrganizationResource;
import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.OrganizationService; import io.metersphere.service.OrganizationService;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -67,7 +64,7 @@ public class OrganizationController { ...@@ -67,7 +64,7 @@ public class OrganizationController {
} }
@PostMapping("/member/update") @PostMapping("/member/update")
@MsAuditLog(module = "organization_member", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#memberDTO.id)", content = "#msClass.getLogDetails(#memberDTO.id)", msClass = OrganizationService.class) @MsAuditLog(module = "organization_member", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#memberDTO)", msClass = OrganizationService.class)
public void updateOrgMember(@RequestBody OrganizationMemberDTO memberDTO) { public void updateOrgMember(@RequestBody OrganizationMemberDTO memberDTO) {
organizationService.updateOrgMember(memberDTO); organizationService.updateOrgMember(memberDTO);
} }
......
...@@ -90,6 +90,18 @@ public class ProjectController { ...@@ -90,6 +90,18 @@ public class ProjectController {
return PageUtils.setPageInfo(page, projectService.getProjectList(request)); return PageUtils.setPageInfo(page, projectService.getProjectList(request));
} }
/**
* 切换项目
* @param request
* @return
*/
@PostMapping("/list/related")
public List<ProjectDTO> getSwitchProject(@RequestBody ProjectRequest request) {
request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
return projectService.getSwitchProject(request);
}
@GetMapping("/delete/{projectId}") @GetMapping("/delete/{projectId}")
@MsAuditLog(module = "project_project_manager", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#projectId)", msClass = ProjectService.class) @MsAuditLog(module = "project_project_manager", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#projectId)", msClass = ProjectService.class)
public void deleteProject(@PathVariable(value = "projectId") String projectId) { public void deleteProject(@PathVariable(value = "projectId") String projectId) {
......
...@@ -83,7 +83,7 @@ public class UserController { ...@@ -83,7 +83,7 @@ public class UserController {
} }
@PostMapping("/special/update") @PostMapping("/special/update")
@MsAuditLog(module = "system_user", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#user.id)", content = "#msClass.getLogDetails(#user.id)", msClass = UserService.class) @MsAuditLog(module = "system_user", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#user)", content = "#msClass.getLogDetails(#user)", msClass = UserService.class)
public void updateUser(@RequestBody UserRequest user) { public void updateUser(@RequestBody UserRequest user) {
userService.updateUserRole(user); userService.updateUserRole(user);
} }
...@@ -254,7 +254,7 @@ public class UserController { ...@@ -254,7 +254,7 @@ public class UserController {
* 添加组织成员 * 添加组织成员
*/ */
@PostMapping("/org/member/add") @PostMapping("/org/member/add")
@MsAuditLog(module = "organization_member", type = OperLogConstants.CREATE, title = "添加组织成员") @MsAuditLog(module = "organization_member", type = OperLogConstants.CREATE, title = "'添加组织成员-'+#request.userIds")
public void addOrganizationMember(@RequestBody AddOrgMemberRequest request) { public void addOrganizationMember(@RequestBody AddOrgMemberRequest request) {
organizationService.checkOrgOwner(request.getOrganizationId()); organizationService.checkOrgOwner(request.getOrganizationId());
userService.addOrganizationMember(request); userService.addOrganizationMember(request);
...@@ -331,6 +331,7 @@ public class UserController { ...@@ -331,6 +331,7 @@ public class UserController {
} }
@PostMapping("/import/{userId}") @PostMapping("/import/{userId}")
@MsAuditLog(module = "system_user", type = OperLogConstants.IMPORT)
public ExcelResponse testCaseImport(MultipartFile file, @PathVariable String userId, HttpServletRequest request) { public ExcelResponse testCaseImport(MultipartFile file, @PathVariable String userId, HttpServletRequest request) {
return userService.userImport(file, userId, request); return userService.userImport(file, userId, request);
} }
......
...@@ -4,7 +4,6 @@ import com.github.pagehelper.Page; ...@@ -4,7 +4,6 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Workspace; import io.metersphere.base.domain.Workspace;
import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.RoleConstants;
import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
...@@ -15,8 +14,6 @@ import io.metersphere.log.annotation.MsAuditLog; ...@@ -15,8 +14,6 @@ import io.metersphere.log.annotation.MsAuditLog;
import io.metersphere.service.OrganizationService; import io.metersphere.service.OrganizationService;
import io.metersphere.service.UserService; import io.metersphere.service.UserService;
import io.metersphere.service.WorkspaceService; import io.metersphere.service.WorkspaceService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -65,7 +62,7 @@ public class WorkspaceController { ...@@ -65,7 +62,7 @@ public class WorkspaceController {
} }
@GetMapping("special/delete/{workspaceId}") @GetMapping("special/delete/{workspaceId}")
@MsAuditLog(module = "system_workspace", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class) @MsAuditLog(module = "system_workspace", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class)
public void deleteWorkspaceByAdmin(@PathVariable String workspaceId) { public void deleteWorkspaceByAdmin(@PathVariable String workspaceId) {
userService.refreshSessionUser("workspace", workspaceId); userService.refreshSessionUser("workspace", workspaceId);
workspaceService.deleteWorkspace(workspaceId); workspaceService.deleteWorkspace(workspaceId);
...@@ -104,7 +101,7 @@ public class WorkspaceController { ...@@ -104,7 +101,7 @@ public class WorkspaceController {
} }
@PostMapping("/member/update") @PostMapping("/member/update")
@MsAuditLog(module = "workspace_member", type = OperLogConstants.UPDATE, title = "#memberDTO.name") @MsAuditLog(module = "workspace_member", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#memberDTO)", content = "#msClass.getLogDetails(#memberDTO)", msClass = WorkspaceService.class)
public void updateOrgMember(@RequestBody WorkspaceMemberDTO memberDTO) { public void updateOrgMember(@RequestBody WorkspaceMemberDTO memberDTO) {
workspaceService.updateWorkspaceMember(memberDTO); workspaceService.updateWorkspaceMember(memberDTO);
} }
......
...@@ -11,6 +11,7 @@ import java.util.Map; ...@@ -11,6 +11,7 @@ import java.util.Map;
public class ProjectRequest { public class ProjectRequest {
private String workspaceId; private String workspaceId;
private String projectId; private String projectId;
private String userId;
private String name; private String name;
private List<OrderRequest> orders; private List<OrderRequest> orders;
private Map<String, List<String>> filters; private Map<String, List<String>> filters;
......
...@@ -4,10 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnore; ...@@ -4,10 +4,15 @@ import com.alibaba.excel.annotation.ExcelIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
@Getter @Getter
@Setter @Setter
public class TestCaseExcelData { public class TestCaseExcelData {
private String id;
@ExcelIgnore @ExcelIgnore
private Integer num; private Integer num;
@ExcelIgnore @ExcelIgnore
...@@ -32,4 +37,14 @@ public class TestCaseExcelData { ...@@ -32,4 +37,14 @@ public class TestCaseExcelData {
private String stepResult; private String stepResult;
@ExcelIgnore @ExcelIgnore
private String stepModel; private String stepModel;
public Set<String> getExcludeColumnFiledNames(boolean needNum){
Set<String> excludeColumnFiledNames = new HashSet<>();
if(!needNum){
excludeColumnFiledNames.add("num");
}
excludeColumnFiledNames.add("customNum");
return excludeColumnFiledNames;
}
} }
...@@ -13,12 +13,12 @@ import javax.validation.constraints.Pattern; ...@@ -13,12 +13,12 @@ import javax.validation.constraints.Pattern;
@ColumnWidth(15) @ColumnWidth(15)
public class TestCaseExcelDataCn extends TestCaseExcelData { public class TestCaseExcelDataCn extends TestCaseExcelData {
@ExcelProperty("ID") // @ExcelProperty("ID")
@NotRequired // @NotRequired
private Integer num; // private Integer num;
@ColumnWidth(50) @ColumnWidth(50)
@ExcelProperty("自定义ID") @ExcelProperty("ID")
@NotRequired @NotRequired
private String customNum; private String customNum;
......
...@@ -15,4 +15,14 @@ public class TestCaseExcelDataFactory implements ExcelDataFactory { ...@@ -15,4 +15,14 @@ public class TestCaseExcelDataFactory implements ExcelDataFactory {
} }
return TestCaseExcelDataCn.class; return TestCaseExcelDataCn.class;
} }
public TestCaseExcelData getTestCaseExcelDataLocal(){
Locale locale = LocaleContextHolder.getLocale();
if (Locale.US.toString().equalsIgnoreCase(locale.toString())) {
return new TestCaseExcelDataUs();
} else if (Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())) {
return new TestCaseExcelDataTw();
}
return new TestCaseExcelDataCn();
}
} }
...@@ -13,12 +13,12 @@ import javax.validation.constraints.Pattern; ...@@ -13,12 +13,12 @@ import javax.validation.constraints.Pattern;
@ColumnWidth(15) @ColumnWidth(15)
public class TestCaseExcelDataTw extends TestCaseExcelData { public class TestCaseExcelDataTw extends TestCaseExcelData {
@ExcelProperty("ID") // @ExcelProperty("ID")
@NotRequired // @NotRequired
private Integer num; // private Integer num;
@ColumnWidth(50) @ColumnWidth(50)
@ExcelProperty("自定義ID") @ExcelProperty("ID")
@NotRequired @NotRequired
private String customNum; private String customNum;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment