diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java new file mode 100644 index 000000000..0f60289e7 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/SysDeptController.java @@ -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 { + + + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptBaseVO.java new file mode 100644 index 000000000..1f08bfd68 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptBaseVO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptCreateReqVO.java new file mode 100644 index 000000000..3e18aa4dd --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptCreateReqVO.java @@ -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 { +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptListReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptListReqVO.java new file mode 100644 index 000000000..6d335b017 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptListReqVO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java new file mode 100644 index 000000000..0cb8c9648 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptRespVO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java new file mode 100644 index 000000000..8bba0c82b --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptSimpleRespVO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptUpdateReqVO.java new file mode 100644 index 000000000..ac437d4eb --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/dept/SysDeptUpdateReqVO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dept/SysDeptMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dept/SysDeptMapper.java new file mode 100644 index 000000000..915d008bb --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dao/dept/SysDeptMapper.java @@ -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 { + + default List selectList() { + return selectList(null); + } + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDept.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDept.java deleted file mode 100644 index 0abca0740..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDept.java +++ /dev/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 children = new ArrayList(); - - @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; - } - -} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDeptDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDeptDO.java new file mode 100644 index 000000000..da826f082 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/dept/SysDeptDO.java @@ -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; + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/user/SysUserDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/user/SysUserDO.java index 68d83c5de..de6d3b786 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/user/SysUserDO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dataobject/user/SysUserDO.java @@ -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.Excels; 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 com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -120,7 +120,7 @@ public class SysUserDO extends BaseDO { @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT) }) @TableField(exist = false) - private SysDept dept; + private SysDeptDO dept; /** * 角色对象 diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java new file mode 100644 index 000000000..d026ac1ee --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysDeptService.java @@ -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 listDepts(); + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java new file mode 100644 index 000000000..aaf52e2f6 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/impl/SysDeptServiceImpl.java @@ -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 listDepts() { + return deptMapper.selectList(); + } + +}