diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmProjectController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmProjectController.java index 2debaf59..c4dfcbe9 100644 --- a/xm-core/src/main/java/com/xm/core/ctrl/XmProjectController.java +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmProjectController.java @@ -7,8 +7,13 @@ import com.mdp.mybatis.PageUtils; import com.mdp.qx.HasQx; import com.mdp.audit.log.client.annotation.AuditLog; import com.mdp.audit.log.client.annotation.OperType; +import com.mdp.safe.client.entity.User; +import com.mdp.safe.client.utils.LoginUtils; import com.xm.core.entity.XmProject; +import com.xm.core.entity.XmProjectGroup; +import com.xm.core.service.XmProjectGroupService; import com.xm.core.service.XmProjectService; +import com.xm.core.vo.XmProjectGroupVo; import com.xm.core.vo.XmProjectVo; import io.swagger.annotations.*; import org.apache.commons.logging.Log; @@ -41,6 +46,8 @@ public class XmProjectController { @Autowired private XmProjectService xmProjectService; + @Autowired + private XmProjectGroupService groupService; @ApiOperation( value = "查询xm_project信息列表",notes="listXmProject,条件之间是 and关系,模糊查询写法如 {studentName:'%才哥%'}") @ApiImplicitParams({ @@ -126,8 +133,18 @@ public class XmProjectController { Map m = new HashMap<>(); Tips tips=new Tips("成功删除一条数据"); try{ - xmProjectService.deleteByPk(xmProject); - xmProjectService.clearProject(xmProject.getId()); + User user= LoginUtils.getCurrentUserInfo(); + XmProject xmProjectDb=this.xmProjectService.selectOneObject(xmProject); + if(xmProjectDb==null){ + tips.setFailureMsg("项目不存在"); + } + if(user.getUserid().equals(xmProjectDb.getCreateUserid())){ + xmProjectService.deleteByPk(xmProject); + xmProjectService.clearProject(xmProject.getId()); + }else { + tips.setFailureMsg("您不是该项目创建人,无权删除"); + } + }catch (BizException e) { tips=e.getTips(); logger.error("",e); @@ -149,9 +166,29 @@ public class XmProjectController { Map m = new HashMap<>(); Tips tips=new Tips("成功更新一条数据"); try{ + + User user= LoginUtils.getCurrentUserInfo(); + if( !StringUtils.hasText(xmProject.getId())){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + XmProject xmProjectDb=this.xmProjectService.selectOneObject(xmProject); + if(xmProjectDb==null){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + List groups=this.groupService.getProjectGroupVoList(xmProjectDb.getId()); + boolean isCreate=user.getUserid().equals(xmProjectDb.getCreateUserid()); + boolean isPm=groupService.checkUserIsProjectManager(groups,user.getUserid()); + if( !isCreate && !isPm ) { + tips.setFailureMsg("您无权操作!项目创建人、项目经理才能修改项目基础数据"); + m.put("tips", tips); + return m; + } xmProjectService.updateByPk(xmProject); xmProjectService.clearProject(xmProject.getId()); - m.put("data",xmProject); }catch (BizException e) { tips=e.getTips(); @@ -174,6 +211,27 @@ public class XmProjectController { Map m = new HashMap<>(); Tips tips=new Tips("状态更新成功"); try{ + + User user= LoginUtils.getCurrentUserInfo(); + if( !StringUtils.hasText(xmProject.getId())){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + XmProject xmProjectDb=this.xmProjectService.selectOneObject(xmProject); + if(xmProjectDb==null){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + List groups=this.groupService.getProjectGroupVoList(xmProjectDb.getId()); + boolean isCreate=user.getUserid().equals(xmProjectDb.getCreateUserid()); + boolean isPm=groupService.checkUserIsProjectManager(groups,user.getUserid()); + if( !isCreate && !isPm ) { + tips.setFailureMsg("您无权操作!项目创建人、项目经理才能修改项目状态"); + m.put("tips", tips); + return m; + } xmProjectService.updateStatus(xmProject); xmProjectService.clearProject(xmProject.getId()); @@ -199,6 +257,26 @@ public class XmProjectController { Map m = new HashMap<>(); Tips tips=new Tips("预算更新成功"); try{ + User user= LoginUtils.getCurrentUserInfo(); + if( !StringUtils.hasText(xmProject.getId())){ + tips.setFailureMsg("项目编号不能为空"); + m.put("tips", tips); + return m; + } + XmProject xmProjectDb=this.xmProjectService.selectOneObject(xmProject); + if(xmProjectDb==null){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + List groups=this.groupService.getProjectGroupVoList(xmProjectDb.getId()); + boolean isCreate=user.getUserid().equals(xmProjectDb.getCreateUserid()); + boolean isPm=groupService.checkUserIsProjectManager(groups,user.getUserid()); + if( !isCreate && !isPm ) { + tips.setFailureMsg("您无权操作!项目创建人、项目经理才能修改项目预算"); + m.put("tips", tips); + return m; + } xmProjectService.editBudget(xmProject); xmProjectService.clearProject(xmProject.getId()); @@ -224,6 +302,26 @@ public class XmProjectController { Map m = new HashMap<>(); Tips tips=new Tips("成功更新一条数据"); try{ + User user= LoginUtils.getCurrentUserInfo(); + if( !StringUtils.hasText(xmProject.getId())){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + XmProject xmProjectDb=this.xmProjectService.selectOneObject(xmProject); + if(xmProjectDb==null){ + tips.setFailureMsg("项目不存在"); + m.put("tips", tips); + return m; + } + List groups=this.groupService.getProjectGroupVoList(xmProjectDb.getId()); + boolean isCreate=user.getUserid().equals(xmProjectDb.getCreateUserid()); + boolean isPm=groupService.checkUserIsProjectManager(groups,user.getUserid()); + if( !isCreate && !isPm ) { + tips.setFailureMsg("您无权操作!项目创建人、项目经理才能修改项目基础信息"); + m.put("tips", tips); + return m; + } xmProjectService.updateProject(xmProject); xmProjectService.clearProject(xmProject.getId()); diff --git a/xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java b/xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java index 8bcc7c6e..0ca049b9 100644 --- a/xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java +++ b/xm-core/src/main/java/com/xm/core/ctrl/XmProjectGroupController.java @@ -63,11 +63,17 @@ public class XmProjectGroupController { @HasQx(value = "xm_core_xmProjectGroup_updateGroup",name = "批量更新修改项目团队信息",categoryId = "admin-xm",categoryName = "管理端-项目管理系统") @RequestMapping(value="/updateGroup",method=RequestMethod.POST) public Map updateGroup(@RequestBody List xmProjectGroupVo) { + + Tips tips=new Tips("团队更新成功"); Map m = new HashMap<>(); + if(xmProjectGroupVo==null || xmProjectGroupVo.size()==0){ + tips.setFailureMsg("团队列表不能为空"); + m.put("tips", tips); + return m; + } String projectId = xmProjectGroupVo.get(0).getProjectId(); xmProjectGroupVo = xmProjectGroupService.updateGroup(projectId,xmProjectGroupVo); //列出XmProjectGroup列表 m.put("data",xmProjectGroupVo); - Tips tips=new Tips("团队更新成功"); m.put("tips", tips); return m; } diff --git a/xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java b/xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java index 06e59d8b..f5c42956 100644 --- a/xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java +++ b/xm-core/src/main/java/com/xm/core/service/XmProjectGroupService.java @@ -14,6 +14,7 @@ import com.xm.core.vo.XmProjectGroupVo; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.util.*; @@ -89,6 +90,7 @@ public class XmProjectGroupService extends BaseService { * @param projectId * @param xmProjectGroupVoList */ + @Transactional public void addGroups(String projectId,List xmProjectGroupVoList) { List groups=new ArrayList<>(); List groupUsers=new ArrayList<>(); @@ -142,7 +144,8 @@ public class XmProjectGroupService extends BaseService { groupCacheService.putGroups(projectId, null); } //更新项目团队 - public List updateGroup(String projectId,List xmProjectGroupVoList) { + @Transactional + public List updateGroup(String projectId,List xmProjectGroupVoList) { XmProjectGroup group = new XmProjectGroup(); group.setProjectId(projectId); List groupListDb = this.selectListByWhere(group);