初始化 dept 部门模块

pull/2/head
YunaiV 2021-01-09 20:24:40 +08:00
parent be2ba5be28
commit 6edd4d7eae
13 changed files with 285 additions and 102 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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;
/**
*

View File

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

View File

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