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

import com.apobates.forum.member.entity.MemberRoleEnum;
import com.apobates.forum.utils.lang.EnumArchitecture;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * 社区经理创建表单
 *
 * @author xiaofanku
 * @since 20200603
 */
public class MemberLeaderForm extends ActionForm {
    @NotBlank(message="{NotBlank.MemberLeaderForm.names}")
    @Size(min=5, max=20, message="{Size.MemberLeaderForm.names}")
    @Pattern(regexp = "^[A-Za-z0-9]+$", message="{Pattern.MemberLeaderForm.names}")
    private String names;
    @NotBlank(message="{NotBlank.MemberLeaderForm.nickname}")
    private String nickname;
    @NotBlank(message="{NotBlank.MemberLeaderForm.pswd}")
    @Size(min=6, max=100, message="{Size.MemberLeaderForm.pswd}")
    private String pswd;
    // enum
    @NotBlank(message="{NotBlank.MemberLeaderForm.role}")
    private String role;
    
    public String getNames() {
        return names;
    }
    
    public void setNames(String names) {
        this.names = names;
    }
    
    public String getNickname() {
        return nickname;
    }
    
    public void setNickname(String nickname) {
        this.nickname = nickname;
    }
    
    public String getPswd() {
        return pswd;
    }
    
    public void setPswd(String newPswd) {
        this.pswd = newPswd;
    }
    
    public MemberRoleEnum getEnumRole() {
        int roleEnumSymbol = covertStringToInteger(getRole(), 0);
        return EnumArchitecture.getInstance(roleEnumSymbol, MemberRoleEnum.class).orElse(MemberRoleEnum.NO);
    }
    
    public String getRole() {
        return role;
    }
    
    public void setRole(String role) {
        this.role = role;
    }
}