All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.jiangzeyin.entity.base.BaseEntity Maven / Gradle / Ivy

package cn.jiangzeyin.entity.base;

import cn.jiangzeyin.util.util.date.DateUtil;

import java.io.Serializable;

/**
 * 所有 实体 必须 有的属性
 *
 * @author jiangzeyin
 */
public abstract class BaseEntity implements Serializable {

    private Integer id;
    private String name;
    private Integer isDelete;
    private Integer createTime;
    private Integer modifyTime;
    private String mark;

    public enum IsDelete implements BaseEnum {
        active(0, "未删除"),
        death(1, "已删除");
        private int code;
        private String desc;

        @Override
        public int getCode() {
            return code;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        IsDelete(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public static String getSql() {
            return getSql(active);// String.format("isDelete=%d", active.getCode());
        }

        public static String getSql(IsDelete isDelete) {
            return String.format(" isDelete=%d", isDelete.getCode());
        }
    }


    public String getMark() {
        return mark;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    /**
     * 获取创建时间 默认格式
     * 

* yyyy-MM-dd HH:mm:ss * * @return time * @author jiangzeyin */ public String getCreateTime() { return getCreateTime(""); } /** * 获取修改时间 默认格式 *

* yyyy-MM-dd HH:mm:ss * * @param pattern pat * @return time * @author jiangzeyin */ public String getCreateTime(String pattern) { if (createTime == null) return ""; return DateUtil.FormatTimeStamp(pattern, createTime); } public void setCreateTime(Integer createTime) { this.createTime = createTime; } /** * 获取上次修改时间 默认格式 *

* yyyy-MM-dd HH:mm:ss * * @return time * @author jiangzeyin */ public String getModifyTime() { return getModifyTime(""); } public String getModifyTime(String pattern) { if (modifyTime == null) return ""; return DateUtil.FormatTimeStamp(pattern, modifyTime); } public int getModifyTimeInt() { if (modifyTime == null) return 0; return modifyTime; } public void setModifyTime(Integer modifyTime) { this.modifyTime = modifyTime; } /** * id 在后台默认排序是 第一个 * * @return id * @author jiangzeyin */ public Integer getId() { if (id == null) return -1; return id; } public T setId(Integer id) { this.id = id; return (T) this; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getIsDelete() { if (isDelete == null) return IsDelete.active.code; return isDelete; } public void setIsDelete(int isDelete) { this.isDelete = isDelete; } @Override public String toString() { return "BaseEntity [id=" + id + ", name=" + name + ", isDelete=" + isDelete + ", createTime=" + createTime + ", modifyTime=" + modifyTime + ", mark=" + mark + "]"; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy