12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- // ==========================================================================
- // Code generated by GoFrame CLI tool. DO NOT EDIT.
- // ==========================================================================
- package internal
- import (
- "context"
- "github.com/gogf/gf/database/gdb"
- "github.com/gogf/gf/frame/g"
- )
- // UserDao is the manager for logic model data accessing and custom defined data operations functions management.
- type UserDao 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 UserColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
- }
- // UserColumns defines and stores column names for table user.
- type UserColumns struct {
- Id string // 用户表id
- User string // 账号
- Username string // 后台用户名
- Password string // 用户密码
- RealName string // 真实姓名
- Role string // 角色 1,超级管理员; 2,管理员;3,企业用户
- Phone string // 绑定手机
- Email string // 电子邮件
- LastLoginTime string // 最后一次登录时间
- UserState string // 0,禁用,1,正常
- CreatedAt string // 创建时间
- UpdatedAt string // 更新时间
- }
- // userColumns holds the columns for table user.
- var userColumns = UserColumns{
- Id: "id",
- User: "user",
- Username: "username",
- Password: "password",
- RealName: "real_name",
- Role: "role",
- Phone: "phone",
- Email: "email",
- LastLoginTime: "last_login_time",
- UserState: "user_state",
- CreatedAt: "created_at",
- UpdatedAt: "updated_at",
- }
- // NewUserDao creates and returns a new DAO object for table data access.
- func NewUserDao() *UserDao {
- return &UserDao{
- Group: "default",
- Table: "user",
- Columns: userColumns,
- }
- }
- // DB retrieves and returns the underlying raw database management object of current DAO.
- func (dao *UserDao) DB() gdb.DB {
- return g.DB(dao.Group)
- }
- // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
- func (dao *UserDao) 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 *UserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
- return dao.Ctx(ctx).Transaction(ctx, f)
- }
|