github.com/SupenBysz/gf-admin-community@v0.7.4/sys_model/sys_dao/internal/sys_message.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 // SysMessageDao is the data access object for table sys_message. 18 type SysMessageDao 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 SysMessageColumns // columns contains all the column names of Table for convenient usage. 22 } 23 24 // SysMessageColumns defines and stores column names for table sys_message. 25 type SysMessageColumns struct { 26 Id string // ID 27 Title string // 标题 28 Summary string // 摘要 29 Content string // 内容 30 Type string // 消息类型 31 Link string // 跳转链接 32 ToUserIds string // 接收者UserIds,允许有多个接收者 33 ToUserType string // 接收者类型用户类型,和UserType保持一致 34 FromUserId string // 发送者ID,为-1代表系统消息 35 FromUserType string // 发送者类型 36 SendAt string // 发送时间 37 ExtJson string // 拓展数据Json 38 ReadUserIds string // 已读用户UserIds 39 DataIdentifier string // 关联的数据标识 40 CreatedAt string // 41 UpdatedAt string // 42 DeletedAt string // 43 } 44 45 // sysMessageColumns holds the columns for table sys_message. 46 var sysMessageColumns = SysMessageColumns{ 47 Id: "id", 48 Title: "title", 49 Summary: "summary", 50 Content: "content", 51 Type: "type", 52 Link: "link", 53 ToUserIds: "to_user_ids", 54 ToUserType: "to_user_type", 55 FromUserId: "from_user_id", 56 FromUserType: "from_user_type", 57 SendAt: "send_at", 58 ExtJson: "ext_json", 59 ReadUserIds: "read_user_ids", 60 DataIdentifier: "data_identifier", 61 CreatedAt: "created_at", 62 UpdatedAt: "updated_at", 63 DeletedAt: "deleted_at", 64 } 65 66 // NewSysMessageDao creates and returns a new DAO object for table data access. 67 func NewSysMessageDao(proxy ...dao_interface.IDao) *SysMessageDao { 68 var dao *SysMessageDao 69 if len(proxy) > 0 { 70 dao = &SysMessageDao{ 71 group: proxy[0].Group(), 72 table: proxy[0].Table(), 73 columns: sysMessageColumns, 74 } 75 return dao 76 } 77 78 return &SysMessageDao{ 79 group: "default", 80 table: "sys_message", 81 columns: sysMessageColumns, 82 } 83 } 84 85 // DB retrieves and returns the underlying raw database management object of current DAO. 86 func (dao *SysMessageDao) DB() gdb.DB { 87 return g.DB(dao.group) 88 } 89 90 // Table returns the table name of current dao. 91 func (dao *SysMessageDao) Table() string { 92 return dao.table 93 } 94 95 // Group returns the configuration group name of database of current dao. 96 func (dao *SysMessageDao) Group() string { 97 return dao.group 98 } 99 100 // Columns returns all column names of current dao. 101 func (dao *SysMessageDao) Columns() SysMessageColumns { 102 return dao.columns 103 } 104 105 // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. 106 func (dao *SysMessageDao) Ctx(ctx context.Context, cacheOption ...*gdb.CacheOption) *gdb.Model { 107 return dao.DaoConfig(ctx, cacheOption...).Model 108 } 109 110 func (dao *SysMessageDao) DaoConfig(ctx context.Context, cacheOption ...*gdb.CacheOption) dao_interface.DaoConfig { 111 daoConfig := dao_interface.DaoConfig{ 112 Dao: dao, 113 DB: dao.DB(), 114 Table: dao.table, 115 Group: dao.group, 116 Model: dao.DB().Model(dao.Table()).Safe().Ctx(ctx), 117 } 118 119 if len(cacheOption) == 0 { 120 daoConfig.CacheOption = daoctl.MakeDaoCache(dao.Table()) 121 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 122 } else { 123 if cacheOption[0] != nil { 124 daoConfig.CacheOption = cacheOption[0] 125 daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption) 126 } 127 } 128 129 daoConfig.Model = daoctl.RegisterDaoHook(daoConfig.Model) 130 131 return daoConfig 132 } 133 134 // Transaction wraps the transaction logic using function f. 135 // It rollbacks the transaction and returns the error from function f if it returns non-nil error. 136 // It commits the transaction and returns nil if function f returns nil. 137 // 138 // Note that, you should not Commit or Rollback the transaction in function f 139 // as it is automatically handled by this function. 140 func (dao *SysMessageDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { 141 return dao.Ctx(ctx).Transaction(ctx, f) 142 }