package cn.pluss.platform.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 用户变更下级等级数据表
 * </p>
 *
 * @author Djh
 * @since 2022-02-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@Accessors(chain = true)
@TableName("tb_pluss_extra_level_benefit")
public class ExtraLevelBenefit implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    private Integer id;


    /**
     * 用户id
     */
    @TableField("userId")
    private Integer userId;


    /**
     * 最大可使用个数
     */
    @TableField("maxCount")
    private Integer maxCount;


    /**
     * 已使用个数
     */
    @TableField("useCount")
    private Integer useCount;

    public Integer getUseCount() {
        if (useCount == null) {
            return 0;
        }

        return useCount;
    }

    /**
     * 创建时间
     */
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 创建时间 开始时间
     */
    @TableField(exist = false, condition = "createTime &gt; #{%s}")
    private Date createTimeStart;

    /**
     * 创建时间 截止时间
     */
    @TableField(exist = false, condition = "createTime &lt; #{%s}")
    private Date createTimeEnd;

    /**
     * 更新时间
     */
    @TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    /**
     * 更新时间 开始时间
     */
    @TableField(exist = false, condition = "updateTime &gt; #{%s}")
    private Date updateTimeStart;

    /**
     * 更新时间 截止时间
     */
    @TableField(exist = false, condition = "updateTime &lt; #{%s}")
    private Date updateTimeEnd;

    public ExtraLevelBenefit(Integer userId, Integer maxCount, Integer useCount) {
        this.userId = userId;
        this.maxCount = maxCount;
        this.useCount = useCount;
    }

    public ExtraLevelBenefit(Integer userId, Integer maxCount) {
        this.userId = userId;
        this.maxCount = maxCount;
    }
}