package com.enterprise.manage.common.base;

import com.enterprise.manage.common.tools.secure.SecurityUtil;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Base Domain (基础实体类)
 *
 * @author PeiZhi Guo
 * 2021-2-18 10:54
 */
public class BaseDomain implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long createBy;

    private Long updateBy;

    private String updateName;

    private String createName;

    private Date createTime;

    private Date updateTime;

    private String remark;

    private Map<String, Object> params;

    // set default insert params method
    public void insertConfigure() {
        Long userId = SecurityUtil.getCurrentUser().getId();
        this.createBy = userId;
        this.updateBy = userId;
        this.createTime = new Date();
        this.updateTime = new Date();
    }

    // set default update params method
    public void updateConfigure() {
        this.updateBy = SecurityUtil.getCurrentUser().getId();
        this.updateTime = new Date();
    }

    public Long getCreateBy() {
        return createBy;
    }

    public void setCreateBy(Long createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(Long updateBy) {
        this.updateBy = updateBy;
    }

    public String getUpdateName() {
        return updateName;
    }

    public void setUpdateName(String updateName) {
        this.updateName = updateName;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params)
    {
        this.params = params;
    }
}
