|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
// Code generated by gorm.io/gen. DO NOT EDIT.
|
|
|
|
|
|
package dao
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
"gorm.io/gorm/clause"
|
|
|
"gorm.io/gorm/schema"
|
|
|
|
|
|
"gorm.io/gen"
|
|
|
"gorm.io/gen/field"
|
|
|
|
|
|
"gorm.io/plugin/dbresolver"
|
|
|
|
|
|
"joybuywork/internal/repository/model"
|
|
|
)
|
|
|
|
|
|
func newFissionChatMsg(db *gorm.DB, opts ...gen.DOOption) fissionChatMsg {
|
|
|
_fissionChatMsg := fissionChatMsg{}
|
|
|
|
|
|
_fissionChatMsg.fissionChatMsgDo.UseDB(db, opts...)
|
|
|
_fissionChatMsg.fissionChatMsgDo.UseModel(&model.FissionChatMsg{})
|
|
|
|
|
|
tableName := _fissionChatMsg.fissionChatMsgDo.TableName()
|
|
|
_fissionChatMsg.ALL = field.NewAsterisk(tableName)
|
|
|
_fissionChatMsg.ID = field.NewInt64(tableName, "id")
|
|
|
_fissionChatMsg.CreatedAt = field.NewInt64(tableName, "created_at")
|
|
|
_fissionChatMsg.CampaignID = field.NewInt64(tableName, "campaign_id")
|
|
|
_fissionChatMsg.UserID = field.NewInt64(tableName, "user_id")
|
|
|
_fissionChatMsg.ChatID = field.NewInt64(tableName, "chat_id")
|
|
|
_fissionChatMsg.Source = field.NewString(tableName, "source")
|
|
|
_fissionChatMsg.MsgType = field.NewInt8(tableName, "msg_type")
|
|
|
_fissionChatMsg.Val = field.NewString(tableName, "val")
|
|
|
|
|
|
_fissionChatMsg.fillFieldMap()
|
|
|
|
|
|
return _fissionChatMsg
|
|
|
}
|
|
|
|
|
|
type fissionChatMsg struct {
|
|
|
fissionChatMsgDo fissionChatMsgDo
|
|
|
|
|
|
ALL field.Asterisk
|
|
|
ID field.Int64
|
|
|
CreatedAt field.Int64
|
|
|
CampaignID field.Int64 // 活动ID(fission_campaign表)
|
|
|
UserID field.Int64 // 用户ID(fission_user表)
|
|
|
ChatID field.Int64 // 聊天窗ID(fission_chat)
|
|
|
Source field.String // 来源
|
|
|
MsgType field.Int8 // 消息类型
|
|
|
Val field.String // 消息数据
|
|
|
|
|
|
fieldMap map[string]field.Expr
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsg) Table(newTableName string) *fissionChatMsg {
|
|
|
f.fissionChatMsgDo.UseTable(newTableName)
|
|
|
return f.updateTableName(newTableName)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsg) As(alias string) *fissionChatMsg {
|
|
|
f.fissionChatMsgDo.DO = *(f.fissionChatMsgDo.As(alias).(*gen.DO))
|
|
|
return f.updateTableName(alias)
|
|
|
}
|
|
|
|
|
|
func (f *fissionChatMsg) updateTableName(table string) *fissionChatMsg {
|
|
|
f.ALL = field.NewAsterisk(table)
|
|
|
f.ID = field.NewInt64(table, "id")
|
|
|
f.CreatedAt = field.NewInt64(table, "created_at")
|
|
|
f.CampaignID = field.NewInt64(table, "campaign_id")
|
|
|
f.UserID = field.NewInt64(table, "user_id")
|
|
|
f.ChatID = field.NewInt64(table, "chat_id")
|
|
|
f.Source = field.NewString(table, "source")
|
|
|
f.MsgType = field.NewInt8(table, "msg_type")
|
|
|
f.Val = field.NewString(table, "val")
|
|
|
|
|
|
f.fillFieldMap()
|
|
|
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f *fissionChatMsg) WithContext(ctx context.Context) *fissionChatMsgDo {
|
|
|
return f.fissionChatMsgDo.WithContext(ctx)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsg) TableName() string { return f.fissionChatMsgDo.TableName() }
|
|
|
|
|
|
func (f fissionChatMsg) Alias() string { return f.fissionChatMsgDo.Alias() }
|
|
|
|
|
|
func (f *fissionChatMsg) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
|
|
_f, ok := f.fieldMap[fieldName]
|
|
|
if !ok || _f == nil {
|
|
|
return nil, false
|
|
|
}
|
|
|
_oe, ok := _f.(field.OrderExpr)
|
|
|
return _oe, ok
|
|
|
}
|
|
|
|
|
|
func (f *fissionChatMsg) fillFieldMap() {
|
|
|
f.fieldMap = make(map[string]field.Expr, 8)
|
|
|
f.fieldMap["id"] = f.ID
|
|
|
f.fieldMap["created_at"] = f.CreatedAt
|
|
|
f.fieldMap["campaign_id"] = f.CampaignID
|
|
|
f.fieldMap["user_id"] = f.UserID
|
|
|
f.fieldMap["chat_id"] = f.ChatID
|
|
|
f.fieldMap["source"] = f.Source
|
|
|
f.fieldMap["msg_type"] = f.MsgType
|
|
|
f.fieldMap["val"] = f.Val
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsg) clone(db *gorm.DB) fissionChatMsg {
|
|
|
f.fissionChatMsgDo.ReplaceConnPool(db.Statement.ConnPool)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsg) replaceDB(db *gorm.DB) fissionChatMsg {
|
|
|
f.fissionChatMsgDo.ReplaceDB(db)
|
|
|
return f
|
|
|
}
|
|
|
|
|
|
type fissionChatMsgDo struct{ gen.DO }
|
|
|
|
|
|
func (f fissionChatMsgDo) Debug() *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Debug())
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) WithContext(ctx context.Context) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.WithContext(ctx))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) ReadDB() *fissionChatMsgDo {
|
|
|
return f.Clauses(dbresolver.Read)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) WriteDB() *fissionChatMsgDo {
|
|
|
return f.Clauses(dbresolver.Write)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Session(config *gorm.Session) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Session(config))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Clauses(conds ...clause.Expression) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Clauses(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Returning(value interface{}, columns ...string) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Returning(value, columns...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Not(conds ...gen.Condition) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Not(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Or(conds ...gen.Condition) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Or(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Select(conds ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Select(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Where(conds ...gen.Condition) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Where(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *fissionChatMsgDo {
|
|
|
return f.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Order(conds ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Order(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Distinct(cols ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Distinct(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Omit(cols ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Omit(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Join(table schema.Tabler, on ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Join(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) LeftJoin(table schema.Tabler, on ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.LeftJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) RightJoin(table schema.Tabler, on ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.RightJoin(table, on...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Group(cols ...field.Expr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Group(cols...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Having(conds ...gen.Condition) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Having(conds...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Limit(limit int) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Limit(limit))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Offset(offset int) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Offset(offset))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Scopes(funcs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Unscoped() *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Unscoped())
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Create(values ...*model.FissionChatMsg) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Create(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) CreateInBatches(values []*model.FissionChatMsg, batchSize int) error {
|
|
|
return f.DO.CreateInBatches(values, batchSize)
|
|
|
}
|
|
|
|
|
|
// Save : !!! underlying implementation is different with GORM
|
|
|
// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
|
|
|
func (f fissionChatMsgDo) Save(values ...*model.FissionChatMsg) error {
|
|
|
if len(values) == 0 {
|
|
|
return nil
|
|
|
}
|
|
|
return f.DO.Save(values)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) First() (*model.FissionChatMsg, error) {
|
|
|
if result, err := f.DO.First(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChatMsg), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Take() (*model.FissionChatMsg, error) {
|
|
|
if result, err := f.DO.Take(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChatMsg), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Last() (*model.FissionChatMsg, error) {
|
|
|
if result, err := f.DO.Last(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChatMsg), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Find() ([]*model.FissionChatMsg, error) {
|
|
|
result, err := f.DO.Find()
|
|
|
return result.([]*model.FissionChatMsg), err
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.FissionChatMsg, err error) {
|
|
|
buf := make([]*model.FissionChatMsg, 0, batchSize)
|
|
|
err = f.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
|
|
|
defer func() { results = append(results, buf...) }()
|
|
|
return fc(tx, batch)
|
|
|
})
|
|
|
return results, err
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) FindInBatches(result *[]*model.FissionChatMsg, batchSize int, fc func(tx gen.Dao, batch int) error) error {
|
|
|
return f.DO.FindInBatches(result, batchSize, fc)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Attrs(attrs ...field.AssignExpr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Attrs(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Assign(attrs ...field.AssignExpr) *fissionChatMsgDo {
|
|
|
return f.withDO(f.DO.Assign(attrs...))
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Joins(fields ...field.RelationField) *fissionChatMsgDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Joins(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Preload(fields ...field.RelationField) *fissionChatMsgDo {
|
|
|
for _, _f := range fields {
|
|
|
f = *f.withDO(f.DO.Preload(_f))
|
|
|
}
|
|
|
return &f
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) FirstOrInit() (*model.FissionChatMsg, error) {
|
|
|
if result, err := f.DO.FirstOrInit(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChatMsg), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) FirstOrCreate() (*model.FissionChatMsg, error) {
|
|
|
if result, err := f.DO.FirstOrCreate(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
return result.(*model.FissionChatMsg), nil
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) FindByPage(offset int, limit int) (result []*model.FissionChatMsg, count int64, err error) {
|
|
|
result, err = f.Offset(offset).Limit(limit).Find()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if size := len(result); 0 < limit && 0 < size && size < limit {
|
|
|
count = int64(size + offset)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
count, err = f.Offset(-1).Limit(-1).Count()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
|
|
|
count, err = f.Count()
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
err = f.Offset(offset).Limit(limit).Scan(result)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Scan(result interface{}) (err error) {
|
|
|
return f.DO.Scan(result)
|
|
|
}
|
|
|
|
|
|
func (f fissionChatMsgDo) Delete(models ...*model.FissionChatMsg) (result gen.ResultInfo, err error) {
|
|
|
return f.DO.Delete(models)
|
|
|
}
|
|
|
|
|
|
func (f *fissionChatMsgDo) withDO(do gen.Dao) *fissionChatMsgDo {
|
|
|
f.DO = *do.(*gen.DO)
|
|
|
return f
|
|
|
}
|