mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 11:05:06 +08:00
初始化 dept 部门模块
This commit is contained in:
@ -1,14 +1,52 @@
|
||||
package cn.iocoder.dashboard.modules.system.controller.dept;
|
||||
|
||||
import cn.iocoder.dashboard.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptSimpleRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.convert.dept.SysDeptConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||
|
||||
@Api(tags = "部门 API")
|
||||
@RestController
|
||||
@RequestMapping("/system/dept")
|
||||
public class SysDeptController {
|
||||
|
||||
@Resource
|
||||
private SysDeptService sysDeptService;
|
||||
|
||||
@ApiOperation("获取部门列表")
|
||||
// @PreAuthorize("@ss.hasPermi('system:dept:list')")
|
||||
@GetMapping("/list")
|
||||
public CommonResult<List<SysDeptRespVO>> listDepts(SysDeptListReqVO reqVO) {
|
||||
List<SysDeptDO> list = sysDeptService.listDepts(reqVO);
|
||||
list.sort(Comparator.comparing(SysDeptDO::getSort));
|
||||
return success(SysDeptConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取部门精简信息列表", notes = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||
@GetMapping("/list-all-simple")
|
||||
public CommonResult<List<SysDeptSimpleRespVO>> listSimpleDepts() {
|
||||
// 获得部门列表,只要开启状态的
|
||||
SysDeptListReqVO reqVO = new SysDeptListReqVO();
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
List<SysDeptDO> list = sysDeptService.listDepts(reqVO);
|
||||
// 排序后,返回个诶前端
|
||||
list.sort(Comparator.comparing(SysDeptDO::getSort));
|
||||
return success(SysDeptConvert.INSTANCE.convertList02(list));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class SysRoleBaseVO {
|
||||
@NotBlank(message = "显示顺序不能为空")
|
||||
private String sort;
|
||||
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 RoleTypeEnum 枚举")
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 SysRoleTypeEnum 枚举")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "备注", example = "我是一个角色")
|
||||
|
@ -25,7 +25,7 @@ public class SysRoleRespVO extends SysRoleBaseVO {
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "参见 RoleTypeEnum 枚举类")
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "参见 SysRoleTypeEnum 枚举类")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
|
@ -14,9 +14,9 @@ public class SysRoleUpdateStatusReqVO {
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 CommonStatusEnum 枚举")
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1", notes = "见 SysCommonStatusEnum 枚举")
|
||||
@NotNull(message = "状态不能为空")
|
||||
// @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
// @InEnum(value = SysCommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.dashboard.modules.system.convert.dept;
|
||||
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptSimpleRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysDeptConvert {
|
||||
|
||||
SysDeptConvert INSTANCE = Mappers.getMapper(SysDeptConvert.class);
|
||||
|
||||
List<SysDeptRespVO> convertList(List<SysDeptDO> list);
|
||||
|
||||
List<SysDeptSimpleRespVO> convertList02(List<SysDeptDO> list);
|
||||
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept;
|
||||
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -10,7 +13,12 @@ import java.util.List;
|
||||
public interface SysDeptMapper extends BaseMapper<SysDeptDO> {
|
||||
|
||||
default List<SysDeptDO> selectList() {
|
||||
return selectList(null);
|
||||
return selectList(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
default List<SysDeptDO> selectList(SysDeptListReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysDeptDO>().likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.dept;
|
||||
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
|
||||
import java.util.List;
|
||||
@ -14,8 +15,16 @@ public interface SysDeptService {
|
||||
/**
|
||||
* 获得所有部门列表
|
||||
*
|
||||
* @return 菜单列表
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDeptDO> listDepts();
|
||||
|
||||
/**
|
||||
* 筛选部门列表
|
||||
*
|
||||
* @param reqVO 筛选条件请求 VO
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<SysDeptDO> listDepts(SysDeptListReqVO reqVO);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.dashboard.modules.system.service.dept.impl;
|
||||
|
||||
import cn.iocoder.dashboard.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept.SysDeptMapper;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService;
|
||||
@ -24,4 +25,9 @@ public class SysDeptServiceImpl implements SysDeptService {
|
||||
return deptMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDeptDO> listDepts(SysDeptListReqVO reqVO) {
|
||||
return deptMapper.selectList(reqVO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user