package com.xmomen.module.user.entity;

import com.xmomen.framework.mybatis.model.BaseMybatisModel;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "sys_roles")
public class SysRoles extends BaseMybatisModel {
    /**
     * 物理主键
     */
    private Integer id;

    /**
     * 角色
     */
    private String role;

    /**
     * 角色描述
     */
    private String description;

    /**
     * 是否启用：0-禁用，1-启用
     */
    private Integer available;

    // 定义ID字段
    @Column(name = "ID")
    // 设置ID为主键
    @Id
    // 设置ID的生成方式为UUID
    @GeneratedValue(generator = "UUIDGenerator")
    public Integer getId() {
        // 返回ID
        return id;
    }

    // 设置ID
    public void setId(Integer id) {
        // 将传入的ID赋值给成员变量
        this.id = id;
        // 如果ID为空
        if(id == null){
              // 移除验证字段
              removeValidField("id");
              // 返回
              return;
        }
        addValidField("id");
    }

    // 获取角色
    @Column(name = "ROLE")
    public String getRole() {
        return role;
    }

    // 设置角色
    public void setRole(String role) {
        this.role = role;
        // 如果角色为空，则移除验证字段
        if(role == null){
              removeValidField("role");
              return;
        }
        addValidField("role");
    }

    // 获取描述
    @Column(name = "DESCRIPTION")
    public String getDescription() {
        return description;
    }

    // 设置描述
    public void setDescription(String description) {
        this.description = description;
        if(description == null){
              removeValidField("description");
    // 如果available为null，则移除"available"字段
    if(available == null){
        removeValidField("available");
              return;
        }
        addValidField("description");
    }

    @Column(name = "AVAILABLE")
    public Integer getAvailable() {
        return available;
    }

    public void setAvailable(Integer available) {
        this.available = available;
        if(available == null){
              removeValidField("available");
              return;
        }
        // 添加一个名为"available"的有效字段
        addValidField("available");
    }
}