package com.apobates.forum.thrones.admin.controller.form;

import com.apobates.forum.member.entity.ForumCalendarUnitEnum;
import com.apobates.forum.utils.lang.EnumArchitecture;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
/**
 *
 * @author xiaofanku
 * @since 20200921
 */
public class MemberExchangeForm extends ActionForm{
    private long memberId;
    @NotBlank(message="{NotBlank.MemberExchangeForm.names}")
    private String names;
    @NotBlank(message="{NotBlank.MemberExchangeForm.limit}")
    @Size(min=1, max=20, message="{Size.MemberExchangeForm.limit}")
    private String limit;
    //单位:天
    @NotBlank(message="{NotBlank.MemberExchangeForm.unit}")
    @Positive(message="{Positive.MemberExchangeForm.unit}")
    private String unit;
    @NotBlank(message="{NotBlank.MemberExchangeForm.serial}")
    private String serial;

    public long getMemberId() {
        return memberId;
    }

    public void setMemberId(long memberId) {
        this.memberId = memberId;
    }

    public String getNames() {
        return names;
    }

    public void setNames(String names) {
        this.names = names;
    }

    public String getLimit() {
        return limit;
    }

    public void setLimit(String limit) {
        this.limit = limit;
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getSerial() {
        return serial;
    }

    public void setSerial(String serial) {
        this.serial = serial;
    }

    public int getIntegerLimit() {
        return covertStringToInteger(getLimit(), 1);
    }

    public ForumCalendarUnitEnum getEnumUnit() {
        int unitEnumSymbol = covertStringToInteger(getUnit(), 0);
        return EnumArchitecture.getInstance(unitEnumSymbol, ForumCalendarUnitEnum.class).orElse(ForumCalendarUnitEnum.MONTH);
    }
}
