// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================

package internal

import (
	"context"
	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/frame/g"
)

// AdminMemberDao is the data access object for table hg_admin_member.
type AdminMemberDao struct {
	table   string             // table is the underlying table name of the DAO.
	group   string             // group is the database configuration group name of current DAO.
	columns AdminMemberColumns // columns contains all the column names of Table for convenient usage.
}

// AdminMemberColumns defines and stores column names for table hg_admin_member.
type AdminMemberColumns struct {
	Id                 string //
	DeptId             string // 部门ID
	Username           string // 帐号
	PasswordHash       string // 密码
	Salt               string // 密码盐
	AuthKey            string // 授权令牌
	PasswordResetToken string // 密码重置令牌
	Type               string // 1:普通管理员;10超级管理员
	Realname           string // 真实姓名
	Avatar             string // 头像
	Sex                string // 性别[0:未知;1:男;2:女]
	Qq                 string // qq
	Email              string // 邮箱
	Birthday           string // 生日
	ProvinceId         string // 省
	CityId             string // 城市
	AreaId             string // 地区
	Address            string // 默认地址
	Mobile             string // 手机号码
	HomePhone          string // 家庭号码
	DingtalkRobotToken string // 钉钉机器人token
	VisitCount         string // 访问次数
	LastTime           string // 最后一次登录时间
	LastIp             string // 最后一次登录ip
	Role               string // 权限
	Remark             string // 备注
	Status             string // 状态
	CreatedAt          string // 创建时间
	UpdatedAt          string // 修改时间
}

//  adminMemberColumns holds the columns for table hg_admin_member.
var adminMemberColumns = AdminMemberColumns{
	Id:                 "id",
	DeptId:             "dept_id",
	Username:           "username",
	PasswordHash:       "password_hash",
	Salt:               "salt",
	AuthKey:            "auth_key",
	PasswordResetToken: "password_reset_token",
	Type:               "type",
	Realname:           "realname",
	Avatar:             "avatar",
	Sex:                "sex",
	Qq:                 "qq",
	Email:              "email",
	Birthday:           "birthday",
	ProvinceId:         "province_id",
	CityId:             "city_id",
	AreaId:             "area_id",
	Address:            "address",
	Mobile:             "mobile",
	HomePhone:          "home_phone",
	DingtalkRobotToken: "dingtalk_robot_token",
	VisitCount:         "visit_count",
	LastTime:           "last_time",
	LastIp:             "last_ip",
	Role:               "role",
	Remark:             "remark",
	Status:             "status",
	CreatedAt:          "created_at",
	UpdatedAt:          "updated_at",
}

// NewAdminMemberDao creates and returns a new DAO object for table data access.
func NewAdminMemberDao() *AdminMemberDao {
	return &AdminMemberDao{
		group:   "default",
		table:   "hg_admin_member",
		columns: adminMemberColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *AdminMemberDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of current dao.
func (dao *AdminMemberDao) Table() string {
	return dao.table
}

// Columns returns all column names of current dao.
func (dao *AdminMemberDao) Columns() AdminMemberColumns {
	return dao.columns
}

// Group returns the configuration group name of database of current dao.
func (dao *AdminMemberDao) Group() string {
	return dao.group
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *AdminMemberDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *AdminMemberDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
