Browse Source

添加节点类型、标签等

master
陈裕财 4 years ago
parent
commit
71e96d3c1a
  1. 2
      xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java
  2. 86
      xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupUserController.java
  3. 65
      xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java
  4. 39
      xm-core/src/main/java/com/xm/core/vo/XmProjectGroupUserVo.java

2
xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java

@ -12,6 +12,7 @@ import com.mdp.safe.client.utils.LoginUtils;
import com.xm.core.entity.XmProduct; import com.xm.core.entity.XmProduct;
import com.xm.core.entity.XmProject; import com.xm.core.entity.XmProject;
import com.xm.core.entity.XmProjectGroup; import com.xm.core.entity.XmProjectGroup;
import com.xm.core.entity.XmProjectGroupUser;
import com.xm.core.service.XmProductService; import com.xm.core.service.XmProductService;
import com.xm.core.service.XmProjectGroupService; import com.xm.core.service.XmProjectGroupService;
import com.xm.core.service.XmProjectService; import com.xm.core.service.XmProjectService;
@ -122,6 +123,7 @@ public class XmProjectGroupController {
xmProjectGroupCacheService.clearProjectGroup(groupDb.getProjectId(),groupDb.getId()); xmProjectGroupCacheService.clearProjectGroup(groupDb.getProjectId(),groupDb.getId());
} }
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }

86
xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupUserController.java

@ -1,19 +1,29 @@
package com.xm.core.ctrl; package com.xm.core.ctrl;
import com.mdp.core.entity.Tips; import com.mdp.core.entity.Tips;
import com.mdp.core.err.BizException;
import com.mdp.core.utils.RequestUtils; import com.mdp.core.utils.RequestUtils;
import com.mdp.core.utils.ResponseHelper;
import com.mdp.mybatis.PageUtils; import com.mdp.mybatis.PageUtils;
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.XmProjectGroup;
import com.xm.core.entity.XmProjectGroupUser; import com.xm.core.entity.XmProjectGroupUser;
import com.xm.core.service.XmProductService;
import com.xm.core.service.XmProjectGroupService;
import com.xm.core.service.XmProjectGroupUserService; import com.xm.core.service.XmProjectGroupUserService;
import com.xm.core.service.XmProjectService;
import com.xm.core.vo.XmProjectGroupUserVo;
import com.xm.core.vo.XmProjectGroupVo;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -40,6 +50,15 @@ public class XmProjectGroupUserController {
private XmProjectGroupUserService xmProjectGroupUserService; private XmProjectGroupUserService xmProjectGroupUserService;
@Autowired
private XmProjectService xmProjectService;
@Autowired
private XmProductService xmProductService;
@Autowired
XmProjectGroupService xmProjectGroupService;
@ApiOperation( value = "查询xm_project_group_user信息列表",notes="listXmProjectGroupUser,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") @ApiOperation( value = "查询xm_project_group_user信息列表",notes="listXmProjectGroupUser,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}")
@ -79,27 +98,61 @@ public class XmProjectGroupUserController {
/**
@ApiOperation( value = "新增一条xm_project_group_user信息",notes="addXmProjectGroupUser,主键如果为空,后台自动生成") @ApiOperation( value = "新增一条xm_project_group_user信息",notes="addXmProjectGroupUser,主键如果为空,后台自动生成")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmProjectGroupUser.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @ApiResponse(code = 200,response=XmProjectGroupUser.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
}) })
@RequestMapping(value="/add",method=RequestMethod.POST) @RequestMapping(value="/add",method=RequestMethod.POST)
public Map<String,Object> addXmProjectGroupUser(@RequestBody XmProjectGroupUser xmProjectGroupUser) {
public Map<String,Object> addXmProjectGroupUser(@RequestBody XmProjectGroupUserVo xmProjectGroupUser) {
Map<String,Object> m = new HashMap<>(); Map<String,Object> m = new HashMap<>();
Tips tips=new Tips("成功新增一条数据"); Tips tips=new Tips("成功新增一条数据");
try{ try{
if(StringUtils.isEmpty(xmProjectGroupUser.getId())) {
xmProjectGroupUser.setId(xmProjectGroupUserService.createKey("id"));
if(!StringUtils.hasText(xmProjectGroupUser.getGroupId())||!StringUtils.hasText(xmProjectGroupUser.getUserid())){
return ResponseHelper.failed("pk-0","请上送小组编号,用户编号groupId,userid");
}
if(!StringUtils.hasText(xmProjectGroupUser.getPgClass())){
return ResponseHelper.failed("pgClass-0","请上送小组类型pgClass");
}
String pgClass=xmProjectGroupUser.getPgClass();
User user=LoginUtils.getCurrentUserInfo();
if("1".equals(pgClass)){
if(!StringUtils.hasText(xmProjectGroupUser.getProductId())){
return ResponseHelper.failed("productId-0","请上送小组归属产品编号");
}
XmProduct xmProduct=this.xmProductService.getProductFromCache(xmProjectGroupUser.getProductId());
if(xmProduct==null){
return ResponseHelper.failed("product-0","产品已不存在");
}
if(!xmProjectGroupService.checkUserIsProductAdm(xmProduct, user.getUserid())){
XmProjectGroupVo xmProjectGroupVo=this.xmProjectGroupService.getProductGroupFromCache(xmProduct.getId(),xmProjectGroupUser.getGroupId());
if(xmProjectGroupVo==null){
return ResponseHelper.failed("group-0","小组已不存在");
}
xmProjectGroupService.checkUserIsTeamHeadOrAss(null,user.getUserid());
}
}else{ }else{
XmProjectGroupUser xmProjectGroupUserQuery = new XmProjectGroupUser(xmProjectGroupUser.getId());
if(xmProjectGroupUserService.countByWhere(xmProjectGroupUserQuery)>0){
tips.setFailureMsg("编号重复,请修改编号再提交");
m.put("tips", tips);
return m;
if(!StringUtils.hasText(xmProjectGroupUser.getProjectId())){
return ResponseHelper.failed("projectId-0","请上送小组归属项目编号");
} }
} }
if(xmProjectGroupUserService.countByWhere(xmProjectGroupUser)>0){
tips.setFailureMsg("该用户已在小组中");
m.put("tips", tips);
return m;
}
this.xmProjectGroupService.checkUserIsProjectAdm();
xmProjectGroupUserService.insert(xmProjectGroupUser); xmProjectGroupUserService.insert(xmProjectGroupUser);
Map<String,Object> usermap=new HashMap<>();
usermap.put("userid", xmProjectGroupUser.getUserid());
usermap.put("username", xmProjectGroupUser.getUsername());
List<Map<String,Object>> users=new ArrayList<>();
users.add(usermap);
pushMsgService.pushJoinChannelGroupMsg(user.getBranchId(), u.getGroupId(), users);
xmRecordService.addXmGroupRecord(projectId,xmProjectGroupUser.getGroupId(), "项目-团队-新增小组成员", "增加组员["+u.getUsername()+"]",u.getUserid(),null);
m.put("data",xmProjectGroupUser); m.put("data",xmProjectGroupUser);
}catch (BizException e) { }catch (BizException e) {
tips=e.getTips(); tips=e.getTips();
@ -111,9 +164,7 @@ public class XmProjectGroupUserController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "删除一条xm_project_group_user信息",notes="delXmProjectGroupUser,仅需要上传主键字段") @ApiOperation( value = "删除一条xm_project_group_user信息",notes="delXmProjectGroupUser,仅需要上传主键字段")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}")
@ -134,9 +185,7 @@ public class XmProjectGroupUserController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键修改一条xm_project_group_user信息",notes="editXmProjectGroupUser") @ApiOperation( value = "根据主键修改一条xm_project_group_user信息",notes="editXmProjectGroupUser")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200,response=XmProjectGroupUser.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") @ApiResponse(code = 200,response=XmProjectGroupUser.class, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}")
@ -158,11 +207,9 @@ public class XmProjectGroupUserController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
/**
@ApiOperation( value = "根据主键列表批量删除xm_project_group_user信息",notes="batchDelXmProjectGroupUser,仅需要上传主键字段") @ApiOperation( value = "根据主键列表批量删除xm_project_group_user信息",notes="batchDelXmProjectGroupUser,仅需要上传主键字段")
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") @ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}")
@ -183,5 +230,4 @@ public class XmProjectGroupUserController {
m.put("tips", tips); m.put("tips", tips);
return m; return m;
} }
*/
} }

65
xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java

@ -92,6 +92,50 @@ public class XmProjectGroupService extends BaseService {
} }
} }
public boolean checkUserIsProjectAdm(XmProject xmProject,String userid){
if(xmProject==null){
return false;
}
Map<String,String> map=this.getProjectAdmUsers(xmProject);
if(map.containsKey(userid)){
return true;
}
return false;
}
public boolean checkUserIsProjectAdm(String projectId,String userid){
XmProject xmProject=xmProjectService.getProjectFromCache(projectId);
if(xmProject==null){
return false;
}
Map<String,String> map=this.getProjectAdmUsers(xmProject);
if(map.containsKey(userid)){
return true;
}
return false;
}
public boolean checkUserIsProductAdm(XmProduct xmProduct,String userid){
if(xmProduct==null){
return false;
}
Map<String,String> map=this.getProductAdmUsers(xmProduct);
if(map.containsKey(userid)){
return true;
}
return false;
}
public boolean checkUserIsProductAdm(String productId,String userid){
XmProduct xmProduct=xmProductService.getProductFromCache(productId);
if(xmProduct==null){
return false;
}
Map<String,String> map=this.getProductAdmUsers(xmProduct);
if(map.containsKey(userid)){
return true;
}
return false;
}
public List<XmProjectGroupVo> getProductGroupVoList(String productId) { public List<XmProjectGroupVo> getProductGroupVoList(String productId) {
List<XmProjectGroupVo> groupVoList=new ArrayList<>(); List<XmProjectGroupVo> groupVoList=new ArrayList<>();
List<XmProjectGroupVo> groupVoList2 = groupCacheService.getProductGroups(productId); List<XmProjectGroupVo> groupVoList2 = groupCacheService.getProductGroups(productId);
@ -813,5 +857,26 @@ public class XmProjectGroupService extends BaseService {
super.batchDelete(canDelNodes); super.batchDelete(canDelNodes);
batchSumParents(canDelNodes); batchSumParents(canDelNodes);
} }
public XmProjectGroupVo getProductGroupFromCache(String productId, String groupId) {
XmProjectGroupVo groupVo=groupCacheService.getProductGroup(productId,groupId);
if(groupVo==null){
XmProjectGroup group=this.selectOneObject(new XmProjectGroup(groupId));
if(group==null){
return null;
}else{
XmProjectGroupUser xmProjectGroupUser=new XmProjectGroupUser();
xmProjectGroupUser.setGroupId(groupId);
List<XmProjectGroupUser> users=this.xmProjectGroupUserService.selectListByWhere(xmProjectGroupUser);
XmProjectGroupVo xmProjectGroupVo=new XmProjectGroupVo();
BeanUtils.copyProperties(group,xmProjectGroupVo);
xmProjectGroupVo.setGroupUsers(users);
this.groupCacheService.putProductGroup(xmProjectGroupVo);
return xmProjectGroupVo;
}
}else {
return groupVo;
}
}
} }

39
xm-core/src/main/java/com/xm/core/vo/XmProjectGroupUserVo.java

@ -0,0 +1,39 @@
package com.xm.core.vo;
import com.xm.core.entity.XmProjectGroupUser;
public class XmProjectGroupUserVo extends XmProjectGroupUser {
String pgClass;
String projectId;
String productId;
public String getPgClass() {
return pgClass;
}
public void setPgClass(String pgClass) {
this.pgClass = pgClass;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
}
Loading…
Cancel
Save