/*
 * This file is generated by jOOQ.
 */
package jj.tech.paolu.repository.jooq.tables;


import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

import jj.tech.paolu.repository.jooq.Keys;
import jj.tech.paolu.repository.jooq.Yx;
import jj.tech.paolu.repository.jooq.tables.records.SysAdminRecord;

import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Function7;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Records;
import org.jooq.Row7;
import org.jooq.Schema;
import org.jooq.SelectField;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes", "this-escape" })
public class SysAdmin extends TableImpl<SysAdminRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>yx.sys_admin</code>
     */
    public static final SysAdmin SYS_ADMIN = new SysAdmin();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<SysAdminRecord> getRecordType() {
        return SysAdminRecord.class;
    }

    /**
     * The column <code>yx.sys_admin.id</code>.
     */
    public final TableField<SysAdminRecord, String> ID = createField(DSL.name("id"), SQLDataType.VARCHAR(20).nullable(false), this, "");

    /**
     * The column <code>yx.sys_admin.org_id</code>.
     */
    public final TableField<SysAdminRecord, String> ORG_ID = createField(DSL.name("org_id"), SQLDataType.VARCHAR(20).defaultValue(DSL.field(DSL.raw("NULL"), SQLDataType.VARCHAR)), this, "");

    /**
     * The column <code>yx.sys_admin.type</code>. 0管理员,1普通用户
     */
    public final TableField<SysAdminRecord, Integer> TYPE = createField(DSL.name("type"), SQLDataType.INTEGER.defaultValue(DSL.field(DSL.raw("0"), SQLDataType.INTEGER)), this, "0管理员,1普通用户");

    /**
     * The column <code>yx.sys_admin.realname</code>.
     */
    public final TableField<SysAdminRecord, String> REALNAME = createField(DSL.name("realname"), SQLDataType.VARCHAR(100).nullable(false), this, "");

    /**
     * The column <code>yx.sys_admin.username</code>.
     */
    public final TableField<SysAdminRecord, String> USERNAME = createField(DSL.name("username"), SQLDataType.VARCHAR(100).nullable(false), this, "");

    /**
     * The column <code>yx.sys_admin.password</code>. sha3_256hex
     */
    public final TableField<SysAdminRecord, String> PASSWORD = createField(DSL.name("password"), SQLDataType.VARCHAR(100).nullable(false), this, "sha3_256hex");

    /**
     * The column <code>yx.sys_admin.islock</code>. 0正常,1锁定
     */
    public final TableField<SysAdminRecord, Integer> ISLOCK = createField(DSL.name("islock"), SQLDataType.INTEGER.defaultValue(DSL.field(DSL.raw("0"), SQLDataType.INTEGER)), this, "0正常,1锁定");

    private SysAdmin(Name alias, Table<SysAdminRecord> aliased) {
        this(alias, aliased, null);
    }

    private SysAdmin(Name alias, Table<SysAdminRecord> aliased, Field<?>[] parameters) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.table());
    }

    /**
     * Create an aliased <code>yx.sys_admin</code> table reference
     */
    public SysAdmin(String alias) {
        this(DSL.name(alias), SYS_ADMIN);
    }

    /**
     * Create an aliased <code>yx.sys_admin</code> table reference
     */
    public SysAdmin(Name alias) {
        this(alias, SYS_ADMIN);
    }

    /**
     * Create a <code>yx.sys_admin</code> table reference
     */
    public SysAdmin() {
        this(DSL.name("sys_admin"), null);
    }

    public <O extends Record> SysAdmin(Table<O> child, ForeignKey<O, SysAdminRecord> key) {
        super(child, key, SYS_ADMIN);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : Yx.YX;
    }

    @Override
    public UniqueKey<SysAdminRecord> getPrimaryKey() {
        return Keys.KEY_SYS_ADMIN_PRIMARY;
    }

    @Override
    public List<UniqueKey<SysAdminRecord>> getUniqueKeys() {
        return Arrays.asList(Keys.KEY_SYS_ADMIN_USERNAME);
    }

    @Override
    public SysAdmin as(String alias) {
        return new SysAdmin(DSL.name(alias), this);
    }

    @Override
    public SysAdmin as(Name alias) {
        return new SysAdmin(alias, this);
    }

    @Override
    public SysAdmin as(Table<?> alias) {
        return new SysAdmin(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public SysAdmin rename(String name) {
        return new SysAdmin(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public SysAdmin rename(Name name) {
        return new SysAdmin(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public SysAdmin rename(Table<?> name) {
        return new SysAdmin(name.getQualifiedName(), null);
    }

    // -------------------------------------------------------------------------
    // Row7 type methods
    // -------------------------------------------------------------------------

    @Override
    public Row7<String, String, Integer, String, String, String, Integer> fieldsRow() {
        return (Row7) super.fieldsRow();
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Function)}.
     */
    public <U> SelectField<U> mapping(Function7<? super String, ? super String, ? super Integer, ? super String, ? super String, ? super String, ? super Integer, ? extends U> from) {
        return convertFrom(Records.mapping(from));
    }

    /**
     * Convenience mapping calling {@link SelectField#convertFrom(Class,
     * Function)}.
     */
    public <U> SelectField<U> mapping(Class<U> toType, Function7<? super String, ? super String, ? super Integer, ? super String, ? super String, ? super String, ? super Integer, ? extends U> from) {
        return convertFrom(toType, Records.mapping(from));
    }
}
