package com.face.global.vo;


import com.face.global.enums.OperateType;
import com.face.global.enums.UserTypeEnum;
import lombok.Data;

import java.util.Date;
import java.util.Map;

@Data
public class Operate {

    /**
     * 主表id
     */
    private String mainId;

    /**
     * id
     */
    private String id;

    /**
     * 历史序列
     */
    private long seqno;

    /**
     * 操作状态（1-新增，2-修改，3-删除）
     */
    private String operateType;

    /**
     * 最后操作人
     */
    private String modifyUser;

    /**
     * 最后操作时间
     */
    private Date modifyDate;


    private String modifyUserType;

    private boolean generateId;

    private Map<String, Object> extendsData;

    public Operate() {
        this.modifyDate = new Date();
        this.generateId = true;
    }

    public Operate extendsData(Map<String, Object> extendsData) {
        this.extendsData = extendsData;
        return this;
    }

    public static Operate inst() {
        return new Operate();
    }

    public Operate seqno(long seqno) {
        this.seqno = seqno;
        return this;
    }

    public Operate mainId(String mainId) {
        this.mainId = mainId;
        return this;
    }

    public Operate id(String id) {
        this.id = id;
        return this;
    }

    public Operate generateId(boolean generateId) {
        this.generateId = generateId;
        return this;
    }

    public Operate insert() {
        this.operateType = OperateType.ADD.getOperateType();
        return this;
    }

    public Operate update() {
        this.operateType = OperateType.UPDATE.getOperateType();
        return this;
    }

    public Operate customerType() {
        this.modifyUserType = UserTypeEnum.CUSTOMER.getCode();
        return this;
    }


    public Operate sysUserType() {
        this.modifyUserType = UserTypeEnum.SYS_USER.getCode();
        return this;
    }

    public Operate modifyUserType(String modifyUserType) {
        this.modifyUserType = modifyUserType;
        return this;
    }

    public Operate delete() {
        this.operateType = OperateType.DELETE.getOperateType();
        return this;
    }

    public Operate modifyUser(String user) {
        this.modifyUser = user;
        return this;
    }

    public Operate operateType(String operateType) {
        this.operateType = operateType;
        return this;
    }
}
