com.soento.core.lang.BaseEntity Maven / Gradle / Ivy
package com.soento.core.lang;
import com.soento.core.util.StringUtil;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
/**
* @author yantao.zeng
*/
@SuppressFBWarnings("EI_EXPOSE_REP")
public abstract class BaseEntity extends BaseObject {
protected String id;
protected String createBy;
protected Date createDate;
protected String modifyBy;
protected Date modifyDate;
protected Integer deleteFlag;
public void init(String userId) {
this.createBy = userId;
this.modifyBy = userId;
this.createDate = new Date();
this.modifyDate = new Date();
this.deleteFlag = 0;
}
public void init() {
this.init("SYSTEM");
}
public void init(LoginUser user) {
if (user != null && StringUtil.isNotBlank(user.getUserId())) {
init(user.getUserId());
} else {
init();
}
}
public void update(String userId) {
this.modifyBy = userId;
this.modifyDate = new Date();
}
public void update() {
this.update("SYSTEM");
}
public void update(LoginUser user) {
if (user != null && StringUtil.isNotBlank(user.getUserId())) {
update(user.getUserId());
} 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;
}
}