Browse Source

feat: [试验管理] 添加权限

master
memorylkf 2 weeks ago
parent
commit
a545ebe02b
8 changed files with 197 additions and 3 deletions
  1. +17
    -2
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java
  2. +55
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/select/DeptUserTreeDto.java
  3. +71
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/study/StudyStatusEnum.java
  4. +21
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java
  5. +8
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java
  6. +7
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java
  7. +6
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java
  8. +12
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml

+ 17
- 2
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyController.java View File

@ -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()));
}
}

+ 55
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/dto/select/DeptUserTreeDto.java View File

@ -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;
}
}

+ 71
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/enums/study/StudyStatusEnum.java View File

@ -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;
}
}

+ 21
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java View File

@ -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<DeptUserTreeDto> 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);
}
}

+ 8
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java View File

@ -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<Long> selectAllocatedListSimple(Long roleId);
/**
* 获取部门+人员列表
* @return
*/
List<DeptUserTreeDto> selectDeptAndUser();
}

+ 7
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java View File

@ -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<SysUser> selectTransferAllList();
/**
* 获取部门+人员列表
* @return
*/
List<DeptUserTreeDto> selectDeptAndUser();
}

+ 6
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/impl/SysUserServiceImpl.java View File

@ -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<SysUser> selectTransferAllList() {
return userMapper.selectTransferAllList();
}
@Override
public List<DeptUserTreeDto> selectDeptAndUser() {
return userMapper.selectDeptAndUser();
}
}

+ 12
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml View File

@ -244,5 +244,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{userId}
</foreach>
</delete>
<select id="selectDeptAndUser" resultType="com.hxhq.business.dto.select.DeptUserTreeDto">
(SELECT d.dept_id AS id, d.parent_id, d.dept_name AS `name`, d.type
FROM sys_dept d
WHERE d.del_flag = '0' ORDER BY d.`dept_id` DESC)
UNION ALL
(SELECT u.`user_id` AS id,u.`dept_id` AS parent_id,u.`nick_name` AS `name`,7 AS `type` FROM `sys_user` u
WHERE u.`del_flag`='0' AND u.`user_id`&lt;>1 ORDER BY u.`user_id` DESC)
</select>
</mapper>

Loading…
Cancel
Save