自动添加测试数据接口,测试接口开发。
This commit is contained in:
+67
-1
@@ -10,6 +10,7 @@ import com.jero.common.api.vo.Result;
|
|||||||
import com.jero.common.aspect.annotation.AutoLog;
|
import com.jero.common.aspect.annotation.AutoLog;
|
||||||
import com.jero.common.constant.enums.CutEnum;
|
import com.jero.common.constant.enums.CutEnum;
|
||||||
import com.jero.common.system.base.controller.JeroController;
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
|
import com.jero.modules.cert.template.entity.CertCategoryParamsInfoEO;
|
||||||
import com.jero.modules.cert.template.entity.ParamsInfoEO;
|
import com.jero.modules.cert.template.entity.ParamsInfoEO;
|
||||||
import com.jero.modules.cert.template.service.IParamsInfoEOService;
|
import com.jero.modules.cert.template.service.IParamsInfoEOService;
|
||||||
import com.jero.modules.cert.template.service.IParamsInfoPublishEOService;
|
import com.jero.modules.cert.template.service.IParamsInfoPublishEOService;
|
||||||
@@ -26,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,7 +49,7 @@ public class ParamsInfoEOController extends JeroController<ParamsInfoEO, IParams
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IParamsInfoPublishEOService paramsInfoPublishEOService;
|
private IParamsInfoPublishEOService paramsInfoPublishEOService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
@@ -305,4 +307,68 @@ public class ParamsInfoEOController extends JeroController<ParamsInfoEO, IParams
|
|||||||
return paramsInfoEOService.importParamsInfo(file, cut, paramsTemplateId);
|
return paramsInfoEOService.importParamsInfo(file, cut, paramsTemplateId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动添加测试数据接口
|
||||||
|
* @param json
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/test/autoAddTestData")
|
||||||
|
public Result<?> autoAddTestData(@RequestBody JSONObject json) {
|
||||||
|
//TODO 测试接口
|
||||||
|
String certCategory = json.getString("certCategory");
|
||||||
|
String certCategoryType = json.getString("certCategoryType"); // gg、3c、yy、hb
|
||||||
|
String controlType = json.getString("controlType");
|
||||||
|
String controlVerify = json.getString("controlVerify");
|
||||||
|
String cut = json.getString("cut");
|
||||||
|
String dutyTerritory = json.getString("dutyTerritory");
|
||||||
|
String isMust = json.getString("isMust");
|
||||||
|
String nioNumber = json.getString("nioNumber");
|
||||||
|
String paramsBatch = json.getString("paramsBatch");
|
||||||
|
String paramsName = json.getString("paramsName");
|
||||||
|
String paramsTemplateId = json.getString("paramsTemplateId");
|
||||||
|
if (StringUtils.isEmpty(certCategory)) {
|
||||||
|
return Result.error("认证类别不能为空!");
|
||||||
|
}
|
||||||
|
boolean isSuccess = false;
|
||||||
|
|
||||||
|
Integer startIndex = json.getInteger("startIndex");
|
||||||
|
Integer endIndex = json.getInteger("endIndex");
|
||||||
|
for (Integer i = 0; i < endIndex; i++) {
|
||||||
|
ParamsInfoEO paramsInfoEO = new ParamsInfoEO();
|
||||||
|
paramsInfoEO.setNioNumber(nioNumber + "-" + String.format("%04d",startIndex + i));
|
||||||
|
paramsInfoEO.setParamsName(paramsName + "-" + String.format("%04d",startIndex + i) + "名称");
|
||||||
|
paramsInfoEO.setCertCategory(certCategory);
|
||||||
|
paramsInfoEO.setControlType(controlType);
|
||||||
|
paramsInfoEO.setControlVerify(controlVerify);
|
||||||
|
paramsInfoEO.setCut(cut);
|
||||||
|
paramsInfoEO.setDutyTerritory(dutyTerritory);
|
||||||
|
paramsInfoEO.setIsMust(isMust);
|
||||||
|
paramsInfoEO.setParamsBatch(paramsBatch);
|
||||||
|
paramsInfoEO.setParamsTemplateId(paramsTemplateId);
|
||||||
|
|
||||||
|
List<CertCategoryParamsInfoEO> certCategoryParamsInfoEOList = new ArrayList<>();
|
||||||
|
CertCategoryParamsInfoEO certCategoryParamsInfoEO = new CertCategoryParamsInfoEO();
|
||||||
|
certCategoryParamsInfoEO.setCertCategory(certCategory);
|
||||||
|
certCategoryParamsInfoEO.setParamsName(paramsName + "-" + String.format("%04d",startIndex + i) + "-" + certCategoryType + "-" + "name");
|
||||||
|
certCategoryParamsInfoEO.setParamsNumber(nioNumber + "-" + String.format("%04d",startIndex + i) + "-" + certCategoryType);
|
||||||
|
certCategoryParamsInfoEOList.add(certCategoryParamsInfoEO);
|
||||||
|
paramsInfoEO.setCertCategoryParamsInfoEOList(certCategoryParamsInfoEOList);
|
||||||
|
|
||||||
|
isSuccess = paramsInfoEOService.add(paramsInfoEO);
|
||||||
|
|
||||||
|
if(!isSuccess){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (isSuccess) {
|
||||||
|
return Result.OK("添加成功!");
|
||||||
|
} else {
|
||||||
|
return Result.error("添加失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user