123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- // 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 query
- import (
- "context"
- "strings"
- "gorm.io/gorm"
- "gorm.io/gorm/clause"
- "gorm.io/gorm/schema"
- "gorm.io/gen"
- "gorm.io/gen/field"
- "gorm.io/plugin/dbresolver"
- "github.com/0xJacky/Nginx-UI/model"
- )
- func newChatGPTLog(db *gorm.DB, opts ...gen.DOOption) chatGPTLog {
- _chatGPTLog := chatGPTLog{}
- _chatGPTLog.chatGPTLogDo.UseDB(db, opts...)
- _chatGPTLog.chatGPTLogDo.UseModel(&model.ChatGPTLog{})
- tableName := _chatGPTLog.chatGPTLogDo.TableName()
- _chatGPTLog.ALL = field.NewAsterisk(tableName)
- _chatGPTLog.Name = field.NewString(tableName, "name")
- _chatGPTLog.Content = field.NewField(tableName, "content")
- _chatGPTLog.fillFieldMap()
- return _chatGPTLog
- }
- type chatGPTLog struct {
- chatGPTLogDo
- ALL field.Asterisk
- Name field.String
- Content field.Field
- fieldMap map[string]field.Expr
- }
- func (c chatGPTLog) Table(newTableName string) *chatGPTLog {
- c.chatGPTLogDo.UseTable(newTableName)
- return c.updateTableName(newTableName)
- }
- func (c chatGPTLog) As(alias string) *chatGPTLog {
- c.chatGPTLogDo.DO = *(c.chatGPTLogDo.As(alias).(*gen.DO))
- return c.updateTableName(alias)
- }
- func (c *chatGPTLog) updateTableName(table string) *chatGPTLog {
- c.ALL = field.NewAsterisk(table)
- c.Name = field.NewString(table, "name")
- c.Content = field.NewField(table, "content")
- c.fillFieldMap()
- return c
- }
- func (c *chatGPTLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
- _f, ok := c.fieldMap[fieldName]
- if !ok || _f == nil {
- return nil, false
- }
- _oe, ok := _f.(field.OrderExpr)
- return _oe, ok
- }
- func (c *chatGPTLog) fillFieldMap() {
- c.fieldMap = make(map[string]field.Expr, 2)
- c.fieldMap["name"] = c.Name
- c.fieldMap["content"] = c.Content
- }
- func (c chatGPTLog) clone(db *gorm.DB) chatGPTLog {
- c.chatGPTLogDo.ReplaceConnPool(db.Statement.ConnPool)
- return c
- }
- func (c chatGPTLog) replaceDB(db *gorm.DB) chatGPTLog {
- c.chatGPTLogDo.ReplaceDB(db)
- return c
- }
- type chatGPTLogDo struct{ gen.DO }
- // FirstByID Where("id=@id")
- func (c chatGPTLogDo) FirstByID(id uint64) (result *model.ChatGPTLog, err error) {
- var params []interface{}
- var generateSQL strings.Builder
- params = append(params, id)
- generateSQL.WriteString("id=? ")
- var executeSQL *gorm.DB
- executeSQL = c.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
- err = executeSQL.Error
- return
- }
- // DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
- func (c chatGPTLogDo) DeleteByID(id uint64) (err error) {
- var params []interface{}
- var generateSQL strings.Builder
- params = append(params, id)
- generateSQL.WriteString("update chat_gpt_logs set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
- var executeSQL *gorm.DB
- executeSQL = c.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
- err = executeSQL.Error
- return
- }
- func (c chatGPTLogDo) Debug() *chatGPTLogDo {
- return c.withDO(c.DO.Debug())
- }
- func (c chatGPTLogDo) WithContext(ctx context.Context) *chatGPTLogDo {
- return c.withDO(c.DO.WithContext(ctx))
- }
- func (c chatGPTLogDo) ReadDB() *chatGPTLogDo {
- return c.Clauses(dbresolver.Read)
- }
- func (c chatGPTLogDo) WriteDB() *chatGPTLogDo {
- return c.Clauses(dbresolver.Write)
- }
- func (c chatGPTLogDo) Session(config *gorm.Session) *chatGPTLogDo {
- return c.withDO(c.DO.Session(config))
- }
- func (c chatGPTLogDo) Clauses(conds ...clause.Expression) *chatGPTLogDo {
- return c.withDO(c.DO.Clauses(conds...))
- }
- func (c chatGPTLogDo) Returning(value interface{}, columns ...string) *chatGPTLogDo {
- return c.withDO(c.DO.Returning(value, columns...))
- }
- func (c chatGPTLogDo) Not(conds ...gen.Condition) *chatGPTLogDo {
- return c.withDO(c.DO.Not(conds...))
- }
- func (c chatGPTLogDo) Or(conds ...gen.Condition) *chatGPTLogDo {
- return c.withDO(c.DO.Or(conds...))
- }
- func (c chatGPTLogDo) Select(conds ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Select(conds...))
- }
- func (c chatGPTLogDo) Where(conds ...gen.Condition) *chatGPTLogDo {
- return c.withDO(c.DO.Where(conds...))
- }
- func (c chatGPTLogDo) Order(conds ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Order(conds...))
- }
- func (c chatGPTLogDo) Distinct(cols ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Distinct(cols...))
- }
- func (c chatGPTLogDo) Omit(cols ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Omit(cols...))
- }
- func (c chatGPTLogDo) Join(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Join(table, on...))
- }
- func (c chatGPTLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.LeftJoin(table, on...))
- }
- func (c chatGPTLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.RightJoin(table, on...))
- }
- func (c chatGPTLogDo) Group(cols ...field.Expr) *chatGPTLogDo {
- return c.withDO(c.DO.Group(cols...))
- }
- func (c chatGPTLogDo) Having(conds ...gen.Condition) *chatGPTLogDo {
- return c.withDO(c.DO.Having(conds...))
- }
- func (c chatGPTLogDo) Limit(limit int) *chatGPTLogDo {
- return c.withDO(c.DO.Limit(limit))
- }
- func (c chatGPTLogDo) Offset(offset int) *chatGPTLogDo {
- return c.withDO(c.DO.Offset(offset))
- }
- func (c chatGPTLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chatGPTLogDo {
- return c.withDO(c.DO.Scopes(funcs...))
- }
- func (c chatGPTLogDo) Unscoped() *chatGPTLogDo {
- return c.withDO(c.DO.Unscoped())
- }
- func (c chatGPTLogDo) Create(values ...*model.ChatGPTLog) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Create(values)
- }
- func (c chatGPTLogDo) CreateInBatches(values []*model.ChatGPTLog, batchSize int) error {
- return c.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 (c chatGPTLogDo) Save(values ...*model.ChatGPTLog) error {
- if len(values) == 0 {
- return nil
- }
- return c.DO.Save(values)
- }
- func (c chatGPTLogDo) First() (*model.ChatGPTLog, error) {
- if result, err := c.DO.First(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChatGPTLog), nil
- }
- }
- func (c chatGPTLogDo) Take() (*model.ChatGPTLog, error) {
- if result, err := c.DO.Take(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChatGPTLog), nil
- }
- }
- func (c chatGPTLogDo) Last() (*model.ChatGPTLog, error) {
- if result, err := c.DO.Last(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChatGPTLog), nil
- }
- }
- func (c chatGPTLogDo) Find() ([]*model.ChatGPTLog, error) {
- result, err := c.DO.Find()
- return result.([]*model.ChatGPTLog), err
- }
- func (c chatGPTLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatGPTLog, err error) {
- buf := make([]*model.ChatGPTLog, 0, batchSize)
- err = c.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 (c chatGPTLogDo) FindInBatches(result *[]*model.ChatGPTLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
- return c.DO.FindInBatches(result, batchSize, fc)
- }
- func (c chatGPTLogDo) Attrs(attrs ...field.AssignExpr) *chatGPTLogDo {
- return c.withDO(c.DO.Attrs(attrs...))
- }
- func (c chatGPTLogDo) Assign(attrs ...field.AssignExpr) *chatGPTLogDo {
- return c.withDO(c.DO.Assign(attrs...))
- }
- func (c chatGPTLogDo) Joins(fields ...field.RelationField) *chatGPTLogDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Joins(_f))
- }
- return &c
- }
- func (c chatGPTLogDo) Preload(fields ...field.RelationField) *chatGPTLogDo {
- for _, _f := range fields {
- c = *c.withDO(c.DO.Preload(_f))
- }
- return &c
- }
- func (c chatGPTLogDo) FirstOrInit() (*model.ChatGPTLog, error) {
- if result, err := c.DO.FirstOrInit(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChatGPTLog), nil
- }
- }
- func (c chatGPTLogDo) FirstOrCreate() (*model.ChatGPTLog, error) {
- if result, err := c.DO.FirstOrCreate(); err != nil {
- return nil, err
- } else {
- return result.(*model.ChatGPTLog), nil
- }
- }
- func (c chatGPTLogDo) FindByPage(offset int, limit int) (result []*model.ChatGPTLog, count int64, err error) {
- result, err = c.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 = c.Offset(-1).Limit(-1).Count()
- return
- }
- func (c chatGPTLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
- count, err = c.Count()
- if err != nil {
- return
- }
- err = c.Offset(offset).Limit(limit).Scan(result)
- return
- }
- func (c chatGPTLogDo) Scan(result interface{}) (err error) {
- return c.DO.Scan(result)
- }
- func (c chatGPTLogDo) Delete(models ...*model.ChatGPTLog) (result gen.ResultInfo, err error) {
- return c.DO.Delete(models)
- }
- func (c *chatGPTLogDo) withDO(do gen.Dao) *chatGPTLogDo {
- c.DO = *do.(*gen.DO)
- return c
- }
|