diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmIterationController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmIterationController.java index 96e5d916..bb632032 100644 --- a/xm-core/src/main/java/com/xm/core/ctrl/XmIterationController.java +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmIterationController.java @@ -11,6 +11,7 @@ import com.mdp.safe.client.entity.User; import com.mdp.safe.client.utils.LoginUtils; import com.xm.core.entity.XmIteration; import com.xm.core.entity.XmIterationLink; +import com.xm.core.service.XmIterationLinkService; import com.xm.core.service.XmIterationService; import com.xm.core.service.XmProductService; import com.xm.core.service.XmRecordService; @@ -47,6 +48,10 @@ public class XmIterationController { @Autowired private XmIterationService xmIterationService; + + @Autowired + private XmIterationLinkService xmIterationLinkService; + @Autowired private XmProductService xmProductService; @@ -219,9 +224,15 @@ public class XmIterationController { return ResponseHelper.failed("data-0","迭代不存在"); } User user=LoginUtils.getCurrentUserInfo(); - if(!user.getUserid().equals(iterationDb.getAdminUserid()) && user.getUserid().equals(iterationDb.getAdminUserid())){ + if(!user.getUserid().equals(iterationDb.getAdminUserid()) && !user.getUserid().equals(iterationDb.getCuserid())){ return ResponseHelper.failed("no-qx","您无权删除,迭代创建人、负责人可以删除"); } + + XmIterationLink linkQ=new XmIterationLink(); + linkQ.setIterationId(iterationDb.getId()); + if(xmIterationLinkService.countByWhere(linkQ)>0){ + return ResponseHelper.failed("links-no-0","该迭代具有产品或者项目关联,请先移除关联关系"); + } xmIterationService.deleteByPk(xmIteration); xmRecordService.addXmIterationRecord(xmIteration.getId(),"迭代-删除","删除迭代"+iterationDb.getIterationName(),"", JSON.toJSONString(iterationDb)); diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmProductProjectLinkController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmProductProjectLinkController.java index e121341e..ed374c83 100644 --- a/xm-core/src/main/java/com/xm/core/ctrl/XmProductProjectLinkController.java +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmProductProjectLinkController.java @@ -1,9 +1,11 @@ package com.xm.core.ctrl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; + +import com.mdp.core.utils.ResponseHelper; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; +import org.aspectj.weaver.ResolvedPointcutDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -81,20 +83,24 @@ public class XmProductProjectLinkController { @RequestMapping(value="/add",method=RequestMethod.POST) public Map addXmProductProjectLink(@RequestBody XmProductProjectLink xmProductProjectLink) { Map m = new HashMap<>(); - Tips tips=new Tips("成功新增一条数据"); + Tips tips=new Tips("成功加入"); try{ - boolean createPk=false; - if(StringUtils.isEmpty(xmProductProjectLink.getProjectId())) { - createPk=true; - xmProductProjectLink.setProjectId(xmProductProjectLinkService.createKey("projectId")); + User user = LoginUtils.getCurrentUserInfo(); + if(!StringUtils.hasText(xmProductProjectLink.getProductId())){ + return ResponseHelper.failed("productId-0","产品编号不能为空"); + } + if(!StringUtils.hasText(xmProductProjectLink.getProjectId())){ + return ResponseHelper.failed("projectId-0","项目编号不能为空"); + } + if(xmProductProjectLinkService.selectOneObject(xmProductProjectLink) !=null ){ + tips.setFailureMsg("已加入,无需再添加"); + m.put("tips", tips); + return m; } - if(createPk==false){ - if(xmProductProjectLinkService.selectOneObject(xmProductProjectLink) !=null ){ - tips.setFailureMsg("编号重复,请修改编号再提交"); - m.put("tips", tips); - return m; - } - } + xmProductProjectLink.setCtime(new Date()); + xmProductProjectLink.setLinkStatus("1"); + xmProductProjectLink.setCuserid(user.getUserid()); + xmProductProjectLink.setCusername(user.getUsername()); xmProductProjectLinkService.insert(xmProductProjectLink); m.put("data",xmProductProjectLink); }catch (BizException e) { @@ -117,6 +123,13 @@ public class XmProductProjectLinkController { Map m = new HashMap<>(); Tips tips=new Tips("成功删除一条数据"); try{ + + if(!StringUtils.hasText(xmProductProjectLink.getProductId())){ + return ResponseHelper.failed("productId-0","产品编号不能为空"); + } + if(!StringUtils.hasText(xmProductProjectLink.getProjectId())){ + return ResponseHelper.failed("projectId-0","项目编号不能为空"); + } xmProductProjectLinkService.deleteByPk(xmProductProjectLink); }catch (BizException e) { tips=e.getTips();