diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java index 89a56c6..e8d3c10 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java @@ -3,6 +3,8 @@ package com.hxhq.business.controller; import java.util.Arrays; import java.util.List; +import com.hxhq.business.enums.study.StudyStatusEnum; +import com.hxhq.common.security.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.hxhq.business.domain.Study; @@ -29,6 +31,7 @@ public class StudyController extends BaseController * 查询试验列表 */ @GetMapping("/list") + @RequiresPermissions("business:study:list") public TableDataInfo list(Study study) { startPage(); @@ -48,6 +51,7 @@ public class StudyController extends BaseController /** * 新增试验信息 */ + @RequiresPermissions({"business:study:add", "business:study:edit"}) @PostMapping("/save") public AjaxResult save(@RequestBody Study study) { @@ -57,9 +61,20 @@ public class StudyController extends BaseController /** * 删除试验信息 */ + @RequiresPermissions({"business:study:remove"}) @PostMapping("/delete") - public AjaxResult delete(@RequestBody Long[] ids) + public AjaxResult delete(@RequestBody Study study) { - return toAjax(studyService.removeByIds(Arrays.asList(ids))); + if(study.getId()==null || study.getId().longValue()<=0){ + return AjaxResult.error("参数有误"); + } + Study info = studyService.getById(study.getId()); + if(info==null){ + return AjaxResult.error("信息不存在"); + } + if(!info.getStatus().equals(StudyStatusEnum.cg.getValue())){ + return AjaxResult.error("当前状态不能删除"); + } + return toAjax(studyService.removeById(study.getId())); } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/select/DeptUserTreeDto.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/select/DeptUserTreeDto.java new file mode 100644 index 0000000..a8675a0 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/select/DeptUserTreeDto.java @@ -0,0 +1,55 @@ +package com.hxhq.business.dto.select; + +/** + * @author memory + */ +public class DeptUserTreeDto { + /** + * 类型 + */ + private Integer type; + /** + * id + */ + private String id; + /** + * 上级 + */ + private String parentId; + /** + * 名称 + */ + private String name; + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/study/StudyStatusEnum.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/study/StudyStatusEnum.java new file mode 100644 index 0000000..6657dc6 --- /dev/null +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/study/StudyStatusEnum.java @@ -0,0 +1,71 @@ +package com.hxhq.business.enums.study; + +/** + * 试验状态1草稿,3试验中,5已锁定,7待归档,9归档,10待解档 + * @author tanfei + */ +public enum StudyStatusEnum { + + /** + * 1草稿 + */ + cg(1, "草稿"), + + /** + * 1试验中 + */ + syz(3, "试验中"), + + /** + * 1已锁定 + */ + ysd(5, "已锁定"), + + /** + * 1待归档 + */ + dgd(7, "待归档"), + + /** + * 1归档 + */ + gd(9, "归档"), + + /** + * 10待解档 + */ + djd(10, "待解档"); + + private int value; + private String text; + + StudyStatusEnum(int value, String text) { + this.value = value; + this.text = text; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public static StudyStatusEnum getEnumByValue(int type) { + for (StudyStatusEnum bt : values()) { + if (bt.value == type) { + return bt; + } + } + return null; + } +} diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java index 2fbc3e5..0f1cd72 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java @@ -8,6 +8,7 @@ import java.util.Set; import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; +import com.hxhq.business.dto.select.DeptUserTreeDto; import com.hxhq.business.enums.dept.DeptTypeEnum; import com.hxhq.system.dto.UserExportDto; import com.hxhq.system.service.ISysConfigService; @@ -420,10 +421,29 @@ public class SysUserController extends BaseController /** * 获取部门树列表 */ - @RequiresPermissions("system:user:list") @GetMapping("/deptTree") public AjaxResult deptTree(SysDept dept) { return success(deptService.selectDeptTreeList(dept)); } + + /** + * 获取部门树列表 + */ + @GetMapping("/deptUserList") + public AjaxResult deptUserList() + { + List depts = userService.selectDeptAndUser(); + for(DeptUserTreeDto dept : depts){ + Boolean isDept = dept.getType().equals(DeptTypeEnum.dept.getValue()) || dept.getType().equals(DeptTypeEnum.subject.getValue()) || dept.getType().equals(DeptTypeEnum.team.getValue()); + if(isDept){ + dept.setId("d_"+dept.getId()); + dept.setParentId(("0".equals(dept.getParentId())?"":"d_")+dept.getParentId()); + }else{ + dept.setId("u_"+dept.getId()); + dept.setParentId("d_"+dept.getParentId()); + } + } + return success(depts); + } } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java index d8210d6..20290f5 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java @@ -1,6 +1,8 @@ package com.hxhq.system.mapper; import java.util.List; + +import com.hxhq.business.dto.select.DeptUserTreeDto; import org.apache.ibatis.annotations.Param; import com.hxhq.system.api.domain.SysUser; @@ -154,4 +156,10 @@ public interface SysUserMapper * @return */ List selectAllocatedListSimple(Long roleId); + + /** + * 获取部门+人员列表 + * @return + */ + List selectDeptAndUser(); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java index ebf59b4..b7dfbb4 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java @@ -3,6 +3,7 @@ package com.hxhq.system.service; import java.util.List; import java.util.Map; +import com.hxhq.business.dto.select.DeptUserTreeDto; import com.hxhq.system.api.domain.SysUser; /** @@ -226,4 +227,10 @@ public interface ISysUserService * @return */ List selectTransferAllList(); + + /** + * 获取部门+人员列表 + * @return + */ + List selectDeptAndUser(); } diff --git a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java index 3d7240d..3115697 100644 --- a/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java +++ b/hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java @@ -7,6 +7,7 @@ import java.util.Map; import java.util.stream.Collectors; import javax.validation.Validator; +import com.hxhq.business.dto.select.DeptUserTreeDto; import com.hxhq.system.domain.SysPost; import com.hxhq.system.domain.SysUserPost; import com.hxhq.system.domain.SysUserRole; @@ -573,4 +574,9 @@ public class SysUserServiceImpl implements ISysUserService public List selectTransferAllList() { return userMapper.selectTransferAllList(); } + + @Override + public List selectDeptAndUser() { + return userMapper.selectDeptAndUser(); + } } diff --git a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml index 03e0b2a..65bb504 100644 --- a/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -244,5 +244,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{userId} + + \ No newline at end of file