Browse Source

添加节点类型、标签等

master
陈裕财 4 years ago
parent
commit
56e467dbed
  1. 22
      xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java
  2. 12
      xm-core/src/main/java/com/xm/core/service/XmProductService.java
  3. 19
      xm-core/src/main/java/com/xm/core/vo/XmProductAddVo.java

22
xm-core/src/main/java/com/xm/core/ctrl/XmProductController.java

@ -11,9 +11,11 @@ import com.mdp.safe.client.entity.User;
import com.mdp.safe.client.utils.LoginUtils;
import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmProductCopyVo;
import com.xm.core.entity.XmProductProjectLink;
import com.xm.core.service.XmProductService;
import com.xm.core.service.XmGroupService;
import com.xm.core.service.XmRecordService;
import com.xm.core.vo.XmProductAddVo;
import io.swagger.annotations.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -218,7 +220,7 @@ public class XmProductController {
})
@HasQx(value = "xm_core_xmProduct_add",name = "创建产品/战略规划等",categoryId = "admin-xm",categoryName = "管理端-项目管理系统")
@RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmProduct(@RequestBody XmProduct xmProduct) {
public Map<String,Object> addXmProduct(@RequestBody XmProductAddVo xmProduct) {
Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据");
try{
@ -235,6 +237,13 @@ public class XmProductController {
return m;
}
}
if(xmProduct.getLinks()!=null && xmProduct.getLinks().size()>0){
for (XmProductProjectLink link : xmProduct.getLinks()) {
if(!StringUtils.hasText(link.getProjectId())) {
return ResponseHelper.failed("projectId-0", "", "关联项目编号不能为空");
}
}
}
if(!StringUtils.hasText(xmProduct.getProductName())){
return ResponseHelper.failed("productName-0","","产品名称不能为空");
}
@ -252,7 +261,16 @@ public class XmProductController {
xmProduct.setPstatus("0");
xmProduct.setDel("0");
xmProduct.setLocked("0");
xmProductService.insert(xmProduct);
if(xmProduct.getLinks()!=null && xmProduct.getLinks().size()>0){
for (XmProductProjectLink link : xmProduct.getLinks()) {
link.setProductId(xmProduct.getId());
link.setCusername(user.getUsername());
link.setCuserid(user.getUserid());
link.setLinkStatus("1");
link.setCtime(new Date());
}
}
xmProductService.addProduct(xmProduct);
xmRecordService.addXmProductRecord(xmProduct.getId(),"创建产品","创建产品【"+xmProduct.getId()+"】【"+xmProduct.getProductName()+"】");
m.put("data",xmProduct);

12
xm-core/src/main/java/com/xm/core/service/XmProductService.java

@ -5,6 +5,7 @@ import com.mdp.core.service.BaseService;
import com.mdp.safe.client.entity.User;
import com.xm.core.entity.*;
import com.xm.core.service.cache.XmProductCacheService;
import com.xm.core.vo.XmProductAddVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -47,6 +48,9 @@ public class XmProductService extends BaseService {
@Autowired
XmPhaseService xmProjectPhaseService;
@Autowired
XmProductProjectLinkService linkService;
/**
@ -288,5 +292,13 @@ public class XmProductService extends BaseService {
this.xmMenuService.doBatchDeleteByProductIds(canDelList.stream().map(i->i.getId()).collect(Collectors.toList()));
super.batchDelete(canDelList);
}
@Transactional
public void addProduct(XmProductAddVo xmProduct) {
super.insert(xmProduct);
if(xmProduct.getLinks()!=null && xmProduct.getLinks().size()>0){
linkService.batchInsert(xmProduct.getLinks());
}
}
}

19
xm-core/src/main/java/com/xm/core/vo/XmProductAddVo.java

@ -0,0 +1,19 @@
package com.xm.core.vo;
import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmProductProjectLink;
import java.util.List;
public class XmProductAddVo extends XmProduct {
List<XmProductProjectLink> links;
public List<XmProductProjectLink> getLinks() {
return links;
}
public void setLinks(List<XmProductProjectLink> links) {
this.links = links;
}
}
Loading…
Cancel
Save