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

com.soento.core.lang.BaseEntity Maven / Gradle / Ivy

package com.soento.core.lang;

import com.soento.core.consts.Constants;
import com.soento.core.enums.DeleteFlag;
import com.soento.core.util.StringUtil;

import java.util.Date;

/**
 * @author yantao.zeng
 */
public abstract class BaseEntity extends BaseObject {
    private static final long serialVersionUID = -7612585927709984362L;
    private String id;
    private String createBy;
    private Date createDate;
    private String modifyBy;
    private Date modifyDate;
    private Integer deleteFlag;

    public void init(String userId) {
        this.createBy = userId;
        this.modifyBy = userId;
        this.createDate = new Date();
        this.modifyDate = new Date();
        this.deleteFlag = DeleteFlag.NOT_DELETED.getValue();
    }

    public void init() {
        this.init(Constants.SYSTEM);
    }

    public void init(LoginUser user) {
        if (user != null && StringUtil.isNotBlank(user.getId())) {
            init(user.getId());
        } else {
            init();
        }
    }

    public void update(String userId) {
        this.modifyBy = userId;
        this.modifyDate = new Date();
    }

    public void update() {
        this.update(Constants.SYSTEM);
    }

    public void update(LoginUser user) {
        if (user != null && StringUtil.isNotBlank(user.getId())) {
            update(user.getId());
        } else {
            update();
        }
    }

    public String getId() {
        return id;
    }

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

    public String getCreateBy() {
        return createBy;
    }

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

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public String getModifyBy() {
        return modifyBy;
    }

    public void setModifyBy(String modifyBy) {
        this.modifyBy = modifyBy;
    }

    public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy