github.com/SupenBysz/gf-admin-community@v0.7.4/sys_model/sys_dao/internal/sys_sms_logs.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 // SysSmsLogsDao is the data access object for table sys_sms_logs. 18 type SysSmsLogsDao 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 SysSmsLogsColumns // columns contains all the column names of Table for convenient usage. 22 } 23 24 // SysSmsLogsColumns defines and stores column names for table sys_sms_logs. 25 type SysSmsLogsColumns struct { 26 Id string // 27 Type string // 短信平台:qyxs:企业信使 28 Context string // 短信内容 29 Mobile string // 手机号 30 State string // 发送状态 31 Result string // 短信接口返回内容 32 UserId string // 用户ID 33 LicenseId string // 主体ID 34 CreatedAt string // 35 UpdatedAt string // 36 DeletedAt string // 37 } 38 39 // sysSmsLogsColumns holds the columns for table sys_sms_logs. 40 var sysSmsLogsColumns = SysSmsLogsColumns{ 41 Id: "id", 42 Type: "type", 43 Context: "context", 44 Mobile: "mobile", 45 State: "state", 46 Result: "result", 47 UserId: "user_id", 48 LicenseId: "license_id", 49 CreatedAt: "created_at", 50 UpdatedAt: "updated_at", 51 DeletedAt: "deleted_at", 52 } 53 54 // NewSysSmsLogsDao creates and returns a new DAO object for table data access. 55 func NewSysSmsLogsDao(proxy ...dao_interface.IDao) *SysSmsLogsDao { 56 var dao *SysSmsLogsDao 57 if len(proxy) > 0 { 58 dao = &SysSmsLogsDao{ 59 group: proxy[0].Group(), 60 table: proxy[0].Table(), 61 columns: sysSmsLogsColumns, 62 } 63 return dao 64 } 65 66 return &SysSmsLogsDao{ 67 group: "default", 68 table: "sys_sms_logs", 69 columns: sysSmsLogsColumns, 70 } 71 } 72 73 // DB retrieves and returns the underlying raw database management object of current DAO. 74 func (dao *SysSmsLogsDao) DB() gdb.DB { 75 return g.DB(dao.group) 76 } 77 78 // Table returns the table name of current dao. 79 func (dao *SysSmsLogsDao) Table() string { 80 return dao.table 81 } 82 83 // Group returns the configuration group name of database of current dao. 84 func (dao *SysSmsLogsDao) Group() string { 85 return dao.group 86 } 87 88 // Columns returns all column names of current dao. 89 func (dao *SysSmsLogsDao) Columns() SysSmsLogsColumns { 90 return dao.columns 91 } 92 93 // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. 94 func (dao *SysSmsLogsDao) Ctx(ctx context.Context, cacheOption ...*gdb.CacheOption) *gdb.Model { 95 return dao.DaoConfig(ctx, cacheOption...).Model 96 } 97 98 func (dao *SysSmsLogsDao) DaoConfig(ctx context.Context, cacheOption ...*gdb.CacheOption) dao_interface.DaoConfig { 99 daoConfig := dao_interface.DaoConfig{ 100 Dao: dao, 101 DB: dao.DB(), 102 Table: dao.table, 103 Group: dao.group, 104 Model: dao.DB().Model(dao.Table()).Safe().Ctx(ctx), 105 } 106 107 if len(cacheOption) == 0 { 108 daoConfig.CacheOption = daoctl.MakeDaoCache(dao.Table()) 109 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 110 } else { 111 if cacheOption[0] != nil { 112 daoConfig.CacheOption = cacheOption[0] 113 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 114 } 115 } 116 117 daoConfig.Model = daoctl.RegisterDaoHook(daoConfig.Model) 118 119 return daoConfig 120 } 121 122 // Transaction wraps the transaction logic using function f. 123 // It rollbacks the transaction and returns the error from function f if it returns non-nil error. 124 // It commits the transaction and returns nil if function f returns nil. 125 // 126 // Note that, you should not Commit or Rollback the transaction in function f 127 // as it is automatically handled by this function. 128 func (dao *SysSmsLogsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { 129 return dao.Ctx(ctx).Transaction(ctx, f) 130 }