package admin

import "time"

// Admin [...]
type Admin struct {
	AdminID                 int64     `gorm:"primaryKey;column:admin_id;type:bigint(20);not null" json:"adminId"`
	AdminName               string    `gorm:"uniqueIndex:un;index:name;index:admin_pass;column:admin_name;type:varchar(60);not null" json:"adminName"`
	AdminAvatar             string    `gorm:"column:admin_avatar;type:varchar(255)" json:"adminAvatar"`
	RealName                string    `gorm:"column:real_name;type:varchar(60)" json:"realName"`
	Password                string    `gorm:"index:password;index:admin_pass;column:password;type:varchar(60);not null" json:"password"`
	LastUpdatedPasswordTime time.Time `gorm:"column:last_updated_password_time;type:datetime" json:"lastUpdatedPasswordTime"`
	Enabled                 int8      `gorm:"uniqueIndex:un;column:enabled;type:tinyint(1);not null;default:1" json:"enabled"` // 1:有效，0:禁用
	Email                   string    `gorm:"column:email;type:varchar(60)" json:"email"`
	LastLoginTime           time.Time `gorm:"column:last_login_time;type:datetime" json:"lastLoginTime"`                                         // 最近登陆时间
	CreatedTime             time.Time `gorm:"index:created_time;column:created_time;type:datetime;default:CURRENT_TIMESTAMP" json:"createdTime"` // 创建时间
	LastUpdatedTime         time.Time `gorm:"index:last_updated_time;column:last_updated_time;type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"lastUpdatedTime"`
	Role                    string    `gorm:"column:role;type:varchar(30);default:saller" json:"role"`               // 用户角色
	Mobile                  string    `gorm:"column:mobile;type:varchar(20)" json:"mobile"`                          // 手机号
	RoleType                int8      `gorm:"column:role_type;type:tinyint(4);default:0" json:"roleType"`            // 角色类型:1需要录入指标,0:不需要
	RoleID                  int       `gorm:"column:role_id;type:int(11);default:0" json:"roleId"`                   // 角色id
	RoleName                string    `gorm:"column:role_name;type:varchar(100)" json:"roleName"`                    // 角色名称
	RoleTypeCode            string    `gorm:"column:role_type_code;type:varchar(20);default:''" json:"roleTypeCode"` // 角色编码
	DepartmentID            int       `gorm:"column:department_id;type:int(11);default:0" json:"departmentId"`       // 部门id
	DepartmentName          string    `gorm:"column:department_name;type:varchar(100)" json:"departmentName"`        // 部门名称
	GroupID                 int       `gorm:"column:group_id;type:int(11);default:0" json:"groupId"`                 // 分组id
	GroupName               string    `gorm:"column:group_name;type:varchar(100)" json:"groupName"`                  // 分组名称
	Authority               int8      `gorm:"column:authority;type:tinyint(4);default:0" json:"authority"`           // 管理权限，0：无，1：部门负责人，2：小组负责人,3:超级管理员
	Position                string    `gorm:"column:position;type:varchar(100)" json:"position"`                     // 职位
	OpenId                  string    `gorm:"column:open_id;type:varchar(100)" json:"open_id"`                       // 弘则部门openid
}

// TableName get sql table name.获取数据库表名
func (m *Admin) TableName() string {
	return "admin"
}

// AdminColumns get sql column name.获取数据库列名
var AdminColumns = struct {
	AdminID                 string
	AdminName               string
	RealName                string
	Password                string
	LastUpdatedPasswordTime string
	Enabled                 string
	Email                   string
	LastLoginTime           string
	CreatedTime             string
	LastUpdatedTime         string
	Role                    string
	Mobile                  string
	RoleType                string
	RoleID                  string
	RoleName                string
	RoleTypeCode            string
	DepartmentID            string
	DepartmentName          string
	GroupID                 string
	GroupName               string
	Authority               string
	Position                string
}{
	AdminID:                 "admin_id",
	AdminName:               "admin_name",
	RealName:                "real_name",
	Password:                "password",
	LastUpdatedPasswordTime: "last_updated_password_time",
	Enabled:                 "enabled",
	Email:                   "email",
	LastLoginTime:           "last_login_time",
	CreatedTime:             "created_time",
	LastUpdatedTime:         "last_updated_time",
	Role:                    "role",
	Mobile:                  "mobile",
	RoleType:                "role_type",
	RoleID:                  "role_id",
	RoleName:                "role_name",
	RoleTypeCode:            "role_type_code",
	DepartmentID:            "department_id",
	DepartmentName:          "department_name",
	GroupID:                 "group_id",
	GroupName:               "group_name",
	Authority:               "authority",
	Position:                "position",
}
