package ink.wgink.gateway.handler;

import ink.wgink.gateway.pojo.BasePOJO;
import ink.wgink.gateway.util.DateUtil;
import ink.wgink.gateway.util.UUIDUtil;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: BaseHandler
 * @Description:
 * @Author: WangGeng
 * @Date: 2021/4/19 21:57
 * @Version: 1.0
 **/
public class BaseHandler {

    public static final String CREATOR = "creator";
    public static final String MODIFIER = "modifier";
    public static final String GMT_CREATE = "gmtCreate";
    public static final String GMT_MODIFIED = "gmtModified";

    protected void setSave(BasePOJO base) {
        String datetime = DateUtil.getTime();
        base.setUuid(UUIDUtil.getUUID());
        base.setCreator("1");
        base.setGmtCreate(datetime);
        base.setModifier("1");
        base.setGmtModified(datetime);
    }

    protected void setUpdate(BasePOJO base) {
        base.setGmtCreate(DateUtil.getTime());
        base.setModifier("1");
    }

    protected int getLimit(int size) {
        return size;
    }

    protected long getSkip(int page, int size) {
        return (page - 1) * size;
    }

}
