|
|
|
@ -1,19 +1,29 @@ |
|
|
|
package com.xm.core.ctrl; |
|
|
|
|
|
|
|
import com.mdp.core.entity.Tips; |
|
|
|
import com.mdp.core.err.BizException; |
|
|
|
import com.mdp.core.utils.RequestUtils; |
|
|
|
import com.mdp.core.utils.ResponseHelper; |
|
|
|
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.service.XmProductService; |
|
|
|
import com.xm.core.service.XmProjectGroupService; |
|
|
|
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 org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
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.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -40,6 +50,15 @@ public class XmProjectGroupUserController { |
|
|
|
private XmProjectGroupUserService xmProjectGroupUserService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private XmProjectService xmProjectService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private XmProductService xmProductService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
XmProjectGroupService xmProjectGroupService; |
|
|
|
|
|
|
|
|
|
|
|
@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,主键如果为空,后台自动生成") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200,response=XmProjectGroupUser.class,message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'},data:数据对象}") |
|
|
|
}) |
|
|
|
@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<>(); |
|
|
|
Tips tips=new Tips("成功新增一条数据"); |
|
|
|
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{ |
|
|
|
XmProjectGroupUser xmProjectGroupUserQuery = new XmProjectGroupUser(xmProjectGroupUser.getId()); |
|
|
|
if(xmProjectGroupUserService.countByWhere(xmProjectGroupUserQuery)>0){ |
|
|
|
tips.setFailureMsg("编号重复,请修改编号再提交"); |
|
|
|
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); |
|
|
|
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); |
|
|
|
}catch (BizException e) { |
|
|
|
tips=e.getTips(); |
|
|
|
@ -111,9 +164,7 @@ public class XmProjectGroupUserController { |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
@ApiOperation( value = "删除一条xm_project_group_user信息",notes="delXmProjectGroupUser,仅需要上传主键字段") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}}") |
|
|
|
@ -134,9 +185,7 @@ public class XmProjectGroupUserController { |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
/** |
|
|
|
@ApiOperation( value = "根据主键修改一条xm_project_group_user信息",notes="editXmProjectGroupUser") |
|
|
|
@ApiResponses({ |
|
|
|
@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); |
|
|
|
return m; |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ApiOperation( value = "根据主键列表批量删除xm_project_group_user信息",notes="batchDelXmProjectGroupUser,仅需要上传主键字段") |
|
|
|
@ApiResponses({ |
|
|
|
@ApiResponse(code = 200, message = "{tips:{isOk:true/false,msg:'成功/失败原因',tipscode:'失败时错误码'}") |
|
|
|
@ -183,5 +230,4 @@ public class XmProjectGroupUserController { |
|
|
|
m.put("tips", tips); |
|
|
|
return m; |
|
|
|
} |
|
|
|
*/ |
|
|
|
} |