package me.chyxion.tigon.model;

import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import me.chyxion.tigon.mybatis.NotUpdate;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * Oct 17, 2015 2:09:08 PM
 */
@Getter
@Setter
public class M1<Id> extends M0<Id> {

    private static final long serialVersionUID = 1L;

    public static final String DATE_CREATED = "date_created";
    public static final String DATE_UPDATED = "date_updated";

    @NotUpdate
    protected Date dateCreated;
    protected Date dateUpdated;

    /**
     * init date created
     */
    @Override
    public void beforeInsert() {
        super.beforeInsert();
        if (dateCreated == null) {
            dateCreated = new Date();
        }
    }

    /**
     * update date updated
     */
    @Override
    public void beforeUpdate() {
        super.beforeUpdate();
        dateUpdated = new Date();
    }
}
