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

import com.apobates.forum.member.entity.ForumCalendarUnitEnum;
import com.apobates.forum.member.entity.MemberStatusEnum;
import com.apobates.forum.utils.lang.EnumArchitecture;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;

/**
 *
 * @author xiaofanku
 * @since 20200603
 */
public class MemberPenalizeForm extends ActionForm {
    private long memberId;
    @NotBlank(message="{NotBlank.MemberPenalizeForm.names}")
    private String names;
    //MemberStatusEnum.symbol
    //惩罚:禁足
    @NotBlank(message="{NotBlank.MemberPenalizeForm.arrive}")
    @Min(value=0, message="{Min.MemberPenalizeForm.arrive}")
    @Max(value=4, message="{Max.MemberPenalizeForm.arrive}")
    private String arrive;
    //开始日期
    //private String date;
    //时长:1
    @NotBlank(message="{NotBlank.MemberPenalizeForm.limit}")
    @Size(min=1, max=20, message="{Size.MemberPenalizeForm.limit}")
    private String limit;
    //单位:天
    @NotBlank(message="{NotBlank.MemberPenalizeForm.unit}")
    @Positive(message="{Positive.MemberPenalizeForm.unit}")
    private String unit;
    //理由
    @NotBlank(message="{NotBlank.MemberPenalizeForm.reason}")
    private String reason;
    //证据
    @NotBlank(message="{NotBlank.MemberPenalizeForm.evidences}")
    private String evidences;
    
    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 MemberStatusEnum getEnumArrive() {
        int arriveEnumSymbol = covertStringToInteger(getArrive(), -1);
        return EnumArchitecture.getInstance(arriveEnumSymbol, MemberStatusEnum.class).orElse(MemberStatusEnum.DELETE);
    }
    
    public String getArrive() {
        return arrive;
    }
    
    public void setArrive(String arrive) {
        this.arrive = arrive;
    }
    
    public int getIntegerLimit() {
        return covertStringToInteger(getLimit(), 1);
    }
    
    public String getLimit() {
        return limit;
    }
    
    public void setLimit(String limit) {
        this.limit = limit;
    }
    
    public ForumCalendarUnitEnum getEnumUnit() {
        int unitEnumSymbol = covertStringToInteger(getUnit(), 0);
        return EnumArchitecture.getInstance(unitEnumSymbol, ForumCalendarUnitEnum.class).orElse(ForumCalendarUnitEnum.DAY);
    }
    
    public String getUnit() {
        return unit;
    }
    
    public void setUnit(String unit) {
        this.unit = unit;
    }
    
    public String getReason() {
        return reason;
    }
    
    public void setReason(String reason) {
        this.reason = reason;
    }
    
    public String getEvidences() {
        return evidences;
    }
    
    public void setEvidences(String evidences) {
        this.evidences = evidences;
    }
}