package com.hzya.frame.web.entity;

import cn.dev33.satoken.stp.StpUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.hzya.frame.uuid.UUIDUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.ObjectUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 基类
 *
 * @author Administrator
 */
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler", "operations", "roles", "menus"})
public class BaseEntity implements Serializable {

    private static final long serialVersionUID = 5490326162916773912L;
    /**
     * 主键ID
     */
    private String id;
    /**
     * 创建人ID
     */
    private String create_user_id;
    /**
     * 创建时间ID
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date create_time;
    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date modify_time;
    /**
     * 修改人ID
     */
    private String modify_user_id;
    /**
     * 所属组织机构
     */
    private String org_id;

    /**  公司id */
    private String companyId;
    /**
     * 状态
     */
    private String sts;

    //==========分页用==============
    private Long start;
    private Long limit;
    private Long offset;
    private String sort;
    private String order;
    private String dir;
    private Long rows;
    private Long page;
    //==========分页用==============
    //区分数据库类型
    private String dialect_type;
    private Integer pageNum;
    private Integer pageSize;
    //排序号
    private Long sorts;
    /****
     * @Content:数据源
     * @Author 👻👻👻👻👻👻👻👻 gjh
     * @Date 2023-07-17 15:05
     * @Param
     * @return
     **/
    private String dataSourceCode;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCreate_user_id() {
        return create_user_id;
    }

    public void setCreate_user_id(String create_user_id) {
        this.create_user_id = create_user_id;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public Date getModify_time() {
        return modify_time;
    }

    public void setModify_time(Date modify_time) {
        this.modify_time = modify_time;
    }

    public String getModify_user_id() {
        return modify_user_id;
    }

    public void setModify_user_id(String modify_user_id) {
        this.modify_user_id = modify_user_id;
    }

    public String getOrg_id() {
        return org_id;
    }

    public void setOrg_id(String org_id) {
        this.org_id = org_id;
    }

    public String getSts() {
        return sts;
    }

    public void setSts(String sts) {
        this.sts = sts;
    }

    public Long getStart() {
        return start;
    }

    public void setStart(Long start) {
        this.start = start;
    }

    public Long getLimit() {
        return limit;
    }

    public void setLimit(Long limit) {
        this.limit = limit;
    }

    public Long getOffset() {
        return offset;
    }

    public void setOffset(Long offset) {
        this.offset = offset;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public String getDir() {
        return dir;
    }

    public void setDir(String dir) {
        this.dir = dir;
    }

    public Long getRows() {
        return rows;
    }

    public void setRows(Long rows) {
        this.rows = rows;
    }

    public Long getPage() {
        return page;
    }

    public void setPage(Long page) {
        this.page = page;
    }

    public String getDialect_type() {
        return dialect_type;
    }

    public void setDialect_type(String dialect_type) {
        this.dialect_type = dialect_type;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public String getDataSourceCode() {

        return dataSourceCode;
    }

    public void setDataSourceCode(String dataSourceCode) {
        this.dataSourceCode = dataSourceCode;
    }

    public BaseEntity() {
            this.dataSourceCode = "master";
    }

    public Long getSorts() {
        return sorts;
    }

    public void setSorts(Long sorts) {
        this.sorts = sorts;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public void setCreate() {
        this.setId(UUIDUtils.getUUID());
        this.setSts("Y");
        this.setCreate_user_id(StpUtil.getLoginIdAsString());
        this.setModify_user_id(StpUtil.getLoginIdAsString());
        this.setCreate_time(new Date());
        this.setModify_time(new Date());
        this.setOrg_id("0");
        this.setCompanyId("0");
    }
    //修改信息
    public void setUpdate() {
        this.setModify_user_id(StpUtil.getLoginIdAsString());
        this.setModify_time(new Date());
    }
}
