Browse Source

团队重构

master
陈裕财 3 years ago
parent
commit
e97d6e7bc4
  1. 98
      xm-core/src/main/java/com/xm/core/ctrl/XmTestCasedbController.java
  2. 81
      xm-core/src/main/java/com/xm/core/ctrl/XmTestPlanController.java

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

@ -10,6 +10,7 @@ import com.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmProduct; import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmTestCasedb; import com.xm.core.entity.XmTestCasedb;
import com.xm.core.service.XmGroupService; import com.xm.core.service.XmGroupService;
import com.xm.core.service.XmProductQxService;
import com.xm.core.service.XmProductService; import com.xm.core.service.XmProductService;
import com.xm.core.service.XmTestCasedbService; import com.xm.core.service.XmTestCasedbService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -47,6 +48,8 @@ public class XmTestCasedbController {
@Autowired @Autowired
XmProductService productService; XmProductService productService;
@Autowired
XmProductQxService productQxService;
Map<String,Object> fieldsMap = toMap(new XmTestCasedb()); Map<String,Object> fieldsMap = toMap(new XmTestCasedb());
@ -106,9 +109,13 @@ public class XmTestCasedbController {
} }
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能创建测试用例库。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestCasedb.getCuserid(),xmTestCasedb.getCusername(),xmTestCasedb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
xmTestCasedb.setCtime(new Date()); xmTestCasedb.setCtime(new Date());
xmTestCasedb.setCuserid(user.getUserid()); xmTestCasedb.setCuserid(user.getUserid());
xmTestCasedb.setCusername(user.getUsername()); xmTestCasedb.setCusername(user.getUsername());
@ -143,13 +150,14 @@ public class XmTestCasedbController {
return failed("data-not-exists","数据不存在,无法删除"); return failed("data-not-exists","数据不存在,无法删除");
} }
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
if(!user.getBranchId().equals(xmTestCasedbDb.getCbranchId())){
return failed("cbranchId-err","该测试库不属于您企业,不能删除");
}
XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试用例库。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestCasedbDb.getCuserid(),xmTestCasedbDb.getCusername(),xmTestCasedbDb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
xmTestCasedbService.deleteByPk(xmTestCasedb); xmTestCasedbService.deleteByPk(xmTestCasedb);
}catch (BizException e) { }catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
@ -180,13 +188,20 @@ public class XmTestCasedbController {
} }
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
if(!user.getBranchId().equals(xmTestCasedbDb.getCbranchId())){
return failed("cbranchId-err","该测试库不属于您企业,不能修改");
}
XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能修改测试用例库。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(StringUtils.hasText(xmTestCasedb.getCuserid())){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestCasedb.getCuserid(),xmTestCasedb.getCusername(),xmTestCasedb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestCasedbDb.getCuserid(),xmTestCasedbDb.getCusername(),xmTestCasedbDb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
xmTestCasedbService.updateSomeFieldByPk(xmTestCasedb); xmTestCasedbService.updateSomeFieldByPk(xmTestCasedb);
m.put("data",xmTestCasedb); m.put("data",xmTestCasedb);
}catch (BizException e) { }catch (BizException e) {
@ -233,22 +248,35 @@ public class XmTestCasedbController {
if(xmTestCasedbsDb==null ||xmTestCasedbsDb.size()==0){ if(xmTestCasedbsDb==null ||xmTestCasedbsDb.size()==0){
return failed("data-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(!user.getBranchId().equals(xmTestCasedbDb.getCbranchId())){
return failed("cbranchId-err","该测试库不属于您企业,不能修改");
XmTestCasedb xmTestCasedbDb=xmTestCasedbsDb.get(0);
if(xmTestCasedbsDb.stream().filter(k->!k.getProductId().equals(xmTestCasedbDb.getProductId())).findAny().isPresent()){
return failed("product-0","批量操作只能在同一批产品中进行");
} }
User user = LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestCasedbDb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能修改测试用例库。");
};
if(!tips2.isOk()){
no.add(xmTestCasedbDb);
if(StringUtils.hasText(xmTestCasedb.getCuserid())){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestCasedb.getCuserid(),xmTestCasedb.getCusername(),xmTestCasedb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb, user.getUserid());
List<XmTestCasedb> can=new ArrayList<>();
List<XmTestCasedb> no=new ArrayList<>();
Set<String> noTips=new HashSet<>();
for (XmTestCasedb data : xmTestCasedbsDb) {
if(isPm){
can.add(data);
}else{ }else{
can.add(xmTestCasedbDb);
tips=productQxService.checkProductQx(null,xmProductDb,1,user,data.getCuserid(),data.getCusername(),data.getCbranchId());
if(!tips.isOk()){
no.add(data);
noTips.add(tips.getMsg());
}else{
can.add(data);
}
} }
} }
if(can.size()>0){ if(can.size()>0){
@ -295,17 +323,21 @@ public class XmTestCasedbController {
List<XmTestCasedb> can=new ArrayList<>(); List<XmTestCasedb> can=new ArrayList<>();
List<XmTestCasedb> no=new ArrayList<>(); List<XmTestCasedb> no=new ArrayList<>();
Set<String> noTips=new HashSet<>();
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
for (XmTestCasedb data : datasDb) { for (XmTestCasedb data : datasDb) {
XmProduct xmProductDb=productService.getProductFromCache(data.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(data.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试用例库。");
};
if(user.getBranchId().equals(data.getCbranchId())){
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb, user.getUserid());
if(isPm){
can.add(data); can.add(data);
}else{ }else{
tips=productQxService.checkProductQx(null,xmProductDb,1,user,data.getCuserid(),data.getCusername(),data.getCbranchId());
if(!tips.isOk()){
no.add(data); no.add(data);
noTips.add(tips.getMsg());
}else{
can.add(data);
}
} }
} }
List<String> msgs=new ArrayList<>(); List<String> msgs=new ArrayList<>();

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

@ -10,6 +10,7 @@ import com.mdp.swagger.ApiEntityParams;
import com.xm.core.entity.XmProduct; import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmTestPlan; import com.xm.core.entity.XmTestPlan;
import com.xm.core.service.XmGroupService; import com.xm.core.service.XmGroupService;
import com.xm.core.service.XmProductQxService;
import com.xm.core.service.XmProductService; import com.xm.core.service.XmProductService;
import com.xm.core.service.XmTestPlanService; import com.xm.core.service.XmTestPlanService;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -48,6 +49,9 @@ public class XmTestPlanController {
@Autowired @Autowired
XmProductService productService; XmProductService productService;
@Autowired
XmProductQxService productQxService;
Map<String,Object> fieldsMap = toMap(new XmTestPlan()); Map<String,Object> fieldsMap = toMap(new XmTestPlan());
@ -138,9 +142,13 @@ public class XmTestPlanController {
} }
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestPlan.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestPlan.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmTestPlan.getProductId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能创建测试计划。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestPlan.getCuserid(),xmTestPlan.getCusername(),xmTestPlan.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
}
xmTestPlan.setCuserid(user.getUserid()); xmTestPlan.setCuserid(user.getUserid());
xmTestPlan.setCusername(user.getUsername()); xmTestPlan.setCusername(user.getUsername());
xmTestPlan.setCtime(new Date()); xmTestPlan.setCtime(new Date());
@ -177,11 +185,12 @@ public class XmTestPlanController {
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试计划。");
};
if(!user.getBranchId().equals(xmTestPlanDb.getCbranchId())){
return failed("cbranchId-err","该计划不属于您的企业创建,无权删除");
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestPlanDb.getCuserid(),xmTestPlanDb.getCusername(),xmTestPlanDb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
} }
xmTestPlanService.deleteByPk(xmTestPlan); xmTestPlanService.deleteByPk(xmTestPlan);
}catch (BizException e) { }catch (BizException e) {
@ -212,13 +221,15 @@ public class XmTestPlanController {
return failed("data-not-exists","数据不存在,无法修改"); return failed("data-not-exists","数据不存在,无法修改");
} }
User user=LoginUtils.getCurrentUserInfo(); User user=LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试计划。");
};
if(!user.getBranchId().equals(xmTestPlanDb.getCbranchId())){
return failed("cbranchId-err","该计划不属于您的企业创建,无权修改");
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
if(!isPm){
tips=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestPlanDb.getCuserid(),xmTestPlanDb.getCusername(),xmTestPlanDb.getCbranchId());
if(!tips.isOk()){
return failed(tips);
}
} }
xmTestPlanService.updateSomeFieldByPk(xmTestPlan); xmTestPlanService.updateSomeFieldByPk(xmTestPlan);
m.put("data",xmTestPlan); m.put("data",xmTestPlan);
@ -272,24 +283,25 @@ public class XmTestPlanController {
} }
User user = LoginUtils.getCurrentUserInfo(); User user = LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb2.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb2.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试计划。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
List<XmTestPlan> can=new ArrayList<>(); List<XmTestPlan> can=new ArrayList<>();
List<XmTestPlan> no=new ArrayList<>(); List<XmTestPlan> no=new ArrayList<>();
Set<String> noTips=new HashSet<>();
for (XmTestPlan xmTestPlanDb : xmTestPlansDb) { for (XmTestPlan xmTestPlanDb : xmTestPlansDb) {
Tips tips2 = new Tips("检查通过"); Tips tips2 = new Tips("检查通过");
if(!user.getBranchId().equals(xmTestPlanDb.getCbranchId())){
return failed("cbranchId-err","该计划不属于您的企业创建,无权修改");
}
if(isPm){
can.add(xmTestPlanDb);
}else{
tips2=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestPlanDb.getCuserid(),xmTestPlanDb.getCusername(),xmTestPlanDb.getCbranchId());
if(!tips2.isOk()){ if(!tips2.isOk()){
no.add(xmTestPlanDb); no.add(xmTestPlanDb);
noTips.add(tips2.getMsg());
}else{ }else{
can.add(xmTestPlanDb); can.add(xmTestPlanDb);
} }
} }
}
if(can.size()>0){ if(can.size()>0){
xmTestPlanMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList())); xmTestPlanMap.put("ids",can.stream().map(i->i.getId()).collect(Collectors.toList()));
xmTestPlanService.editSomeFields(xmTestPlanMap); xmTestPlanService.editSomeFields(xmTestPlanMap);
@ -299,7 +311,7 @@ public class XmTestPlanController {
msgs.add(String.format("成功更新以下%s条数据",can.size())); msgs.add(String.format("成功更新以下%s条数据",can.size()));
} }
if(no.size()>0){ if(no.size()>0){
msgs.add(String.format("以下%s个数据无权限更新",no.size()));
msgs.add(String.format("以下%s个数据无权限更新,原因【%s】",no.size(),noTips.stream().collect(Collectors.joining(";"))));
} }
if(can.size()>0){ if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining())); tips.setOkMsg(msgs.stream().collect(Collectors.joining()));
@ -337,19 +349,24 @@ public class XmTestPlanController {
} }
User user = LoginUtils.getCurrentUserInfo(); User user = LoginUtils.getCurrentUserInfo();
XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb2.getProductId()); XmProduct xmProductDb=productService.getProductFromCache(xmTestPlanDb2.getProductId());
if(!groupService.checkUserIsProductAdm(xmProductDb,user.getUserid()) && !groupService.checkUserExistsProductGroup(xmProductDb.getId(),user.getUserid())){
return failed("no-in-pteam","您不是产品团队成员,不能删除测试计划。");
};
boolean isPm=groupService.checkUserIsProductAdm(xmProductDb,user.getUserid());
List<XmTestPlan> can=new ArrayList<>(); List<XmTestPlan> can=new ArrayList<>();
List<XmTestPlan> no=new ArrayList<>(); List<XmTestPlan> no=new ArrayList<>();
for (XmTestPlan data : datasDb) {
if(user.getBranchId().equals(data.getCbranchId())){
can.add(data);
Set<String> noTips=new HashSet<>();
for (XmTestPlan xmTestPlanDb : datasDb) {
Tips tips2 = new Tips("检查通过");
if(isPm){
can.add(xmTestPlanDb);
}else{ }else{
no.add(data);
tips2=productQxService.checkProductQx(null,xmProductDb,1,user,xmTestPlanDb.getCuserid(),xmTestPlanDb.getCusername(),xmTestPlanDb.getCbranchId());
if(!tips2.isOk()){
no.add(xmTestPlanDb);
noTips.add(tips2.getMsg());
}else{
can.add(xmTestPlanDb);
}
} }
} }
List<String> msgs=new ArrayList<>(); List<String> msgs=new ArrayList<>();
if(can.size()>0){ if(can.size()>0){
@ -358,7 +375,7 @@ public class XmTestPlanController {
} }
if(no.size()>0){ if(no.size()>0){
msgs.add(String.format("以下%s条数据不能删除.【%s】",no.size(),no.stream().map(i-> i.getId() ).collect(Collectors.joining(","))));
msgs.add(String.format("有%s条数据无权限删除.原因【%s】",no.size(), noTips.stream().collect(Collectors.joining(";"))));
} }
if(can.size()>0){ if(can.size()>0){
tips.setOkMsg(msgs.stream().collect(Collectors.joining())); tips.setOkMsg(msgs.stream().collect(Collectors.joining()));

Loading…
Cancel
Save