mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	初始化 dept 部门模块
This commit is contained in:
		| @@ -0,0 +1,14 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.Api; | ||||||
|  | import org.springframework.web.bind.annotation.RequestMapping; | ||||||
|  | import org.springframework.web.bind.annotation.RestController; | ||||||
|  |  | ||||||
|  | @Api(tags = "部门 API") | ||||||
|  | @RestController | ||||||
|  | @RequestMapping("/system/dept") | ||||||
|  | public class SysDeptController { | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,43 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import javax.validation.constraints.Email; | ||||||
|  | import javax.validation.constraints.NotBlank; | ||||||
|  | import javax.validation.constraints.NotNull; | ||||||
|  | import javax.validation.constraints.Size; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 部门 Base VO,提供给添加、修改、详细的子 VO 使用 | ||||||
|  |  * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class SysDeptBaseVO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "菜单名称", required = true, example = "芋道") | ||||||
|  |     @NotBlank(message = "部门名称不能为空") | ||||||
|  |     @Size(max = 30, message = "部门名称长度不能超过30个字符") | ||||||
|  |     private String name; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "父菜单 ID", required = true, example = "1024") | ||||||
|  |     @NotNull(message = "父菜单 ID 不能为空") | ||||||
|  |     private Long parentId; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "显示顺序不能为空", required = true, example = "1024") | ||||||
|  |     @NotBlank(message = "显示顺序不能为空") | ||||||
|  |     private String sort; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "负责人", example = "芋道") | ||||||
|  |     private String leader; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "联系电话", example = "15601691000") | ||||||
|  |     @Size(max = 11, message = "联系电话长度不能超过11个字符") | ||||||
|  |     private String phone; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "邮箱", example = "yudao@iocoder.cn") | ||||||
|  |     @Email(message = "邮箱格式不正确") | ||||||
|  |     @Size(max = 50, message = "邮箱长度不能超过50个字符") | ||||||
|  |     private String email; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,11 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
|  | @ApiModel("部门创建 Request VO") | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | public class SysDeptCreateReqVO extends SysDeptBaseVO { | ||||||
|  | } | ||||||
| @@ -0,0 +1,19 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
|  | @ApiModel("部门列表 Request VO") | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | public class SysDeptListReqVO extends SysDeptBaseVO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "部门名称", example = "芋道", notes = "模糊匹配") | ||||||
|  |     private String name; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "展示状态", example = "1", notes = "参见 SysCommonStatusEnum 枚举类") | ||||||
|  |     private Integer status; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,27 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
|  | import java.util.Date; | ||||||
|  |  | ||||||
|  | @ApiModel("部门信息 Response VO") | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | public class SysDeptRespVO extends SysDeptBaseVO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "部门编号", required = true, example = "1024") | ||||||
|  |     private Integer id; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "祖级列表", required = true, example = "0,100") | ||||||
|  |     private String ancestors; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 SysCommonStatusEnum 枚举类") | ||||||
|  |     private Integer status; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式") | ||||||
|  |     private Date createTime; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,24 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.AllArgsConstructor; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.NoArgsConstructor; | ||||||
|  |  | ||||||
|  | @ApiModel("部门精简信息 Response VO") | ||||||
|  | @Data | ||||||
|  | @NoArgsConstructor | ||||||
|  | @AllArgsConstructor | ||||||
|  | public class SysDeptSimpleRespVO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "部门编号", required = true, example = "1024") | ||||||
|  |     private Integer id; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "部门名称", required = true, example = "芋道") | ||||||
|  |     private String name; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "父部门 ID", required = true, example = "1024") | ||||||
|  |     private Long parentId; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,19 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.controller.dept.vo.dept; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
|  | import javax.validation.constraints.NotNull; | ||||||
|  |  | ||||||
|  | @ApiModel("部门更新 Request VO") | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | public class SysDeptUpdateReqVO extends SysDeptBaseVO { | ||||||
|  |  | ||||||
|  |     @ApiModelProperty(value = "部门编号", required = true, example = "1024") | ||||||
|  |     @NotNull(message = "部门编号不能为空") | ||||||
|  |     private Integer id; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,16 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.dal.mysql.dao.dept; | ||||||
|  |  | ||||||
|  | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | ||||||
|  | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
|  | import org.apache.ibatis.annotations.Mapper; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | @Mapper | ||||||
|  | public interface SysDeptMapper extends BaseMapper<SysDeptDO> { | ||||||
|  |  | ||||||
|  |     default List<SysDeptDO> selectList() { | ||||||
|  |         return selectList(null); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -1,100 +0,0 @@ | |||||||
| package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept; |  | ||||||
|  |  | ||||||
| import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; |  | ||||||
|  |  | ||||||
| import javax.validation.constraints.Email; |  | ||||||
| import javax.validation.constraints.NotBlank; |  | ||||||
| import javax.validation.constraints.Size; |  | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * 部门表 sys_dept |  | ||||||
|  * |  | ||||||
|  * @author ruoyi |  | ||||||
|  */ |  | ||||||
| public class SysDept extends BaseDO { |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 部门ID |  | ||||||
|      */ |  | ||||||
|     private Long deptId; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 父部门ID |  | ||||||
|      */ |  | ||||||
|     private Long parentId; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 祖级列表 |  | ||||||
|      */ |  | ||||||
|     private String ancestors; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 部门名称 |  | ||||||
|      */ |  | ||||||
|     private String deptName; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 显示顺序 |  | ||||||
|      */ |  | ||||||
|     private String orderNum; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 负责人 |  | ||||||
|      */ |  | ||||||
|     private String leader; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 联系电话 |  | ||||||
|      */ |  | ||||||
|     private String phone; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 邮箱 |  | ||||||
|      */ |  | ||||||
|     private String email; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 部门状态:0正常,1停用 |  | ||||||
|      */ |  | ||||||
|     private String status; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 删除标志(0代表存在 2代表删除) |  | ||||||
|      */ |  | ||||||
|     private String delFlag; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 父部门名称 |  | ||||||
|      */ |  | ||||||
|     private String parentName; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 子部门 |  | ||||||
|      */ |  | ||||||
|     private List<SysDept> children = new ArrayList<SysDept>(); |  | ||||||
|  |  | ||||||
|     @NotBlank(message = "部门名称不能为空") |  | ||||||
|     @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符") |  | ||||||
|     public String getDeptName() { |  | ||||||
|         return deptName; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @NotBlank(message = "显示顺序不能为空") |  | ||||||
|     public String getOrderNum() { |  | ||||||
|         return orderNum; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") |  | ||||||
|     public String getPhone() { |  | ||||||
|         return phone; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Email(message = "邮箱格式不正确") |  | ||||||
|     @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符") |  | ||||||
|     public String getEmail() { |  | ||||||
|         return email; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @@ -0,0 +1,62 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept; | ||||||
|  |  | ||||||
|  | import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | ||||||
|  | import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
|  | import com.baomidou.mybatisplus.annotation.TableName; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.EqualsAndHashCode; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 部门表 sys_dept | ||||||
|  |  * | ||||||
|  |  * @author ruoyi | ||||||
|  |  */ | ||||||
|  | @TableName("sys_dept") | ||||||
|  | @Data | ||||||
|  | @EqualsAndHashCode(callSuper = true) | ||||||
|  | public class SysDeptDO extends BaseDO { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 部门ID | ||||||
|  |      */ | ||||||
|  |     @TableId | ||||||
|  |     private Long id; | ||||||
|  |     /** | ||||||
|  |      * 部门名称 | ||||||
|  |      */ | ||||||
|  |     private String name; | ||||||
|  |     /** | ||||||
|  |      * 父部门ID | ||||||
|  |      * | ||||||
|  |      * 外键 {@link #id} | ||||||
|  |      */ | ||||||
|  |     private Long parentId; | ||||||
|  |     /** | ||||||
|  |      * 祖级列表 | ||||||
|  |      */ | ||||||
|  |     private String ancestors; | ||||||
|  |     /** | ||||||
|  |      * 显示顺序 | ||||||
|  |      */ | ||||||
|  |     private String sort; | ||||||
|  |     /** | ||||||
|  |      * 负责人 | ||||||
|  |      */ | ||||||
|  |     private String leader; | ||||||
|  |     /** | ||||||
|  |      * 联系电话 | ||||||
|  |      */ | ||||||
|  |     private String phone; | ||||||
|  |     /** | ||||||
|  |      * 邮箱 | ||||||
|  |      */ | ||||||
|  |     private String email; | ||||||
|  |     /** | ||||||
|  |      * 部门状态 | ||||||
|  |      * | ||||||
|  |      * 枚举 {@link CommonStatusEnum} | ||||||
|  |      */ | ||||||
|  |     private Integer status; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.user; | |||||||
| import cn.iocoder.dashboard.framework.excel.Excel; | import cn.iocoder.dashboard.framework.excel.Excel; | ||||||
| import cn.iocoder.dashboard.framework.excel.Excels; | import cn.iocoder.dashboard.framework.excel.Excels; | ||||||
| import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; | ||||||
| import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDept; | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | ||||||
| import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO; | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.permission.SysRoleDO; | ||||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||||
| import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||||
| @@ -120,7 +120,7 @@ public class SysUserDO extends BaseDO { | |||||||
|             @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT) |             @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT) | ||||||
|     }) |     }) | ||||||
|     @TableField(exist = false) |     @TableField(exist = false) | ||||||
|     private SysDept dept; |     private SysDeptDO dept; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 角色对象 |      * 角色对象 | ||||||
|   | |||||||
| @@ -0,0 +1,21 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.service.dept; | ||||||
|  |  | ||||||
|  | import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dept.SysDeptDO; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 部门 Service 接口 | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | public interface SysDeptService { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 获得所有部门列表 | ||||||
|  |      * | ||||||
|  |      * @return 菜单列表 | ||||||
|  |      */ | ||||||
|  |     List<SysDeptDO> listDepts(); | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,27 @@ | |||||||
|  | package cn.iocoder.dashboard.modules.system.service.dept.impl; | ||||||
|  |  | ||||||
|  | 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; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  |  | ||||||
|  | import javax.annotation.Resource; | ||||||
|  | import java.util.List; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 部门 Service 实现类 | ||||||
|  |  * | ||||||
|  |  * @author 芋道源码 | ||||||
|  |  */ | ||||||
|  | @Service | ||||||
|  | public class SysDeptServiceImpl implements SysDeptService { | ||||||
|  |  | ||||||
|  |     @Resource | ||||||
|  |     private SysDeptMapper deptMapper; | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public List<SysDeptDO> listDepts() { | ||||||
|  |         return deptMapper.selectList(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV