github.com/SupenBysz/gf-admin-community@v0.7.4/sys_model/sys_dao/internal/sys_user_detail.go (about) 1 // ========================================================================== 2 // Code generated by GoFrame CLI tool. DO NOT EDIT. 3 // ========================================================================== 4 5 package internal 6 7 import ( 8 "context" 9 10 "github.com/kysion/base-library/utility/daoctl" 11 "github.com/kysion/base-library/utility/daoctl/dao_interface" 12 13 "github.com/gogf/gf/v2/database/gdb" 14 "github.com/gogf/gf/v2/frame/g" 15 ) 16 17 // SysUserDetailDao is the data access object for table sys_user_detail. 18 type SysUserDetailDao struct { 19 table string // table is the underlying table name of the DAO. 20 group string // group is the database configuration group name of current DAO. 21 columns SysUserDetailColumns // columns contains all the column names of Table for convenient usage. 22 } 23 24 // SysUserDetailColumns defines and stores column names for table sys_user_detail. 25 type SysUserDetailColumns struct { 26 Id string // ID,保持与USERID一致 27 Realname string // 姓名 28 UnionMainName string // 关联主体名称 29 LastLoginIp string // 最后登录IP 30 LastLoginArea string // 最后登录地区 31 LastLoginAt string // 最后登录时间 32 } 33 34 // sysUserDetailColumns holds the columns for table sys_user_detail. 35 var sysUserDetailColumns = SysUserDetailColumns{ 36 Id: "id", 37 Realname: "realname", 38 UnionMainName: "union_main_name", 39 LastLoginIp: "last_login_ip", 40 LastLoginArea: "last_login_area", 41 LastLoginAt: "last_login_at", 42 } 43 44 // NewSysUserDetailDao creates and returns a new DAO object for table data access. 45 func NewSysUserDetailDao(proxy ...dao_interface.IDao) *SysUserDetailDao { 46 var dao *SysUserDetailDao 47 if len(proxy) > 0 { 48 dao = &SysUserDetailDao{ 49 group: proxy[0].Group(), 50 table: proxy[0].Table(), 51 columns: sysUserDetailColumns, 52 } 53 return dao 54 } 55 56 return &SysUserDetailDao{ 57 group: "default", 58 table: "sys_user_detail", 59 columns: sysUserDetailColumns, 60 } 61 } 62 63 // DB retrieves and returns the underlying raw database management object of current DAO. 64 func (dao *SysUserDetailDao) DB() gdb.DB { 65 return g.DB(dao.group) 66 } 67 68 // Table returns the table name of current dao. 69 func (dao *SysUserDetailDao) Table() string { 70 return dao.table 71 } 72 73 // Group returns the configuration group name of database of current dao. 74 func (dao *SysUserDetailDao) Group() string { 75 return dao.group 76 } 77 78 // Columns returns all column names of current dao. 79 func (dao *SysUserDetailDao) Columns() SysUserDetailColumns { 80 return dao.columns 81 } 82 83 // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. 84 func (dao *SysUserDetailDao) Ctx(ctx context.Context, cacheOption ...*gdb.CacheOption) *gdb.Model { 85 return dao.DaoConfig(ctx, cacheOption...).Model 86 } 87 88 func (dao *SysUserDetailDao) DaoConfig(ctx context.Context, cacheOption ...*gdb.CacheOption) dao_interface.DaoConfig { 89 daoConfig := dao_interface.DaoConfig{ 90 Dao: dao, 91 DB: dao.DB(), 92 Table: dao.table, 93 Group: dao.group, 94 Model: dao.DB().Model(dao.Table()).Safe().Ctx(ctx), 95 } 96 97 if len(cacheOption) == 0 { 98 daoConfig.CacheOption = daoctl.MakeDaoCache(dao.Table()) 99 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 100 } else { 101 if cacheOption[0] != nil { 102 daoConfig.CacheOption = cacheOption[0] 103 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 104 } 105 } 106 107 daoConfig.Model = daoctl.RegisterDaoHook(daoConfig.Model) 108 109 return daoConfig 110 } 111 112 // Transaction wraps the transaction logic using function f. 113 // It rollbacks the transaction and returns the error from function f if it returns non-nil error. 114 // It commits the transaction and returns nil if function f returns nil. 115 // 116 // Note that, you should not Commit or Rollback the transaction in function f 117 // as it is automatically handled by this function. 118 func (dao *SysUserDetailDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { 119 return dao.Ctx(ctx).Transaction(ctx, f) 120 }