package com.yh.saas.plugin.operation.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.yh.saas.common.support.entity.BaseModel;
import com.yh.saas.common.support.util.query.SearchField;
import com.yh.saas.common.support.util.query.SearchMode;
import com.yh.saas.common.support.util.uniqueness.Unique;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * <p>
 * 'winsea_platform.certificate_view' is not BASE TABLE
 * </p>
 *
 * @author zhangb
 * @since 2019-06-10
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class CommonOperator extends BaseModel<CommonOperator> {

    private static final long serialVersionUID = 1L;
    /**
     * 主键ID
     */
    @TableId(type = IdType.INPUT)
    private String operatorId;
    /**
     * 账户名
     */
    @Unique(value = "OPERATION-002", otherConflictColums = "operator_mobile_phone")
    @NotBlank
    private String operatorName;
    /**
     * 手机号
     */
    @Unique(value = "OPERATION-003", otherConflictColums = "operator_name")
    @NotBlank
    private String operatorMobilePhone;
    /**
     * 部门
     */
    private String departmentName;
    /**
     * 角色
     */
    private String positionName;
    /**
     * 登录密码
     */
    @TableField(exist = false)
    @NotBlank
    private String loginPassword;
    /**
     * 启用/禁用
     */
    @SearchField(mode = SearchMode.EQ)
    private Integer enabled;

    /**
     * 搜索关键字
     */
    @TableField(exist = false)
    private String keyword;

    /**
     * 查询用字段
     */
    public static class QueryFields {

        public static final String OPERATOR_NAME = "operator_name";

        public static final String OPERATOR_MOBILE_PHONE = "operator_mobile_phone";

        public static final String OPERATOR_ID = "operator_id";

        private QueryFields() {
        }
    }

    @Override
    protected Serializable pkVal() {
        return this.operatorId;
    }

}
