package api.common.pojo.po.project;

import api.common.util.StringUtil;
import api.common.util.TimeUtil;
import lombok.Getter;
import lombok.Setter;

import java.sql.Timestamp;

/**
 * 数据表公共字段
 */
@Getter
@Setter
public class BasePO {

    //id
    private String id;

    //创建时间
    private Timestamp createTime;

    //创建人
    private String createUserId;

    //修改时间
    private Timestamp modifyTime;

    //修改人
    private String modifyUserId;

    //是否删除
    private String isDeleted;

    public void createPo(String userId){
        id = createId();
        Timestamp nowForMysql = TimeUtil.getNowForMysql();
        createTime = nowForMysql;
        modifyTime = nowForMysql;
        isDeleted = "0";
        createUserId = userId;
        modifyUserId = userId;
    }

    public void updatePo(String userId){
        modifyTime = TimeUtil.getNowForMysql();
        modifyUserId = userId;
    }

    private String createId(){
        return StringUtil.getRandomUUID();
    }

}
