通过数据表,告诉创建entity、dao
我有如下的一个例子,主要是关于 一个mysql数据表给出后,可以新建如下的类:
数据表
CREATE TABLE `t_batch_follow_up_record` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '@cname:主键ID',
`name` VARCHAR(64) NULL DEFAULT NULL COMMENT '@cname:批次名称' COLLATE 'utf8mb4_general_ci',
`plan_start_time` DATE NOT NULL COMMENT '@cname:计划开始时间',
`plan_end_time` DATE NOT NULL COMMENT '@cname:计划结束时间',
`recipient` VARCHAR(512) NULL DEFAULT NULL COMMENT '@cname:收件人' COLLATE 'utf8mb4_general_ci',
`ccto` VARCHAR(1024) NULL DEFAULT NULL COMMENT '@cname:抄送人' COLLATE 'utf8mb4_general_ci',
`hhmmss` VARCHAR(10) NULL DEFAULT NULL COMMENT '@cname:发送时间' COLLATE 'utf8mb4_general_ci',
`send_cycle_type` INT(4) NOT NULL COMMENT '@cname:发送周期类型 1-每天,2-按周',
`day_of_week` INT(4) NULL DEFAULT NULL COMMENT '@cname:如果按周,则设置周几,1-周一,依次,7-周日',
`status` INT(4) NULL DEFAULT NULL COMMENT '@cname:状态。1-待进行 2-进行中 3-已结束',
`create_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '@cname:创建时间',
`create_user` VARCHAR(32) NULL DEFAULT NULL COMMENT '@cname:创建用户ssouserid' COLLATE 'utf8mb4_general_ci',
`create_user_name` VARCHAR(64) NULL DEFAULT NULL COMMENT '@cname:创建用户名称' COLLATE 'utf8mb4_general_ci',
`update_time` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '@cname:更新时间',
`update_user` VARCHAR(32) NULL DEFAULT NULL COMMENT '@cname:更新用户ssouserid' COLLATE 'utf8mb4_general_ci',
`update_user_name` VARCHAR(64) NULL DEFAULT NULL COMMENT '@cname:更新用户名称' COLLATE 'utf8mb4_general_ci',
`deleted` BIT(1) NOT NULL DEFAULT 'b\'0\'' COMMENT '@cname:是否删除',
PRIMARY KEY (`id`) USING BTREE,
INDEX `t_name` (`name`) USING BTREE
)
COMMENT='@cname: 跟进批次-记录表'
COLLATE='utf8mb4_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=27
;
会新建如下的类,条件如下
----------------------------------
第一个类开始
如下:
类的命名:数据表+Entity (注意把数据表t_移除)
类需要继承 cn.mucang.simple.db.entity.IdEntity
类是字段,就是对应的t_batch_follow_up_record的字段,并根据对应的数据库字段类型,映射java字段类型
映射的规则:
数据表字段类型 java类型
BIGINT 并且不能为空 not null long
BIGINT 可以为 NULL Long(封装类型)
varchar String
DATE java.sql.Date
INT 并且不能为空 not null int
INT 并且可以为空 null Integer(封装类型)
TIMESTAMP java.sql.Timestamp
BIT 并且不能为空 boolean
BIT 可以为空 Boolean(封装类型)
另外对于BatchFollowUpRecordEntity.QEntity 这个内部类对应的字段说明
1 他也是根据t_batch_follow_up_record字段生成对应的如下属性的字段
2 字段对应的类是cn.mucang.simple.db.dao.EntityField
3 public final EntityField id = new EntityField("id", "id", Long.class, true, -1,
BatchFollowUpRecordEntity.class);
以t_batch_follow_up_record.id对应的字段id进行说明
构造函数第一个参数是数据表字段的驼峰规则
构造函数第二个参数是数据表字段同样的写法
构造函数第三个参数是 数据表字段类型 映射的 java类型
构造函数第四个参数表示是否为空,根据数据表字段是否可以为null来确定
构造函数第五个参数表示数据表字段的长度,如果不能为空则为-1,如果可以为空,根据数据表字段设置的长度来确定,如果得不到长度,就给-1
构造函数第六个参数表示对应的生成的类(第一个类)
public class BatchFollowUpRecordEntity extends IdEntity {
public static final QEntity Fields = new QEntity();
/**
* 批次名称
*/
private String name;
/**
* 计划开始时间
*/
private Date planStartTime;
/**
* 计划结束时间
*/
private Date planEndTime;
/**
* 收件人,多个用;分隔
*/
private String recipient;
/**
* 抄送人
*/
private String ccto;
/**
* 发送时间
*/
private String hhmmss;
/**
* 发送周期类型 1-每天,2-按周
*/
private int sendCycleType;
/**
* 如果按周,则设置周几,1-周一,依次,7-周日
*/
private Integer dayOfWeek;
/**
* 状态。1-待进行 2-进行中 3-已结束
*/
private Integer status;
/**
* 创建时间
*/
private Timestamp createTime;
/**
* 创建用户ssouserid
*/
private String createUser;
/**
* 创建用户名称
*/
private String createUserName;
/**
* 更新时间
*/
private Timestamp updateTime;
/**
* 更新用户ssouserid
*/
private String updateUser;
/**
* 更新用户名称
*/
private String updateUserName;
/**
* 是否删除
*/
private boolean deleted;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Date getPlanStartTime() {
return this.planStartTime;
}
public void setPlanStartTime(Date planStartTime) {
this.planStartTime = planStartTime;
}
public Date getPlanEndTime() {
return this.planEndTime;
}
public void setPlanEndTime(Date planEndTime) {
this.planEndTime = planEndTime;
}
public String getRecipient() {
return this.recipient;
}
public void setRecipient(String recipient) {
this.recipient = recipient;
}
public String getCcto() {
return this.ccto;
}
public void setCcto(String ccto) {
this.ccto = ccto;
}
public String getHhmmss() {
return this.hhmmss;
}
public void setHhmmss(String hhmmss) {
this.hhmmss = hhmmss;
}
public int getSendCycleType() {
return this.sendCycleType;
}
public void setSendCycleType(int sendCycleType) {
this.sendCycleType = sendCycleType;
}
public Integer getDayOfWeek() {
return this.dayOfWeek;
}
public void setDayOfWeek(Integer dayOfWeek) {
this.dayOfWeek = dayOfWeek;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Timestamp getCreateTime() {
return this.createTime;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
public String getCreateUser() {
return this.createUser;
}
public void setCreateUser(String createUser) {
this.createUser = createUser;
}
public String getCreateUserName() {
return this.createUserName;
}
public void setCreateUserName(String createUserName) {
this.createUserName = createUserName;
}
public Timestamp getUpdateTime() {
return this.updateTime;
}
public void setUpdateTime(Timestamp updateTime) {
this.updateTime = updateTime;
}
public String getUpdateUser() {
return this.updateUser;
}
public void setUpdateUser(String updateUser) {
this.updateUser = updateUser;
}
public String getUpdateUserName() {
return this.updateUserName;
}
public void setUpdateUserName(String updateUserName) {
this.updateUserName = updateUserName;
}
public boolean isDeleted() {
return this.deleted;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public static class QEntity {
public final EntityField id = new EntityField("id", "id", Long.class, true, -1, BatchFollowUpRecordEntity.class);
public final EntityField name = new EntityField("name", "name", String.class, true, 64, BatchFollowUpRecordEntity.class);
public final EntityField planStartTime = new EntityField("planStartTime", "plan_start_time", Date.class, false, -1, BatchFollowUpRecordEntity.class);
public final EntityField planEndTime = new EntityField("planEndTime", "plan_end_time", Date.class, false, -1, BatchFollowUpRecordEntity.class);
public final EntityField recipient = new EntityField("recipient", "recipient", String.class, true, 512, BatchFollowUpRecordEntity.class);
public final EntityField ccto = new EntityField("ccto", "ccto", String.class, true, 1024, BatchFollowUpRecordEntity.class);
public final EntityField hhmmss = new EntityField("hhmmss", "hhmmss", String.class, true, 10, BatchFollowUpRecordEntity.class);
public final EntityField sendCycleType = new EntityField("sendCycleType", "send_cycle_type", int.class, false, -1, BatchFollowUpRecordEntity.class);
public final EntityField dayOfWeek = new EntityField("dayOfWeek", "day_of_week", Integer.class, true, -1, BatchFollowUpRecordEntity.class);
public final EntityField status = new EntityField("status", "status", Integer.class, true, -1, BatchFollowUpRecordEntity.class);
public final EntityField createTime = new EntityField("createTime", "create_time", Timestamp.class, false, -1, BatchFollowUpRecordEntity.class);
public final EntityField createUser = new EntityField("createUser", "create_user", String.class, true, 32, BatchFollowUpRecordEntity.class);
public final EntityField createUserName = new EntityField("createUserName", "create_user_name", String.class, true, 64, BatchFollowUpRecordEntity.class);
public final EntityField updateTime = new EntityField("updateTime", "update_time", Timestamp.class, false, -1, BatchFollowUpRecordEntity.class);
public final EntityField updateUser = new EntityField("updateUser", "update_user", String.class, true, 32, BatchFollowUpRecordEntity.class);
public final EntityField updateUserName = new EntityField("updateUserName", "update_user_name", String.class, true, 64, BatchFollowUpRecordEntity.class);
public final EntityField deleted = new EntityField("deleted", "deleted", boolean.class, false, -1, BatchFollowUpRecordEntity.class);
}
}
第一个类结束
---------------------------------------------
--------------------------
第二个类,如下:
1 类的命名,BatchFollowUpJiaxiaoInfoEntityDao,是数据表t_batch_follow_up_record+EntityDao(注意把t_移除哦)
2 继承cn.mucang.simple.db.dao.proxy.BaseProxyDao 并且泛型是第一类BatchFollowUpJiaxiaoInfoEntity
3 并且类的注解是@DataBase,来自cn.mucang.simple.db.dao.proxy.annotations.DataBase
4 @DataBase
public interface BatchFollowUpJiaxiaoInfoEntityDao extends BaseProxyDao<BatchFollowUpJiaxiaoInfoEntity> {
BatchFollowUpJiaxiaoInfoEntity.QEntity q = BatchFollowUpJiaxiaoInfoEntity.Fields;
}
第二个类结束
--------------------------
我现在有如下一个表,请帮我按上面规则生成。
1 按前面的规则
2 强调一下不要使用lombok,正常生成get set工具
3 继承IdEntity