本章介绍项目实体信息规划及对应实体创建,并引入A.CTable实现实体信息和数据表表的自动对应,自动创建数据库表。
源码下载:点击下载
讲解视频:
SMM+VUE3实现设备维修管理系统毕设:系统实体创建
一、系统实体规划
1.1 实体基础类
所有实体的基础类型,定义基本的属性,包括id、创建时间、备注信息等字段。
package com.junjunjun.device.entity;
import java.io.Serializable;
public abstract class BaseEntity implements Serializable{
private static final long serialVersionUID = 1L;
}
package com.junjunjun.device.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.IgnoreUpdate;
import com.gitee.sunchenbin.mybatis.actable.annotation.Index;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public abstract class BaseDataEntity extends BaseEntity{
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
@Column(isNull=false,isKey=true,isAutoIncrement=true,comment="主键")
@IgnoreUpdate
@Index
@Unique
private Long id ;
@TableField("create_date")
@Column(isNull=false,type=MySqlTypeConstant.DATETIME,defaultValue="CURRENT_TIMESTAMP",comment="创建时间")
@IgnoreUpdate
@Index
private Date createDate;
@Column(length=1024,comment="备注")
private String remark;
}
1.2 设备信息
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | String | 20 | | |
3 | Categoryid | 分类id | Long | 10 | 外键 | |
4 | Status | 状态 | string | 1 | | |
5 | count | 数量 | double | 11 | | |
6 | date | 日期 | Date | - | | |
7 | xinhao | 型号 | string | 100 | | |
8 | icon | 图片 | string | 20 | | |
9 | userid | 使用人 | Long | 10 | 外键 | |
10 | description | 描述 | string | 1024 | | |
11 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.device;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.DeviceStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_device",autoResultMap =true)
@Table(name="sys_device",comment="设备信息",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Device extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,decimalLength =50,comment="名称")
private String name ;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="状态")
private DeviceStatus status ;
@Column(isNull=false,decimalLength = 2,comment="数量")
private double count ;
@Column(length=50,comment="型号")
private String xinhao ;
@Column(length=50,comment="图标")
private String icon ;
@Column(isNull=false,type=MySqlTypeConstant.TEXT,comment="描述")
private String description ;
@Column(isNull=false,comment="分类")
private Long categoryId ;
@Column(comment="使用人")
private Long userId ;
@Column(comment="使用部门")
private Long departmentId ;
}
1.3 设备分类
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | String | 20 | | |
3 | parentid | 上级 | Long | 10 | 外键 | |
4 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.device;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.DeviceStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_device",autoResultMap =true)
@Table(name="sys_device",comment="设备信息",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Device extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,decimalLength =50,comment="名称")
private String name ;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="状态")
private DeviceStatus status ;
@Column(isNull=false,decimalLength = 2,comment="数量")
private double count ;
@Column(length=50,comment="型号")
private String xinhao ;
@Column(length=50,comment="图标")
private String icon ;
@Column(isNull=false,type=MySqlTypeConstant.TEXT,comment="描述")
private String description ;
@Column(isNull=false,comment="分类")
private Long categoryId ;
@Column(comment="使用人")
private Long userId ;
@Column(comment="使用部门")
private Long departmentId ;
}
1.4 设备使用记录
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 使用人 | Long | 10 | 外键 | |
3 | startdate | 开始日期 | Date | - | | |
4 | enddate | 结束日期 | Date | - | | |
5 | departmentid | 部门id | Long | 10 | 外键 | |
6 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.device;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_device_use_record",autoResultMap =true)
@Table(name="sys_device_use_record",comment="设备使用记录",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class DeviceUserRecord extends BaseDataEntity {
private static final long serialVersionUID = 1L;
@Column(isNull=false,comment="使用人")
private Long userId ;
@Column(isNull=false,type=MySqlTypeConstant.DATETIME,comment="开始时间")
@TableField("start")
private Date start;
@Column(type=MySqlTypeConstant.DATETIME,comment="截至时间")
@TableField("end")
private Date end;
@Column(isNull=false,comment="使用部门")
private Long departmentId ;
@Column(isNull=false,comment="设备")
private Long deviceId ;
}
1.5 验收记录
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 验收人 | Long | 10 | 外键 | |
3 | requestid | 申请id | Long | 10 | 外键 | |
4 | status | 状态 | string | 1 | | |
5 | equipmentid | 设备id | Long | 10 | 外键 | |
6 | content | 维修明细 | string | 2048 | | |
7 | Detailid | 维修清单 | Long | 10 | 外键 | |
8 | startdate | 开始时间 | Date | - | | |
9 | Enddate | 开始时间 | Date | - | | |
10 | Recordid | 维修记录 | Long | 10 | 外键 | |
11 | result | 验收结果 | string | 2048 | | |
12 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.repair;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.CheckStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_check_record",autoResultMap =true)
@Table(name="sys_check_record",comment="验收记录",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class CheckRecord extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(type=MySqlTypeConstant.TEXT,comment="验收结果")
private String result;
@Column(isNull=false,type=MySqlTypeConstant.LONGTEXT,comment="维修明细")
private String content;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="状态")
private CheckStatus status;
@Column(comment="验收人")
private Long userId ;
@Column(isNull=false,type=MySqlTypeConstant.DATETIME,comment="开始时间")
@TableField("start")
private Date start;
@Column(type=MySqlTypeConstant.DATETIME,comment="截至时间")
@TableField("end")
private Date end;
@Column(isNull=false,comment="申请单")
private Long requestId ;
@Column(isNull=false,comment="设备")
private Long deviceId ;
@Column(isNull=false,comment="设备")
private Long detailId ;
@Column(isNull=false,comment="维修记录")
private Long recordId ;
}
1.6 维修明细数据
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 评估人 | Long | 10 | 外键 | |
3 | requestid | 申请id | Long | 10 | 外键 | |
4 | examineuserid | 审核人 | Long | 10 | 外键 | |
5 | examinedate | 审核时间 | Date | - | | |
6 | examineinfo | 审核信息 | string | 2048 | | |
7 | type | 维修类型 | string | 1 | | |
8 | status | 状态 | string | 1 | | |
9 | content | 维修明细 | string | 2048 | | |
10 | Date | 审核时间 | Date | - | | |
11 | equipmentid | 设备id | Long | 10 | 外键 | |
12 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.repair;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_repair_detail",autoResultMap =true)
@Table(name="sys_repair_detail",comment="维修明细",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class RepairDetail extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=100,comment="故障类型")
private String type;
@Column(isNull=false,type=MySqlTypeConstant.LONGTEXT,comment="维修明细")
private String content;
@Column(isNull=false,comment="评估人")
private Long userId ;
@Column(isNull=false,comment="申请单")
private Long requestId ;
@Column(isNull=false,comment="设备")
private Long deviceId ;
}
1.7 维修记录数据
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 维修人 | Long | 10 | 外键 | |
3 | requestid | 申请id | Long | 10 | 外键 | |
4 | type | 维修类型 | string | 1 | | |
5 | status | 状态 | string | 1 | | |
6 | content | 维修明细 | string | 2048 | | |
7 | Detailid | 维修清单 | Long | 10 | 外键 | |
8 | startdate | 开始时间 | Date | - | | |
9 | Enddate | 开始时间 | Date | - | | |
10 | equipmentid | 设备id | Long | 10 | 外键 | |
11 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.repair;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.RequestStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_repair_record",autoResultMap =true)
@Table(name="sys_repair_record",comment="维修记录",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class RepairRecord extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=100,comment="故障类型")
private String type;
@Column(type=MySqlTypeConstant.LONGTEXT,comment="维修明细")
private String content;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="状态")
private RequestStatus status;
@Column(length=2048,comment="维修明细")
private String exmaineinfo;
@Column(comment="评估人")
private Long userId ;
@Column(isNull=false,type=MySqlTypeConstant.DATETIME,comment="开始时间")
@TableField("start")
private Date start;
@Column(type=MySqlTypeConstant.DATETIME,comment="截至时间")
@TableField("end")
private Date end;
@Column(isNull=false,comment="申请单")
private Long requestId ;
@Column(isNull=false,comment="设备")
private Long deviceId ;
@Column(comment="维修明细")
private Long detailId ;
@Column(comment="审核人")
private Long exmaineuserId ;
@Column(type=MySqlTypeConstant.DATETIME,comment="审核时间")
@TableField("exmainedate")
private Date exmainedate;
}
1.8 维修申请记录
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 申请人 | Long | 10 | 外键 | |
3 | startdate | 开始日期 | Date | - | | |
4 | enddate | 结束日期 | Date | - | | |
5 | departmentid | 部门id | Long | 10 | 外键 | |
6 | equipmentid | 设备id | Long | 10 | 外键 | |
7 | guzhang | 故障描述 | string | 2048 | | |
8 | type | 故障类型 | string | 1 | | |
9 | status | 状态 | string | 1 | | |
10 | examineuserid | 审核人 | Long | 10 | 外键 | |
11 | examinedate | 审核时间 | Date | - | | |
12 | examineinfo | 审核信息 | string | 2048 | | |
13 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.repair;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.RequestStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_repair_request",autoResultMap =true)
@Table(name="sys_repair_request",comment="維修申请记录",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Request extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=100,comment="故障类型")
private String type;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="审核结果")
private RequestStatus status;
@Column(length=2048,comment="审核描述")
private String exmaineinfo;
@Column(isNull=false,comment="申请人")
private Long userId ;
@Column(isNull=false,comment="部门")
private Long departmentId ;
@Column(isNull=false,comment="设备")
private Long deviceId ;
@Column(comment="审核人")
private Long exmaineuserId ;
@Column(type=MySqlTypeConstant.DATETIME,comment="审核时间")
@TableField("exmainedate")
private Date exmainedate;
}
1.9 维修申请审核处理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 申请人 | Long | 10 | 外键 | |
3 | requestid | 申请id | Long | 10 | 外键 | |
4 | examineuserid | 审核人 | Long | 10 | 外键 | |
5 | examinedate | 审核时间 | Date | - | | |
6 | examineinfo | 审核信息 | string | 2048 | | |
7 | type | 故障类型 | string | 1 | | |
8 | status | 状态 | string | 1 | | |
9 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.repair;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.RequestStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_repair_request_examine_record",autoResultMap =true)
@Table(name="sys_repair_request_examine_record",comment="审核记录",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class RequestExamineRecord extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=1,type=MySqlTypeConstant.INT,comment="审核结果")
private RequestStatus status;
@Column(isNull=false,length=2048,comment="审核描述")
private String exmaineinfo;
@Column(isNull=false,comment="使用人")
private Long userId ;
@Column(isNull=false,comment="使用人")
private Long requestId ;
@Column(isNull=false,comment="使用人")
private Long deviceId ;
@Column(isNull=false,comment="审核人")
private Long exmaineuserId ;
@Column(isNull=false,type=MySqlTypeConstant.DATETIME,comment="审核时间")
@TableField("exmainedate")
private Date exmainedate;
}
1.10 部门数据管理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | String | 20 | | |
3 | userid | 负责人ID | Long | 10 | 外键 | |
4 | parentid | 上级 | Long | 10 | 外键 | |
5 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "sys_department", autoResultMap = true)
@Table(name = "sys_department", comment = "部门信息", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
public class Department extends BaseDataEntity {
private static final long serialVersionUID = 1L;
@Column(isNull = false, length = 40, comment = "名称")
private String name;
@Column(comment = "上级")
private Long parentId;
@Column(comment = "负责人")
private Long userId;
}
1.11 数据字典管理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | string | 20 | | |
3 | Key | 标识 | string | 20 | | |
4 | Vallue | 值 | string | 1024 | | |
5 | Sort | 顺序 | Int | 8 | | |
6 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_dict",autoResultMap =true)
@Table(name="sys_dict",comment="数据字典",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Dict extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@TableField("key_")
@Column(isNull=false,length=40,comment="标识")
private String key ;
@Column(isNull=false,length=40,comment="名称")
private String name ;
@Column(length=1024,comment="值")
private String value ;
@TableField("sort_")
@Column(comment="顺序")
private int sort;
}
1.12 系统日志管理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | userid | 用户ID | Long | 10 | 外键 | |
3 | ip | ip | string | 30 | | |
4 | msg | 操作内容 | string | 1024 | | |
5 | date | 操作时间 | Date | - | | |
6 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_log",autoResultMap =true)
@Table(name="sys_log",comment="操作日志",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Log extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=30,comment="IP")
private String ip ;
@Column(isNull=false,length=20,comment="操作类型")
private String type;
@Column(isNull=false,length=20480,comment="參數")
private String pama;
@Column(isNull=false,length=300,comment="访问地址")
private String url;
@Column(isNull=false,type=MySqlTypeConstant.LONGTEXT,comment="返回參數")
private String result;
@Column(isNull=false,length=300,comment="執行方法")
private String method;
@Column(isNull=false,type=MySqlTypeConstant.LONGTEXT,comment="访问明细")
private String msg ;
@Column(comment="操作用户")
private Long userId ;
}
1.13 系统菜单管理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | string | 10 | | |
3 | Path | 路径 | string | 20 | | |
4 | compentent | 组件 | string | 50 | | |
5 | Icon | 图标 | string | 20 | | |
6 | Sort | 顺序 | Int | 8 | | |
7 | permission | 权限标识 | string | 50 | | |
8 | parent | 上级 | Long | 10 | 外键 | |
9 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import org.springframework.security.core.GrantedAuthority;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_menu",autoResultMap =true)
@Table(name="sys_menu",comment="系統菜單",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Menu extends BaseDataEntity implements GrantedAuthority{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=40,comment="名称")
private String name ;
@Column(length=40,comment="路径")
private String path ;
@Column(length=40,comment="权限标识")
private String permission ;
@Column(length=40,comment="名称")
private String compentent ;
@Column(length=40,comment="名称")
private String icon ;
@TableField("sort_")
@Column(comment="名称")
private int sort ;
@Column(comment="上级")
private Long parentId ;
@Column(comment="是否前端展示")
private Boolean isShow;
@Override
public String getAuthority() {
return permission;
}
}
1.14 系统角色管理
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | string | 20 | | |
3 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_role",autoResultMap =true)
@Table(name="sys_role",comment="角色表",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB,excludeFields= {"serialVersionUID","menus"})
public class Role extends BaseDataEntity {
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=40,comment="名称")
private String name ;
@Column(length=40,comment="权限标识")
private String permission ;
@TableField(exist = false)
private List<Menu> menus;
}
1.15 角色菜单关联表
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | role_id | 角色ID | Long | 10 | 外键 | |
2 | menu_id | 菜单ID | Long | 10 | 外键 | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_role_menu",autoResultMap =true)
@Table(name="sys_role_menu",comment="角色菜单关联表 ",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB,excludeFields= {"serialVersionUID"})
public class RoleMenuItem extends BaseEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,comment="菜单")
private Long menuId ;
@Column(isNull=false,comment="角色")
private Long roleId ;
}
1.16 系统配置数据
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | Name | 名称 | string | 20 | | |
3 | Key | 标识 | string | 20 | | |
4 | Vallue | 值 | string | 1024 | | |
5 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseDataEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_setting",autoResultMap =true)
@Table(name="sys_setting",comment="系統配置",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class Setting extends BaseDataEntity{
private static final long serialVersionUID = 1L;
@TableField("key_")
@Column(isNull=false,length=40,comment="标识")
@Unique
private String key ;
@Column(isNull=false,length=40,comment="名称")
private String name ;
@Column(length=1024,comment="值")
private String value ;
}
1.17 系统用户管理数据
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | ID | ID | Long | 10 | 主键 | |
2 | account | 账号 | string | 10 | | |
3 | name | 姓名 | string | 5 | | |
4 | sex | 性别 | string | 1 | | |
5 | phone | 电话 | string | 11 | | |
6 | password | 密码 | string | 50 | | |
7 | job | 职位 | string | 50 | | |
8 | deparemnt | 部门 | Long | 10 | 外键 | |
9 | remark | 备注 | string | 1024 | | |
package com.junjunjun.device.entity.system;
import java.util.Collection;
import java.util.List;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Index;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.annotation.Unique;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.google.common.collect.Lists;
import com.junjunjun.device.entity.BaseDataEntity;
import com.junjunjun.device.enums.Grade;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_user",autoResultMap =true)
@Table(name="sys_user",comment="用户表",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB,excludeFields= {"serialVersionUID","roles"})
public class User extends BaseDataEntity implements UserDetails{
private static final long serialVersionUID = 1L;
@Column(isNull=false,length=20,comment="登录账号")
@Unique
@Index
private String account ;
private boolean status;
@Column(isNull=false,length=40,comment="登录账号")
private String name ;
@Column(type=MySqlTypeConstant.INT,comment="性别")
private Grade sex ;
@Column(isNull=false,length=11,comment="电话")
@Unique
@Index
private String phone ;
@Column(isNull=false,length=100,comment="密碼")
private String password ;
@Column(length=20,comment="职位")
private String job ;
@Column(comment="部门")
private Long departmentId ;
@TableField(exist = false)
private List<Role> roles;
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
List<GrantedAuthority> results = Lists.newArrayList();
if(roles!=null) {
roles.forEach(item->{
if(item.getMenus()!=null) {
item.getMenus().forEach(menuItem->{
results.add(menuItem);
});
}
results.add(new SimpleGrantedAuthority(item.getPermission()));
});
}
return results;
}
@Override
public String getUsername() {
return account;
}
}
1.18 用户角色关联表
序号 | 列名 | 名称 | 类型 | 长度 | 描述 | 备注 |
---|
1 | role_id | 角色ID | Long | 10 | 外键 | |
2 | User_id | 用户ID | Long | 10 | 外键 | |
package com.junjunjun.device.entity.system;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant;
import com.junjunjun.device.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="sys_user_role",autoResultMap =true)
@Table(name="sys_user_role",comment="用戶角色关联表",charset=MySqlCharsetConstant.UTF8MB4,engine=MySqlEngineConstant.InnoDB)
public class UserRoleItem extends BaseEntity{
private static final long serialVersionUID = 1L;
@Column(isNull=false,comment="用戶")
private Long userId ;
@Column(isNull=false,comment="角色")
private Long roleId ;
}
二、A.Ctable配置
maven引入:
<dependency>
<groupId>com.gitee.sunchenbin.mybatis.actable</groupId>
<artifactId>mybatis-enhance-actable</artifactId>
<version>1.5.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
</exclusion>
</exclusions>
</dependency>
启动类上添加扫描配置:
@MapperScan({ "com.baomidou.mybatisplus.samples.quickstart.mapper", "com.gitee.sunchenbin.mybatis.actable.dao.*",
"com.junjunjun.device.dao.*" })
@ComponentScan({"com.gitee.sunchenbin.mybatis.actable.manager.*","com.junjunjun.device.*"})
配置文件中添加相关配置:
@MapperScan({ "com.baomidou.mybatisplus.samples.quickstart.mapper", "com.gitee.sunchenbin.mybatis.actable.dao.*",
"com.junjunjun.device.dao.*" })
@ComponentScan({"com.gitee.sunchenbin.mybatis.actable.manager.*","com.junjunjun.device.*"})
A.Ctable官网文档:https://gitee.com/sunchenbin/mybatis-enhance