陈裕财 4 years ago
parent
commit
eb3b78bfbb
  1. 307
      xm-core/src/main/java/com/xm/core/ctrl/XmTestCaseController.java
  2. 296
      xm-core/src/main/java/com/xm/core/ctrl/XmTestCasedbController.java
  3. 307
      xm-core/src/main/java/com/xm/core/ctrl/XmTestPlanCaseController.java
  4. 296
      xm-core/src/main/java/com/xm/core/ctrl/XmTestPlanController.java
  5. 59
      xm-core/src/main/java/com/xm/core/entity/XmTestCasedb.java
  6. 98
      xm-core/src/main/java/com/xm/core/entity/XmTestPlan.java
  7. 72
      xm-core/src/main/java/com/xm/core/entity/XmTestPlanCase.java
  8. 24
      xm-core/src/main/java/com/xm/core/service/XmTestCasedbService.java
  9. 24
      xm-core/src/main/java/com/xm/core/service/XmTestPlanCaseService.java
  10. 24
      xm-core/src/main/java/com/xm/core/service/XmTestPlanService.java
  11. 188
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestCasedbMapper.xml
  12. 203
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestPlanCaseMapper.xml
  13. 240
      xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestPlanMapper.xml

307
xm-core/src/main/java/com/xm/core/ctrl/XmTestCaseController.java

@ -0,0 +1,307 @@
package com.xm.core.ctrl;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import static com.mdp.core.utils.ResponseHelper.*;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.mybatis.PageUtils;
import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.NumberUtil;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import springfox.documentation.annotations.ApiIgnore;
import com.xm.core.service.XmTestCaseService;
import com.xm.core.entity.XmTestCase;
/**
* url编制采用rest风格,如对xm_test_case 测试用例的操作有增删改查,对应的url分别为:<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestCase xm_test_case 当前主键(包括多主键): id;
***/
@RestController("xm.core.xmTestCaseController")
@RequestMapping(value="/**/core/xmTestCase")
@Api(tags={"测试用例操作接口"})
public class XmTestCaseController {
static Logger logger =LoggerFactory.getLogger(XmTestCaseController.class);
@Autowired
private XmTestCaseService xmTestCaseService;
Map<String,Object> fieldsMap = toMap(new XmTestCase());
@ApiOperation( value = "查询测试用例信息列表",notes=" ")
@ApiEntityParams( XmTestCase.class )
@ApiImplicitParams({
@ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false),
})
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCase.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listXmTestCase( @ApiIgnore @RequestParam Map<String,Object> xmTestCase){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("查询成功");
RequestUtils.transformArray(xmTestCase, "ids");
RequestUtils.transformArray(xmTestCase, "menuIds");
PageUtils.startPage(xmTestCase);
String id= (String) xmTestCase.get("id");
String menuId= (String) xmTestCase.get("menuId");
Object ids= xmTestCase.get("ids");
Object menuIds= xmTestCase.get("menuIds");
String productId= (String) xmTestCase.get("productId");
String myUserid= (String) xmTestCase.get("myUserid");
String projectId= (String) xmTestCase.get("projectId");
if( !( StringUtils.hasText(myUserid) ||StringUtils.hasText(id) || StringUtils.hasText(menuId) || StringUtils.hasText(productId)|| StringUtils.hasText(projectId)||menuIds!=null||ids!=null ) ){
xmTestCase.put("compete", LoginUtils.getCurrentUserInfo().getUserid());
}
List<Map<String,Object>> xmTestCaseList = xmTestCaseService.selectListMapByWhere(xmTestCase); //列出XmTestCase列表
PageUtils.responePage(m, xmTestCaseList);
m.put("data",xmTestCaseList);
m.put("tips", tips);
return m;
}
/**
@ApiOperation( value = "新增一条测试用例信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCase.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmTestCase(@RequestBody XmTestCase xmTestCase) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
boolean createPk=false;
if(!StringUtils.hasText(xmTestCase.getId())) {
createPk=true;
xmTestCase.setId(xmTestCaseService.createKey("id"));
}
if(createPk==false){
if(xmTestCaseService.selectOneObject(xmTestCase) !=null ){
return failed("pk-exists","编号重复,请修改编号再提交");
}
}
xmTestCaseService.insert(xmTestCase);
m.put("data",xmTestCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "删除一条测试用例信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
})
@RequestMapping(value="/del",method=RequestMethod.POST)
public Map<String,Object> delXmTestCase(@RequestBody XmTestCase xmTestCase){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除一条数据");
try{
if(!StringUtils.hasText(xmTestCase.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestCase xmTestCaseDb = xmTestCaseService.selectOneObject(xmTestCase);
if( xmTestCaseDb == null ){
return failed("data-not-exists","数据不存在,无法删除");
}
xmTestCaseService.deleteByPk(xmTestCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键修改一条测试用例信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCase.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/edit",method=RequestMethod.POST)
public Map<String,Object> editXmTestCase(@RequestBody XmTestCase xmTestCase) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
if(!StringUtils.hasText(xmTestCase.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestCase xmTestCaseDb = xmTestCaseService.selectOneObject(xmTestCase);
if( xmTestCaseDb == null ){
return failed("data-not-exists","数据不存在,无法修改");
}
xmTestCaseService.updateSomeFieldByPk(xmTestCase);
m.put("data",xmTestCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmTestCase.class, props={ }, remark = "测试用例", paramType = "body" )
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCase.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST)
public Map<String,Object> editSomeFields( @ApiIgnore @RequestBody Map<String,Object> xmTestCaseMap) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
List<String> ids= (List<String>) xmTestCaseMap.get("ids");
if(ids==null || ids.size()==0){
return failed("ids-0","ids不能为空");
}
Set<String> fields=new HashSet<>();
fields.add("id");
for (String fieldName : xmTestCaseMap.keySet()) {
if(fields.contains(fieldName)){
return failed(fieldName+"-no-edit",fieldName+"不允许修改");
}
}
Set<String> fieldKey=xmTestCaseMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet());
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmTestCaseMap.get(i) )).collect(Collectors.toSet());
if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段");
}
XmTestCase xmTestCase = fromMap(xmTestCaseMap,XmTestCase.class);
List<XmTestCase> xmTestCasesDb=xmTestCaseService.selectListByIds(ids);
if(xmTestCasesDb==null ||xmTestCasesDb.size()==0){
return failed("data-0","记录已不存在");
}
List<XmTestCase> can=new ArrayList<>();
List<XmTestCase> no=new ArrayList<>();
User user = LoginUtils.getCurrentUserInfo();
for (XmTestCase xmTestCaseDb : xmTestCasesDb) {
Tips tips2 = new Tips("检查通过");
if(!tips2.isOk()){
no.add(xmTestCaseDb);
}else{
can.add(xmTestCaseDb);
}
}
if(can.size()>0){
xmTestCaseMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList()));
xmTestCaseService.editSomeFields(xmTestCaseMap);
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
msgs.add(String.format("成功更新以下%s条数据",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s个数据无权限更新",no.size()));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
//m.put("data",xmMenu);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键列表批量删除测试用例信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmTestCase(@RequestBody List<XmTestCase> xmTestCases) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmTestCases.size()<=0){
return failed("data-0","请上送待删除数据列表");
}
List<XmTestCase> datasDb=xmTestCaseService.selectListByIds(xmTestCases.stream().map(i-> i.getId() ).collect(Collectors.toList()));
List<XmTestCase> can=new ArrayList<>();
List<XmTestCase> no=new ArrayList<>();
for (XmTestCase data : datasDb) {
if(true){
can.add(data);
}else{
no.add(data);
}
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
xmTestCaseService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
}

296
xm-core/src/main/java/com/xm/core/ctrl/XmTestCasedbController.java

@ -0,0 +1,296 @@
package com.xm.core.ctrl;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import static com.mdp.core.utils.ResponseHelper.*;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.mybatis.PageUtils;
import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.NumberUtil;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import springfox.documentation.annotations.ApiIgnore;
import com.xm.core.service.XmTestCasedbService;
import com.xm.core.entity.XmTestCasedb;
/**
* url编制采用rest风格,如对xm_test_casedb 测试用例库的操作有增删改查,对应的url分别为:<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestCasedb xm_test_casedb 当前主键(包括多主键): id;
***/
@RestController("xm.core.xmTestCasedbController")
@RequestMapping(value="/**/core/xmTestCasedb")
@Api(tags={"测试用例库操作接口"})
public class XmTestCasedbController {
static Logger logger =LoggerFactory.getLogger(XmTestCasedbController.class);
@Autowired
private XmTestCasedbService xmTestCasedbService;
Map<String,Object> fieldsMap = toMap(new XmTestCasedb());
@ApiOperation( value = "查询测试用例库信息列表",notes=" ")
@ApiEntityParams( XmTestCasedb.class )
@ApiImplicitParams({
@ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false),
})
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCasedb.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listXmTestCasedb( @ApiIgnore @RequestParam Map<String,Object> xmTestCasedb){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("查询成功");
RequestUtils.transformArray(xmTestCasedb, "ids");
PageUtils.startPage(xmTestCasedb);
List<Map<String,Object>> xmTestCasedbList = xmTestCasedbService.selectListMapByWhere(xmTestCasedb); //列出XmTestCasedb列表
PageUtils.responePage(m, xmTestCasedbList);
m.put("data",xmTestCasedbList);
m.put("tips", tips);
return m;
}
/**
@ApiOperation( value = "新增一条测试用例库信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCasedb.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmTestCasedb(@RequestBody XmTestCasedb xmTestCasedb) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
boolean createPk=false;
if(!StringUtils.hasText(xmTestCasedb.getId())) {
createPk=true;
xmTestCasedb.setId(xmTestCasedbService.createKey("id"));
}
if(createPk==false){
if(xmTestCasedbService.selectOneObject(xmTestCasedb) !=null ){
return failed("pk-exists","编号重复,请修改编号再提交");
}
}
xmTestCasedbService.insert(xmTestCasedb);
m.put("data",xmTestCasedb);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "删除一条测试用例库信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
})
@RequestMapping(value="/del",method=RequestMethod.POST)
public Map<String,Object> delXmTestCasedb(@RequestBody XmTestCasedb xmTestCasedb){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除一条数据");
try{
if(!StringUtils.hasText(xmTestCasedb.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestCasedb xmTestCasedbDb = xmTestCasedbService.selectOneObject(xmTestCasedb);
if( xmTestCasedbDb == null ){
return failed("data-not-exists","数据不存在,无法删除");
}
xmTestCasedbService.deleteByPk(xmTestCasedb);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键修改一条测试用例库信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCasedb.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/edit",method=RequestMethod.POST)
public Map<String,Object> editXmTestCasedb(@RequestBody XmTestCasedb xmTestCasedb) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
if(!StringUtils.hasText(xmTestCasedb.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestCasedb xmTestCasedbDb = xmTestCasedbService.selectOneObject(xmTestCasedb);
if( xmTestCasedbDb == null ){
return failed("data-not-exists","数据不存在,无法修改");
}
xmTestCasedbService.updateSomeFieldByPk(xmTestCasedb);
m.put("data",xmTestCasedb);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmTestCasedb.class, props={ }, remark = "测试用例库", paramType = "body" )
@ApiResponses({
@ApiResponse(code = 200,response=XmTestCasedb.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST)
public Map<String,Object> editSomeFields( @ApiIgnore @RequestBody Map<String,Object> xmTestCasedbMap) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
List<String> ids= (List<String>) xmTestCasedbMap.get("ids");
if(ids==null || ids.size()==0){
return failed("ids-0","ids不能为空");
}
Set<String> fields=new HashSet<>();
fields.add("id");
for (String fieldName : xmTestCasedbMap.keySet()) {
if(fields.contains(fieldName)){
return failed(fieldName+"-no-edit",fieldName+"不允许修改");
}
}
Set<String> fieldKey=xmTestCasedbMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet());
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmTestCasedbMap.get(i) )).collect(Collectors.toSet());
if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段");
}
XmTestCasedb xmTestCasedb = fromMap(xmTestCasedbMap,XmTestCasedb.class);
List<XmTestCasedb> xmTestCasedbsDb=xmTestCasedbService.selectListByIds(ids);
if(xmTestCasedbsDb==null ||xmTestCasedbsDb.size()==0){
return failed("data-0","记录已不存在");
}
List<XmTestCasedb> can=new ArrayList<>();
List<XmTestCasedb> no=new ArrayList<>();
User user = LoginUtils.getCurrentUserInfo();
for (XmTestCasedb xmTestCasedbDb : xmTestCasedbsDb) {
Tips tips2 = new Tips("检查通过");
if(!tips2.isOk()){
no.add(xmTestCasedbDb);
}else{
can.add(xmTestCasedbDb);
}
}
if(can.size()>0){
xmTestCasedbMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList()));
xmTestCasedbService.editSomeFields(xmTestCasedbMap);
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
msgs.add(String.format("成功更新以下%s条数据",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s个数据无权限更新",no.size()));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
//m.put("data",xmMenu);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键列表批量删除测试用例库信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmTestCasedb(@RequestBody List<XmTestCasedb> xmTestCasedbs) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmTestCasedbs.size()<=0){
return failed("data-0","请上送待删除数据列表");
}
List<XmTestCasedb> datasDb=xmTestCasedbService.selectListByIds(xmTestCasedbs.stream().map(i-> i.getId() ).collect(Collectors.toList()));
List<XmTestCasedb> can=new ArrayList<>();
List<XmTestCasedb> no=new ArrayList<>();
for (XmTestCasedb data : datasDb) {
if(true){
can.add(data);
}else{
no.add(data);
}
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
xmTestCasedbService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
}

307
xm-core/src/main/java/com/xm/core/ctrl/XmTestPlanCaseController.java

@ -0,0 +1,307 @@
package com.xm.core.ctrl;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import static com.mdp.core.utils.ResponseHelper.*;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.mybatis.PageUtils;
import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.NumberUtil;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import springfox.documentation.annotations.ApiIgnore;
import com.xm.core.service.XmTestPlanCaseService;
import com.xm.core.entity.XmTestPlanCase;
/**
* url编制采用rest风格,如对xm_test_plan_case 测试计划与用例关系表的操作有增删改查,对应的url分别为:<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlanCase xm_test_plan_case 当前主键(包括多主键): case_id,plan_id;
***/
@RestController("xm.core.xmTestPlanCaseController")
@RequestMapping(value="/**/core/xmTestPlanCase")
@Api(tags={"测试计划与用例关系表操作接口"})
public class XmTestPlanCaseController {
static Logger logger =LoggerFactory.getLogger(XmTestPlanCaseController.class);
@Autowired
private XmTestPlanCaseService xmTestPlanCaseService;
Map<String,Object> fieldsMap = toMap(new XmTestPlanCase());
@ApiOperation( value = "查询测试计划与用例关系表信息列表",notes=" ")
@ApiEntityParams( XmTestPlanCase.class )
@ApiImplicitParams({
@ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false),
})
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlanCase.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listXmTestPlanCase( @ApiIgnore @RequestParam Map<String,Object> xmTestPlanCase){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("查询成功");
RequestUtils.transformArray(xmTestPlanCase, "pkList");
PageUtils.startPage(xmTestPlanCase);
List<Map<String,Object>> xmTestPlanCaseList = xmTestPlanCaseService.selectListMapByWhere(xmTestPlanCase); //列出XmTestPlanCase列表
PageUtils.responePage(m, xmTestPlanCaseList);
m.put("data",xmTestPlanCaseList);
m.put("tips", tips);
return m;
}
/**
@ApiOperation( value = "新增一条测试计划与用例关系表信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlanCase.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmTestPlanCase(@RequestBody XmTestPlanCase xmTestPlanCase) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
boolean createPk=false;
if(!StringUtils.hasText(xmTestPlanCase.getCaseId())) {
createPk=true;
xmTestPlanCase.setCaseId(xmTestPlanCaseService.createKey("caseId"));
}
if(!StringUtils.hasText(xmTestPlanCase.getPlanId())) {
createPk=true;
xmTestPlanCase.setPlanId(xmTestPlanCaseService.createKey("planId"));
}
if(createPk==false){
if(xmTestPlanCaseService.selectOneObject(xmTestPlanCase) !=null ){
return failed("pk-exists","编号重复,请修改编号再提交");
}
}
xmTestPlanCaseService.insert(xmTestPlanCase);
m.put("data",xmTestPlanCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "删除一条测试计划与用例关系表信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
})
@RequestMapping(value="/del",method=RequestMethod.POST)
public Map<String,Object> delXmTestPlanCase(@RequestBody XmTestPlanCase xmTestPlanCase){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除一条数据");
try{
if(!StringUtils.hasText(xmTestPlanCase.getCaseId())) {
return failed("pk-not-exists","请上送主键参数caseId");
}
if(!StringUtils.hasText(xmTestPlanCase.getPlanId())) {
return failed("pk-not-exists","请上送主键参数planId");
}
XmTestPlanCase xmTestPlanCaseDb = xmTestPlanCaseService.selectOneObject(xmTestPlanCase);
if( xmTestPlanCaseDb == null ){
return failed("data-not-exists","数据不存在,无法删除");
}
xmTestPlanCaseService.deleteByPk(xmTestPlanCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键修改一条测试计划与用例关系表信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlanCase.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/edit",method=RequestMethod.POST)
public Map<String,Object> editXmTestPlanCase(@RequestBody XmTestPlanCase xmTestPlanCase) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
if(!StringUtils.hasText(xmTestPlanCase.getCaseId())) {
return failed("pk-not-exists","请上送主键参数caseId");
}
if(!StringUtils.hasText(xmTestPlanCase.getPlanId())) {
return failed("pk-not-exists","请上送主键参数planId");
}
XmTestPlanCase xmTestPlanCaseDb = xmTestPlanCaseService.selectOneObject(xmTestPlanCase);
if( xmTestPlanCaseDb == null ){
return failed("data-not-exists","数据不存在,无法修改");
}
xmTestPlanCaseService.updateSomeFieldByPk(xmTestPlanCase);
m.put("data",xmTestPlanCase);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmTestPlanCase.class, props={ }, remark = "测试计划与用例关系表", paramType = "body" )
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlanCase.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST)
public Map<String,Object> editSomeFields( @ApiIgnore @RequestBody Map<String,Object> xmTestPlanCaseMap) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
List<Map<String,Object>> pkList= (List<Map<String,Object>>) xmTestPlanCaseMap.get("pkList");
if(pkList==null || pkList.size()==0){
return failed("pkList-0","pkList不能为空");
}
Set<String> fields=new HashSet<>();
fields.add("caseId");
fields.add("planId");
for (String fieldName : xmTestPlanCaseMap.keySet()) {
if(fields.contains(fieldName)){
return failed(fieldName+"-no-edit",fieldName+"不允许修改");
}
}
Set<String> fieldKey=xmTestPlanCaseMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet());
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmTestPlanCaseMap.get(i) )).collect(Collectors.toSet());
if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段");
}
XmTestPlanCase xmTestPlanCase = fromMap(xmTestPlanCaseMap,XmTestPlanCase.class);
List<XmTestPlanCase> xmTestPlanCasesDb=xmTestPlanCaseService.selectListByIds(pkList);
if(xmTestPlanCasesDb==null ||xmTestPlanCasesDb.size()==0){
return failed("data-0","记录已不存在");
}
List<XmTestPlanCase> can=new ArrayList<>();
List<XmTestPlanCase> no=new ArrayList<>();
User user = LoginUtils.getCurrentUserInfo();
for (XmTestPlanCase xmTestPlanCaseDb : xmTestPlanCasesDb) {
Tips tips2 = new Tips("检查通过");
if(!tips2.isOk()){
no.add(xmTestPlanCaseDb);
}else{
can.add(xmTestPlanCaseDb);
}
}
if(can.size()>0){
xmTestPlanCaseMap.put("pkList",can.stream().map(i->map( "caseId",i.getCaseId(), "planId",i.getPlanId())).collect(Collectors.toList()));
xmTestPlanCaseService.editSomeFields(xmTestPlanCaseMap);
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
msgs.add(String.format("成功更新以下%s条数据",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s个数据无权限更新",no.size()));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
//m.put("data",xmMenu);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键列表批量删除测试计划与用例关系表信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmTestPlanCase(@RequestBody List<XmTestPlanCase> xmTestPlanCases) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmTestPlanCases.size()<=0){
return failed("data-0","请上送待删除数据列表");
}
List<XmTestPlanCase> datasDb=xmTestPlanCaseService.selectListByIds(xmTestPlanCases.stream().map(i->map( "caseId",i.getCaseId() , "planId",i.getPlanId() )).collect(Collectors.toList()));
List<XmTestPlanCase> can=new ArrayList<>();
List<XmTestPlanCase> no=new ArrayList<>();
for (XmTestPlanCase data : datasDb) {
if(true){
can.add(data);
}else{
no.add(data);
}
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
xmTestPlanCaseService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getCaseId() +" "+ i.getPlanId() ).collect(Collectors.joining(","))));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
}

296
xm-core/src/main/java/com/xm/core/ctrl/XmTestPlanController.java

@ -0,0 +1,296 @@
package com.xm.core.ctrl;
import java.util.*;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import static com.mdp.core.utils.ResponseHelper.*;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.mybatis.PageUtils;
import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.NumberUtil;
import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.mdp.swagger.ApiEntityParams;
import springfox.documentation.annotations.ApiIgnore;
import com.xm.core.service.XmTestPlanService;
import com.xm.core.entity.XmTestPlan;
/**
* url编制采用rest风格,如对xm_test_plan 测试计划的操作有增删改查,对应的url分别为:<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlan xm_test_plan 当前主键(包括多主键): id;
***/
@RestController("xm.core.xmTestPlanController")
@RequestMapping(value="/**/core/xmTestPlan")
@Api(tags={"测试计划操作接口"})
public class XmTestPlanController {
static Logger logger =LoggerFactory.getLogger(XmTestPlanController.class);
@Autowired
private XmTestPlanService xmTestPlanService;
Map<String,Object> fieldsMap = toMap(new XmTestPlan());
@ApiOperation( value = "查询测试计划信息列表",notes=" ")
@ApiEntityParams( XmTestPlan.class )
@ApiImplicitParams({
@ApiImplicitParam(name="pageSize",value="每页大小,默认20条",required=false),
@ApiImplicitParam(name="pageNum",value="当前页码,从1开始",required=false),
@ApiImplicitParam(name="total",value="总记录数,服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算",required=false),
@ApiImplicitParam(name="count",value="是否计算总记录条数,如果count=true,则计算计算总条数,如果count=false 则不计算",required=false),
@ApiImplicitParam(name="orderBy",value="排序列 如性别、学生编号排序 orderBy = sex desc,student desc",required=false),
})
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlan.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'错误码'},total:总记录数,data:[数据对象1,数据对象2,...]}")
})
@RequestMapping(value="/list",method=RequestMethod.GET)
public Map<String,Object> listXmTestPlan( @ApiIgnore @RequestParam Map<String,Object> xmTestPlan){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("查询成功");
RequestUtils.transformArray(xmTestPlan, "ids");
PageUtils.startPage(xmTestPlan);
List<Map<String,Object>> xmTestPlanList = xmTestPlanService.selectListMapByWhere(xmTestPlan); //列出XmTestPlan列表
PageUtils.responePage(m, xmTestPlanList);
m.put("data",xmTestPlanList);
m.put("tips", tips);
return m;
}
/**
@ApiOperation( value = "新增一条测试计划信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlan.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmTestPlan(@RequestBody XmTestPlan xmTestPlan) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
boolean createPk=false;
if(!StringUtils.hasText(xmTestPlan.getId())) {
createPk=true;
xmTestPlan.setId(xmTestPlanService.createKey("id"));
}
if(createPk==false){
if(xmTestPlanService.selectOneObject(xmTestPlan) !=null ){
return failed("pk-exists","编号重复,请修改编号再提交");
}
}
xmTestPlanService.insert(xmTestPlan);
m.put("data",xmTestPlan);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "删除一条测试计划信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
})
@RequestMapping(value="/del",method=RequestMethod.POST)
public Map<String,Object> delXmTestPlan(@RequestBody XmTestPlan xmTestPlan){
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除一条数据");
try{
if(!StringUtils.hasText(xmTestPlan.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestPlan xmTestPlanDb = xmTestPlanService.selectOneObject(xmTestPlan);
if( xmTestPlanDb == null ){
return failed("data-not-exists","数据不存在,无法删除");
}
xmTestPlanService.deleteByPk(xmTestPlan);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键修改一条测试计划信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlan.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/edit",method=RequestMethod.POST)
public Map<String,Object> editXmTestPlan(@RequestBody XmTestPlan xmTestPlan) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
if(!StringUtils.hasText(xmTestPlan.getId())) {
return failed("pk-not-exists","请上送主键参数id");
}
XmTestPlan xmTestPlanDb = xmTestPlanService.selectOneObject(xmTestPlan);
if( xmTestPlanDb == null ){
return failed("data-not-exists","数据不存在,无法修改");
}
xmTestPlanService.updateSomeFieldByPk(xmTestPlan);
m.put("data",xmTestPlan);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "批量修改某些字段",notes="")
@ApiEntityParams( value = XmTestPlan.class, props={ }, remark = "测试计划", paramType = "body" )
@ApiResponses({
@ApiResponse(code = 200,response=XmTestPlan.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
})
@RequestMapping(value="/editSomeFields",method=RequestMethod.POST)
public Map<String,Object> editSomeFields( @ApiIgnore @RequestBody Map<String,Object> xmTestPlanMap) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功更新一条数据");
try{
List<String> ids= (List<String>) xmTestPlanMap.get("ids");
if(ids==null || ids.size()==0){
return failed("ids-0","ids不能为空");
}
Set<String> fields=new HashSet<>();
fields.add("id");
for (String fieldName : xmTestPlanMap.keySet()) {
if(fields.contains(fieldName)){
return failed(fieldName+"-no-edit",fieldName+"不允许修改");
}
}
Set<String> fieldKey=xmTestPlanMap.keySet().stream().filter(i-> fieldsMap.containsKey(i)).collect(Collectors.toSet());
fieldKey=fieldKey.stream().filter(i->!StringUtils.isEmpty(xmTestPlanMap.get(i) )).collect(Collectors.toSet());
if(fieldKey.size()<=0) {
return failed("fieldKey-0","没有需要更新的字段");
}
XmTestPlan xmTestPlan = fromMap(xmTestPlanMap,XmTestPlan.class);
List<XmTestPlan> xmTestPlansDb=xmTestPlanService.selectListByIds(ids);
if(xmTestPlansDb==null ||xmTestPlansDb.size()==0){
return failed("data-0","记录已不存在");
}
List<XmTestPlan> can=new ArrayList<>();
List<XmTestPlan> no=new ArrayList<>();
User user = LoginUtils.getCurrentUserInfo();
for (XmTestPlan xmTestPlanDb : xmTestPlansDb) {
Tips tips2 = new Tips("检查通过");
if(!tips2.isOk()){
no.add(xmTestPlanDb);
}else{
can.add(xmTestPlanDb);
}
}
if(can.size()>0){
xmTestPlanMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList()));
xmTestPlanService.editSomeFields(xmTestPlanMap);
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
msgs.add(String.format("成功更新以下%s条数据",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s个数据无权限更新",no.size()));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
//m.put("data",xmMenu);
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
/**
@ApiOperation( value = "根据主键列表批量删除测试计划信息",notes=" ")
@ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
})
@RequestMapping(value="/batchDel",method=RequestMethod.POST)
public Map<String,Object> batchDelXmTestPlan(@RequestBody List<XmTestPlan> xmTestPlans) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功删除");
try{
if(xmTestPlans.size()<=0){
return failed("data-0","请上送待删除数据列表");
}
List<XmTestPlan> datasDb=xmTestPlanService.selectListByIds(xmTestPlans.stream().map(i-> i.getId() ).collect(Collectors.toList()));
List<XmTestPlan> can=new ArrayList<>();
List<XmTestPlan> no=new ArrayList<>();
for (XmTestPlan data : datasDb) {
if(true){
can.add(data);
}else{
no.add(data);
}
}
List<String> msgs=new ArrayList<>();
if(can.size()>0){
xmTestPlanService.batchDelete(can);
msgs.add(String.format("成功删除%s条数据.",can.size()));
}
if(no.size()>0){
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
}
if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
}else {
tips.setFailureMsg(msgs.stream().collect(Collectors.joining()));
}
}catch (BizException e) {
tips=e.getTips();
logger.error("",e);
}catch (Exception e) {
tips.setFailureMsg(e.getMessage());
logger.error("",e);
}
m.put("tips", tips);
return m;
}
*/
}

59
xm-core/src/main/java/com/xm/core/entity/XmTestCasedb.java

@ -0,0 +1,59 @@
package com.xm.core.entity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestCasedb所有属性名: <br>
* "id","主键","name","用例库名称","cuserid","创建人","cusername","创建人姓名","ctime","创建日期","cbranchId","归属机构编号","productId","产品编号","productName","产品名称";<br>
* 当前主键(包括多主键):<br>
* id;<br>
*/
@Data
@ApiModel(description="测试用例库")
public class XmTestCasedb implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes="主键,主键",allowEmptyValue=true,example="",allowableValues="")
String id;
@ApiModelProperty(notes="用例库名称",allowEmptyValue=true,example="",allowableValues="")
String name;
@ApiModelProperty(notes="创建人",allowEmptyValue=true,example="",allowableValues="")
String cuserid;
@ApiModelProperty(notes="创建人姓名",allowEmptyValue=true,example="",allowableValues="")
String cusername;
@ApiModelProperty(notes="创建日期",allowEmptyValue=true,example="",allowableValues="")
Date ctime;
@ApiModelProperty(notes="归属机构编号",allowEmptyValue=true,example="",allowableValues="")
String cbranchId;
@ApiModelProperty(notes="产品编号",allowEmptyValue=true,example="",allowableValues="")
String productId;
@ApiModelProperty(notes="产品名称",allowEmptyValue=true,example="",allowableValues="")
String productName;
/**
*主键
**/
public XmTestCasedb(String id) {
this.id = id;
}
/**
* 测试用例库
**/
public XmTestCasedb() {
}
}

98
xm-core/src/main/java/com/xm/core/entity/XmTestPlan.java

@ -0,0 +1,98 @@
package com.xm.core.entity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlan所有属性名: <br>
* "id","测试计划编号","name","计划名称","casedbId","用例库编号","casedbName","用例库名称","projectId","项目编号","projectName","项目名称","cuserid","创建人编号","cusername","创建人名称","ctime","创建时间","stime","开始时间","etime","结束时间","status","状态0-未开始,1-进行中,2已结束","tcode","测试结果0未通过,1已通过","totalCases","总用例数","okCases","通过用例数","errCases","失败用例数","igCases","忽略用例数","blCases","阻塞用例数","productId","产品编号","productName","产品名称","flowState","评审结果0-待评审,1-已评审通过,2-已拒绝";<br>
* 当前主键(包括多主键):<br>
* id;<br>
*/
@Data
@ApiModel(description="测试计划")
public class XmTestPlan implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes="测试计划编号,主键",allowEmptyValue=true,example="",allowableValues="")
String id;
@ApiModelProperty(notes="计划名称",allowEmptyValue=true,example="",allowableValues="")
String name;
@ApiModelProperty(notes="用例库编号",allowEmptyValue=true,example="",allowableValues="")
String casedbId;
@ApiModelProperty(notes="用例库名称",allowEmptyValue=true,example="",allowableValues="")
String casedbName;
@ApiModelProperty(notes="项目编号",allowEmptyValue=true,example="",allowableValues="")
String projectId;
@ApiModelProperty(notes="项目名称",allowEmptyValue=true,example="",allowableValues="")
String projectName;
@ApiModelProperty(notes="创建人编号",allowEmptyValue=true,example="",allowableValues="")
String cuserid;
@ApiModelProperty(notes="创建人名称",allowEmptyValue=true,example="",allowableValues="")
String cusername;
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="")
Date ctime;
@ApiModelProperty(notes="开始时间",allowEmptyValue=true,example="",allowableValues="")
Date stime;
@ApiModelProperty(notes="结束时间",allowEmptyValue=true,example="",allowableValues="")
Date etime;
@ApiModelProperty(notes="状态0-未开始,1-进行中,2已结束",allowEmptyValue=true,example="",allowableValues="")
String status;
@ApiModelProperty(notes="测试结果0未通过,1已通过",allowEmptyValue=true,example="",allowableValues="")
String tcode;
@ApiModelProperty(notes="总用例数",allowEmptyValue=true,example="",allowableValues="")
Integer totalCases;
@ApiModelProperty(notes="通过用例数",allowEmptyValue=true,example="",allowableValues="")
Integer okCases;
@ApiModelProperty(notes="失败用例数",allowEmptyValue=true,example="",allowableValues="")
Integer errCases;
@ApiModelProperty(notes="忽略用例数",allowEmptyValue=true,example="",allowableValues="")
Integer igCases;
@ApiModelProperty(notes="阻塞用例数",allowEmptyValue=true,example="",allowableValues="")
Integer blCases;
@ApiModelProperty(notes="产品编号",allowEmptyValue=true,example="",allowableValues="")
String productId;
@ApiModelProperty(notes="产品名称",allowEmptyValue=true,example="",allowableValues="")
String productName;
@ApiModelProperty(notes="评审结果0-待评审,1-已评审通过,2-已拒绝",allowEmptyValue=true,example="",allowableValues="")
String flowState;
/**
*测试计划编号
**/
public XmTestPlan(String id) {
this.id = id;
}
/**
* 测试计划
**/
public XmTestPlan() {
}
}

72
xm-core/src/main/java/com/xm/core/entity/XmTestPlanCase.java

@ -0,0 +1,72 @@
package com.xm.core.entity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
/**
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlanCase所有属性名: <br>
* "bugs","bug数目","execUserid","执行人","caseId","测试用例编号","ltime","更新时间","ctime","创建时间","execStatus","0-未测,1-通过,2-受阻,3-忽略,4-失败","execUsername","执行人姓名","planId","计划编号","caseName","用例名称","priority","优先级","remark","执行备注","testStep","测试步骤";<br>
* 当前主键(包括多主键):<br>
* case_id,plan_id;<br>
*/
@Data
@ApiModel(description="测试计划与用例关系表")
public class XmTestPlanCase implements java.io.Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes="测试用例编号,主键",allowEmptyValue=true,example="",allowableValues="")
String caseId;
@ApiModelProperty(notes="计划编号,主键",allowEmptyValue=true,example="",allowableValues="")
String planId;
@ApiModelProperty(notes="bug数目",allowEmptyValue=true,example="",allowableValues="")
Integer bugs;
@ApiModelProperty(notes="执行人",allowEmptyValue=true,example="",allowableValues="")
String execUserid;
@ApiModelProperty(notes="更新时间",allowEmptyValue=true,example="",allowableValues="")
Date ltime;
@ApiModelProperty(notes="创建时间",allowEmptyValue=true,example="",allowableValues="")
Date ctime;
@ApiModelProperty(notes="0-未测,1-通过,2-受阻,3-忽略,4-失败",allowEmptyValue=true,example="",allowableValues="")
String execStatus;
@ApiModelProperty(notes="执行人姓名",allowEmptyValue=true,example="",allowableValues="")
String execUsername;
@ApiModelProperty(notes="用例名称",allowEmptyValue=true,example="",allowableValues="")
String caseName;
@ApiModelProperty(notes="优先级",allowEmptyValue=true,example="",allowableValues="")
String priority;
@ApiModelProperty(notes="执行备注",allowEmptyValue=true,example="",allowableValues="")
String remark;
@ApiModelProperty(notes="测试步骤",allowEmptyValue=true,example="",allowableValues="")
String testStep;
/**
*测试用例编号,计划编号
**/
public XmTestPlanCase(String caseId,String planId) {
this.caseId = caseId;
this.planId = planId;
}
/**
* 测试计划与用例关系表
**/
public XmTestPlanCase() {
}
}

24
xm-core/src/main/java/com/xm/core/service/XmTestCasedbService.java

@ -0,0 +1,24 @@
package com.xm.core.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.mdp.core.service.BaseService;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.xm.core.entity.XmTestCasedb;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestCasedb xm_test_casedb 当前主键(包括多主键): id;
***/
@Service("xm.core.xmTestCasedbService")
public class XmTestCasedbService extends BaseService {
static Logger logger =LoggerFactory.getLogger(XmTestCasedbService.class);
}

24
xm-core/src/main/java/com/xm/core/service/XmTestPlanCaseService.java

@ -0,0 +1,24 @@
package com.xm.core.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.mdp.core.service.BaseService;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.xm.core.entity.XmTestPlanCase;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlanCase xm_test_plan_case 当前主键(包括多主键): case_id,plan_id;
***/
@Service("xm.core.xmTestPlanCaseService")
public class XmTestPlanCaseService extends BaseService {
static Logger logger =LoggerFactory.getLogger(XmTestPlanCaseService.class);
}

24
xm-core/src/main/java/com/xm/core/service/XmTestPlanService.java

@ -0,0 +1,24 @@
package com.xm.core.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.mdp.core.service.BaseService;
import static com.mdp.core.utils.BaseUtils.*;
import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.xm.core.entity.XmTestPlan;
/**
* 父类已经支持增删改查操作,因此,即使本类什么也不写,也已经可以满足一般的增删改查操作了.<br>
* 组织 com 顶级模块 xm 大模块 core 小模块 <br>
* 实体 XmTestPlan xm_test_plan 当前主键(包括多主键): id;
***/
@Service("xm.core.xmTestPlanService")
public class XmTestPlanService extends BaseService {
static Logger logger =LoggerFactory.getLogger(XmTestPlanService.class);
}

188
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestCasedbMapper.xml

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xm.core.entity.XmTestCasedb">
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 -->
<sql id="whereForMap">
<if test=" ids != null"> and (res.id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</if>
<if test="key != null and key !='' "> </if>
</sql>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select * from xm_test_casedb res
<where>
<include refid="whereForMap"/>
<include refid="where"/>
</where>
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmTestCasedb" resultType="com.xm.core.entity.XmTestCasedb">
select * from xm_test_casedb res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmTestCasedb" resultType="com.xm.core.entity.XmTestCasedb">
select * from xm_test_casedb res
where
res.id = #{id}
</select>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmTestCasedb">
select * from xm_test_casedb res
where (res.id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_test_casedb res
where
res.id = #{id}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmTestCasedb" resultType="long">
select count(*) from xm_test_casedb res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmTestCasedb" useGeneratedKeys="false" keyProperty="id">
insert into xm_test_casedb(
<include refid="columns"/>
) values (
#{id},#{name},#{cuserid},#{cusername},#{ctime},#{cbranchId},#{productId},#{productName}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmTestCasedb">
delete from xm_test_casedb res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmTestCasedb">
delete from xm_test_casedb
where id = #{id}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmTestCasedb">
update xm_test_casedb
<set>
<include refid="someFieldSet"/>
</set>
where id = #{id}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmTestCasedb">
update xm_test_casedb
<set>
<include refid="set"/>
</set>
where id = #{id}
</update>
<!-- 批量新增 批量插入 借用insert 循环插入实现
<insert id="batchInsert" parameterType="List">
</insert>
-->
<!-- 批量更新 -->
<update id="batchUpdate" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
update xm_test_casedb
set
<include refid="batchSet"/>
where id = #{item.id}
</foreach>
</update>
<!-- 批量修改某几个字段 -->
<delete id="editSomeFields" parameterType="HashMap">
update xm_test_casedb
<set>
<include refid="someFieldSet"/>
</set>
where (id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</delete>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_test_casedb
where
(id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.id} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
id,name,cuserid,cusername,ctime,cbranch_id,product_id,product_name
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="id != null and id != ''"> and res.id = #{id} </if>
<if test="name != null and name != ''"> and res.name = #{name} </if>
<if test="cuserid != null and cuserid != ''"> and res.cuserid = #{cuserid} </if>
<if test="cusername != null and cusername != ''"> and res.cusername = #{cusername} </if>
<if test="ctime != null"> and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') </if>
<if test="cbranchId != null and cbranchId != ''"> and res.cbranch_id = #{cbranchId} </if>
<if test="productId != null and productId != ''"> and res.product_id = #{productId} </if>
<if test="productName != null and productName != ''"> and res.product_name = #{productName} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
name = #{name},
cuserid = #{cuserid},
cusername = #{cusername},
ctime = #{ctime},
cbranch_id = #{cbranchId},
product_id = #{productId},
product_name = #{productName}
</sql>
<sql id="someFieldSet">
<if test="name != null and name != ''"> name = #{name}, </if>
<if test="cuserid != null and cuserid != ''"> cuserid = #{cuserid}, </if>
<if test="cusername != null and cusername != ''"> cusername = #{cusername}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if>
<if test="cbranchId != null and cbranchId != ''"> cbranch_id = #{cbranchId}, </if>
<if test="productId != null and productId != ''"> product_id = #{productId}, </if>
<if test="productName != null and productName != ''"> product_name = #{productName}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
name = #{item.name},
cuserid = #{item.cuserid},
cusername = #{item.cusername},
ctime = #{item.ctime},
cbranch_id = #{item.cbranchId},
product_id = #{item.productId},
product_name = #{item.productName}
</sql>
</mapper>

203
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestPlanCaseMapper.xml

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xm.core.entity.XmTestPlanCase">
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 -->
<sql id="whereForMap">
<if test=" pkList != null"> and (res.case_id, res.plan_id) in
<foreach collection="pkList" item="item" index="index" open="(" separator="," close=")" >
( #{item.caseId}, #{item.planId})
</foreach>
</if>
<if test="key != null and key !='' "> </if>
</sql>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select * from xm_test_plan_case res
<where>
<include refid="whereForMap"/>
<include refid="where"/>
</where>
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmTestPlanCase" resultType="com.xm.core.entity.XmTestPlanCase">
select * from xm_test_plan_case res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmTestPlanCase" resultType="com.xm.core.entity.XmTestPlanCase">
select * from xm_test_plan_case res
where
res.case_id = #{caseId}
and res.plan_id = #{planId}
</select>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmTestPlanCase">
select * from xm_test_plan_case res
where (res.case_id, res.plan_id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.caseId}, #{item.planId})
</foreach>
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_test_plan_case res
where
res.case_id = #{caseId}
and res.plan_id = #{planId}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmTestPlanCase" resultType="long">
select count(*) from xm_test_plan_case res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键case_id,plan_id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmTestPlanCase" useGeneratedKeys="false" >
insert into xm_test_plan_case(
<include refid="columns"/>
) values (
#{bugs},#{execUserid},#{caseId},#{ltime},#{ctime},#{execStatus},#{execUsername},#{planId},#{caseName},#{priority},#{remark},#{testStep}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmTestPlanCase">
delete from xm_test_plan_case res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmTestPlanCase">
delete from xm_test_plan_case
where case_id = #{caseId} and plan_id = #{planId}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmTestPlanCase">
update xm_test_plan_case
<set>
<include refid="someFieldSet"/>
</set>
where case_id = #{caseId} and plan_id = #{planId}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmTestPlanCase">
update xm_test_plan_case
<set>
<include refid="set"/>
</set>
where case_id = #{caseId} and plan_id = #{planId}
</update>
<!-- 批量新增 批量插入 借用insert 循环插入实现
<insert id="batchInsert" parameterType="List">
</insert>
-->
<!-- 批量更新 -->
<update id="batchUpdate" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
update xm_test_plan_case
set
<include refid="batchSet"/>
where case_id = #{item.caseId} and plan_id = #{item.planId}
</foreach>
</update>
<!-- 批量修改某几个字段 -->
<delete id="editSomeFields" parameterType="HashMap">
update xm_test_plan_case
<set>
<include refid="someFieldSet"/>
</set>
where (case_id, plan_id) in
<foreach collection="pkList" item="item" index="index" open="(" separator="," close=")" >
( #{item.caseId}, #{item.planId})
</foreach>
</delete>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_test_plan_case
where
(case_id, plan_id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.caseId}, #{item.planId} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
bugs,exec_userid,case_id,ltime,ctime,exec_status,exec_username,plan_id,case_name,priority,remark,test_step
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="bugs != null and bugs != ''"> and res.bugs = #{bugs} </if>
<if test="execUserid != null and execUserid != ''"> and res.exec_userid = #{execUserid} </if>
<if test="caseId != null and caseId != ''"> and res.case_id = #{caseId} </if>
<if test="ltime != null"> and date_format(res.ltime,'%Y-%m-%d') = date_format(#{ltime},'%Y-%m-%d') </if>
<if test="ctime != null"> and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') </if>
<if test="execStatus != null and execStatus != ''"> and res.exec_status = #{execStatus} </if>
<if test="execUsername != null and execUsername != ''"> and res.exec_username = #{execUsername} </if>
<if test="planId != null and planId != ''"> and res.plan_id = #{planId} </if>
<if test="caseName != null and caseName != ''"> and res.case_name = #{caseName} </if>
<if test="priority != null and priority != ''"> and res.priority = #{priority} </if>
<if test="remark != null and remark != ''"> and res.remark = #{remark} </if>
<if test="testStep != null and testStep != ''"> and res.test_step = #{testStep} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
bugs = #{bugs},
exec_userid = #{execUserid},
ltime = #{ltime},
ctime = #{ctime},
exec_status = #{execStatus},
exec_username = #{execUsername},
case_name = #{caseName},
priority = #{priority},
remark = #{remark},
test_step = #{testStep}
</sql>
<sql id="someFieldSet">
<if test="bugs != null and bugs != ''"> bugs = #{bugs}, </if>
<if test="execUserid != null and execUserid != ''"> exec_userid = #{execUserid}, </if>
<if test="ltime != null"> ltime = #{ltime}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if>
<if test="execStatus != null and execStatus != ''"> exec_status = #{execStatus}, </if>
<if test="execUsername != null and execUsername != ''"> exec_username = #{execUsername}, </if>
<if test="caseName != null and caseName != ''"> case_name = #{caseName}, </if>
<if test="priority != null and priority != ''"> priority = #{priority}, </if>
<if test="remark != null and remark != ''"> remark = #{remark}, </if>
<if test="testStep != null and testStep != ''"> test_step = #{testStep}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
bugs = #{item.bugs},
exec_userid = #{item.execUserid},
ltime = #{item.ltime},
ctime = #{item.ctime},
exec_status = #{item.execStatus},
exec_username = #{item.execUsername},
case_name = #{item.caseName},
priority = #{item.priority},
remark = #{item.remark},
test_step = #{item.testStep}
</sql>
</mapper>

240
xm-core/src/main/resources/mybatis/mapper/xm/core/dao/XmTestPlanMapper.xml

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xm.core.entity.XmTestPlan">
<!--开始 自定sql函数区域 请在此区域添加自定义函数,其它区域尽量不要动,因为代码随时重新生成 -->
<sql id="whereForMap">
<if test=" ids != null"> and (res.id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</if>
<if test="key != null and key !='' "> </if>
</sql>
<!--结束 自定义sql函数区域-->
<!-- 通过条件查询获取数据列表 返回list<map> -->
<select id="selectListMapByWhere" parameterType="HashMap" resultType="HashMap">
select * from xm_test_plan res
<where>
<include refid="whereForMap"/>
<include refid="where"/>
</where>
</select>
<!-- 通过条件查询获取数据列表 不分页 返回 list<Object> -->
<select id="selectListByWhere" parameterType="com.xm.core.entity.XmTestPlan" resultType="com.xm.core.entity.XmTestPlan">
select * from xm_test_plan res
<where>
<include refid="where"/>
</where>
</select>
<!-- 通过主键查询获取数据对象 返回object -->
<select id="selectOneObject" parameterType="com.xm.core.entity.XmTestPlan" resultType="com.xm.core.entity.XmTestPlan">
select * from xm_test_plan res
where
res.id = #{id}
</select>
<select id="selectListByIds" parameterType="List" resultType="com.xm.core.entity.XmTestPlan">
select * from xm_test_plan res
where (res.id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</select>
<!-- 通过主键查询获取数据对象 返回map-->
<select id="selectOneMap" parameterType="HashMap" resultType="HashMap">
select * from xm_test_plan res
where
res.id = #{id}
</select>
<!-- 获取数据条目 返回long -->
<select id="countByWhere" parameterType="com.xm.core.entity.XmTestPlan" resultType="long">
select count(*) from xm_test_plan res
<where>
<include refid="where"/>
</where>
</select>
<!-- 新增一条记录 主键id,-->
<insert id="insert" parameterType="com.xm.core.entity.XmTestPlan" useGeneratedKeys="false" keyProperty="id">
insert into xm_test_plan(
<include refid="columns"/>
) values (
#{id},#{name},#{casedbId},#{casedbName},#{projectId},#{projectName},#{cuserid},#{cusername},#{ctime},#{stime},#{etime},#{status},#{tcode},#{totalCases},#{okCases},#{errCases},#{igCases},#{blCases},#{productId},#{productName},#{flowState}
)
</insert>
<!-- 按条件删除若干条记录-->
<delete id="deleteByWhere" parameterType="com.xm.core.entity.XmTestPlan">
delete from xm_test_plan res
<where>
<include refid="where"/>
</where>
</delete>
<!-- 按主键删除一条记录-->
<delete id="deleteByPk" parameterType="com.xm.core.entity.XmTestPlan">
delete from xm_test_plan
where id = #{id}
</delete>
<!-- 根据条件修改若干条记录 -->
<update id="updateSomeFieldByPk" parameterType="com.xm.core.entity.XmTestPlan">
update xm_test_plan
<set>
<include refid="someFieldSet"/>
</set>
where id = #{id}
</update>
<!-- 根据主键修改一条记录 -->
<update id="updateByPk" parameterType="com.xm.core.entity.XmTestPlan">
update xm_test_plan
<set>
<include refid="set"/>
</set>
where id = #{id}
</update>
<!-- 批量新增 批量插入 借用insert 循环插入实现
<insert id="batchInsert" parameterType="List">
</insert>
-->
<!-- 批量更新 -->
<update id="batchUpdate" parameterType="List">
<foreach collection="list" item="item" index="index" separator=";" >
update xm_test_plan
set
<include refid="batchSet"/>
where id = #{item.id}
</foreach>
</update>
<!-- 批量修改某几个字段 -->
<delete id="editSomeFields" parameterType="HashMap">
update xm_test_plan
<set>
<include refid="someFieldSet"/>
</set>
where (id) in
<foreach collection="ids" item="item" index="index" open="(" separator="," close=")" >
( #{item})
</foreach>
</delete>
<!-- 批量删除 -->
<delete id="batchDelete" parameterType="List">
delete from xm_test_plan
where
(id) in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")" >
( #{item.id} )
</foreach>
</delete>
<!--sql片段 列-->
<sql id="columns">
id,name,casedb_id,casedb_name,project_id,project_name,cuserid,cusername,ctime,stime,etime,status,tcode,total_cases,ok_cases,err_cases,ig_cases,bl_cases,product_id,product_name,flow_state
</sql>
<!--sql片段 动态条件 YYYY-MM-DD HH24:MI:SS-->
<sql id="where">
<if test="id != null and id != ''"> and res.id = #{id} </if>
<if test="name != null and name != ''"> and res.name = #{name} </if>
<if test="casedbId != null and casedbId != ''"> and res.casedb_id = #{casedbId} </if>
<if test="casedbName != null and casedbName != ''"> and res.casedb_name = #{casedbName} </if>
<if test="projectId != null and projectId != ''"> and res.project_id = #{projectId} </if>
<if test="projectName != null and projectName != ''"> and res.project_name = #{projectName} </if>
<if test="cuserid != null and cuserid != ''"> and res.cuserid = #{cuserid} </if>
<if test="cusername != null and cusername != ''"> and res.cusername = #{cusername} </if>
<if test="ctime != null"> and date_format(res.ctime,'%Y-%m-%d') = date_format(#{ctime},'%Y-%m-%d') </if>
<if test="stime != null"> and date_format(res.stime,'%Y-%m-%d') = date_format(#{stime},'%Y-%m-%d') </if>
<if test="etime != null"> and date_format(res.etime,'%Y-%m-%d') = date_format(#{etime},'%Y-%m-%d') </if>
<if test="status != null and status != ''"> and res.status = #{status} </if>
<if test="tcode != null and tcode != ''"> and res.tcode = #{tcode} </if>
<if test="totalCases != null and totalCases != ''"> and res.total_cases = #{totalCases} </if>
<if test="okCases != null and okCases != ''"> and res.ok_cases = #{okCases} </if>
<if test="errCases != null and errCases != ''"> and res.err_cases = #{errCases} </if>
<if test="igCases != null and igCases != ''"> and res.ig_cases = #{igCases} </if>
<if test="blCases != null and blCases != ''"> and res.bl_cases = #{blCases} </if>
<if test="productId != null and productId != ''"> and res.product_id = #{productId} </if>
<if test="productName != null and productName != ''"> and res.product_name = #{productName} </if>
<if test="flowState != null and flowState != ''"> and res.flow_state = #{flowState} </if>
</sql>
<!--sql片段 更新字段 -->
<sql id="set">
name = #{name},
casedb_id = #{casedbId},
casedb_name = #{casedbName},
project_id = #{projectId},
project_name = #{projectName},
cuserid = #{cuserid},
cusername = #{cusername},
ctime = #{ctime},
stime = #{stime},
etime = #{etime},
status = #{status},
tcode = #{tcode},
total_cases = #{totalCases},
ok_cases = #{okCases},
err_cases = #{errCases},
ig_cases = #{igCases},
bl_cases = #{blCases},
product_id = #{productId},
product_name = #{productName},
flow_state = #{flowState}
</sql>
<sql id="someFieldSet">
<if test="name != null and name != ''"> name = #{name}, </if>
<if test="casedbId != null and casedbId != ''"> casedb_id = #{casedbId}, </if>
<if test="casedbName != null and casedbName != ''"> casedb_name = #{casedbName}, </if>
<if test="projectId != null and projectId != ''"> project_id = #{projectId}, </if>
<if test="projectName != null and projectName != ''"> project_name = #{projectName}, </if>
<if test="cuserid != null and cuserid != ''"> cuserid = #{cuserid}, </if>
<if test="cusername != null and cusername != ''"> cusername = #{cusername}, </if>
<if test="ctime != null"> ctime = #{ctime}, </if>
<if test="stime != null"> stime = #{stime}, </if>
<if test="etime != null"> etime = #{etime}, </if>
<if test="status != null and status != ''"> status = #{status}, </if>
<if test="tcode != null and tcode != ''"> tcode = #{tcode}, </if>
<if test="totalCases != null and totalCases != ''"> total_cases = #{totalCases}, </if>
<if test="okCases != null and okCases != ''"> ok_cases = #{okCases}, </if>
<if test="errCases != null and errCases != ''"> err_cases = #{errCases}, </if>
<if test="igCases != null and igCases != ''"> ig_cases = #{igCases}, </if>
<if test="blCases != null and blCases != ''"> bl_cases = #{blCases}, </if>
<if test="productId != null and productId != ''"> product_id = #{productId}, </if>
<if test="productName != null and productName != ''"> product_name = #{productName}, </if>
<if test="flowState != null and flowState != ''"> flow_state = #{flowState}, </if>
</sql>
<!--sql片段 批量更新 -->
<sql id="batchSet">
name = #{item.name},
casedb_id = #{item.casedbId},
casedb_name = #{item.casedbName},
project_id = #{item.projectId},
project_name = #{item.projectName},
cuserid = #{item.cuserid},
cusername = #{item.cusername},
ctime = #{item.ctime},
stime = #{item.stime},
etime = #{item.etime},
status = #{item.status},
tcode = #{item.tcode},
total_cases = #{item.totalCases},
ok_cases = #{item.okCases},
err_cases = #{item.errCases},
ig_cases = #{item.igCases},
bl_cases = #{item.blCases},
product_id = #{item.productId},
product_name = #{item.productName},
flow_state = #{item.flowState}
</sql>
</mapper>
Loading…
Cancel
Save