chat_gpt_logs.gen.go 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. // Code generated by gorm.io/gen. DO NOT EDIT.
  2. // Code generated by gorm.io/gen. DO NOT EDIT.
  3. // Code generated by gorm.io/gen. DO NOT EDIT.
  4. package query
  5. import (
  6. "context"
  7. "strings"
  8. "gorm.io/gorm"
  9. "gorm.io/gorm/clause"
  10. "gorm.io/gorm/schema"
  11. "gorm.io/gen"
  12. "gorm.io/gen/field"
  13. "gorm.io/plugin/dbresolver"
  14. "github.com/0xJacky/Nginx-UI/model"
  15. )
  16. func newChatGPTLog(db *gorm.DB, opts ...gen.DOOption) chatGPTLog {
  17. _chatGPTLog := chatGPTLog{}
  18. _chatGPTLog.chatGPTLogDo.UseDB(db, opts...)
  19. _chatGPTLog.chatGPTLogDo.UseModel(&model.ChatGPTLog{})
  20. tableName := _chatGPTLog.chatGPTLogDo.TableName()
  21. _chatGPTLog.ALL = field.NewAsterisk(tableName)
  22. _chatGPTLog.Name = field.NewString(tableName, "name")
  23. _chatGPTLog.Content = field.NewField(tableName, "content")
  24. _chatGPTLog.fillFieldMap()
  25. return _chatGPTLog
  26. }
  27. type chatGPTLog struct {
  28. chatGPTLogDo
  29. ALL field.Asterisk
  30. Name field.String
  31. Content field.Field
  32. fieldMap map[string]field.Expr
  33. }
  34. func (c chatGPTLog) Table(newTableName string) *chatGPTLog {
  35. c.chatGPTLogDo.UseTable(newTableName)
  36. return c.updateTableName(newTableName)
  37. }
  38. func (c chatGPTLog) As(alias string) *chatGPTLog {
  39. c.chatGPTLogDo.DO = *(c.chatGPTLogDo.As(alias).(*gen.DO))
  40. return c.updateTableName(alias)
  41. }
  42. func (c *chatGPTLog) updateTableName(table string) *chatGPTLog {
  43. c.ALL = field.NewAsterisk(table)
  44. c.Name = field.NewString(table, "name")
  45. c.Content = field.NewField(table, "content")
  46. c.fillFieldMap()
  47. return c
  48. }
  49. func (c *chatGPTLog) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  50. _f, ok := c.fieldMap[fieldName]
  51. if !ok || _f == nil {
  52. return nil, false
  53. }
  54. _oe, ok := _f.(field.OrderExpr)
  55. return _oe, ok
  56. }
  57. func (c *chatGPTLog) fillFieldMap() {
  58. c.fieldMap = make(map[string]field.Expr, 2)
  59. c.fieldMap["name"] = c.Name
  60. c.fieldMap["content"] = c.Content
  61. }
  62. func (c chatGPTLog) clone(db *gorm.DB) chatGPTLog {
  63. c.chatGPTLogDo.ReplaceConnPool(db.Statement.ConnPool)
  64. return c
  65. }
  66. func (c chatGPTLog) replaceDB(db *gorm.DB) chatGPTLog {
  67. c.chatGPTLogDo.ReplaceDB(db)
  68. return c
  69. }
  70. type chatGPTLogDo struct{ gen.DO }
  71. // FirstByID Where("id=@id")
  72. func (c chatGPTLogDo) FirstByID(id uint64) (result *model.ChatGPTLog, err error) {
  73. var params []interface{}
  74. var generateSQL strings.Builder
  75. params = append(params, id)
  76. generateSQL.WriteString("id=? ")
  77. var executeSQL *gorm.DB
  78. executeSQL = c.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
  79. err = executeSQL.Error
  80. return
  81. }
  82. // DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
  83. func (c chatGPTLogDo) DeleteByID(id uint64) (err error) {
  84. var params []interface{}
  85. var generateSQL strings.Builder
  86. params = append(params, id)
  87. generateSQL.WriteString("update chat_gpt_logs set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
  88. var executeSQL *gorm.DB
  89. executeSQL = c.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
  90. err = executeSQL.Error
  91. return
  92. }
  93. func (c chatGPTLogDo) Debug() *chatGPTLogDo {
  94. return c.withDO(c.DO.Debug())
  95. }
  96. func (c chatGPTLogDo) WithContext(ctx context.Context) *chatGPTLogDo {
  97. return c.withDO(c.DO.WithContext(ctx))
  98. }
  99. func (c chatGPTLogDo) ReadDB() *chatGPTLogDo {
  100. return c.Clauses(dbresolver.Read)
  101. }
  102. func (c chatGPTLogDo) WriteDB() *chatGPTLogDo {
  103. return c.Clauses(dbresolver.Write)
  104. }
  105. func (c chatGPTLogDo) Session(config *gorm.Session) *chatGPTLogDo {
  106. return c.withDO(c.DO.Session(config))
  107. }
  108. func (c chatGPTLogDo) Clauses(conds ...clause.Expression) *chatGPTLogDo {
  109. return c.withDO(c.DO.Clauses(conds...))
  110. }
  111. func (c chatGPTLogDo) Returning(value interface{}, columns ...string) *chatGPTLogDo {
  112. return c.withDO(c.DO.Returning(value, columns...))
  113. }
  114. func (c chatGPTLogDo) Not(conds ...gen.Condition) *chatGPTLogDo {
  115. return c.withDO(c.DO.Not(conds...))
  116. }
  117. func (c chatGPTLogDo) Or(conds ...gen.Condition) *chatGPTLogDo {
  118. return c.withDO(c.DO.Or(conds...))
  119. }
  120. func (c chatGPTLogDo) Select(conds ...field.Expr) *chatGPTLogDo {
  121. return c.withDO(c.DO.Select(conds...))
  122. }
  123. func (c chatGPTLogDo) Where(conds ...gen.Condition) *chatGPTLogDo {
  124. return c.withDO(c.DO.Where(conds...))
  125. }
  126. func (c chatGPTLogDo) Order(conds ...field.Expr) *chatGPTLogDo {
  127. return c.withDO(c.DO.Order(conds...))
  128. }
  129. func (c chatGPTLogDo) Distinct(cols ...field.Expr) *chatGPTLogDo {
  130. return c.withDO(c.DO.Distinct(cols...))
  131. }
  132. func (c chatGPTLogDo) Omit(cols ...field.Expr) *chatGPTLogDo {
  133. return c.withDO(c.DO.Omit(cols...))
  134. }
  135. func (c chatGPTLogDo) Join(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
  136. return c.withDO(c.DO.Join(table, on...))
  137. }
  138. func (c chatGPTLogDo) LeftJoin(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
  139. return c.withDO(c.DO.LeftJoin(table, on...))
  140. }
  141. func (c chatGPTLogDo) RightJoin(table schema.Tabler, on ...field.Expr) *chatGPTLogDo {
  142. return c.withDO(c.DO.RightJoin(table, on...))
  143. }
  144. func (c chatGPTLogDo) Group(cols ...field.Expr) *chatGPTLogDo {
  145. return c.withDO(c.DO.Group(cols...))
  146. }
  147. func (c chatGPTLogDo) Having(conds ...gen.Condition) *chatGPTLogDo {
  148. return c.withDO(c.DO.Having(conds...))
  149. }
  150. func (c chatGPTLogDo) Limit(limit int) *chatGPTLogDo {
  151. return c.withDO(c.DO.Limit(limit))
  152. }
  153. func (c chatGPTLogDo) Offset(offset int) *chatGPTLogDo {
  154. return c.withDO(c.DO.Offset(offset))
  155. }
  156. func (c chatGPTLogDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *chatGPTLogDo {
  157. return c.withDO(c.DO.Scopes(funcs...))
  158. }
  159. func (c chatGPTLogDo) Unscoped() *chatGPTLogDo {
  160. return c.withDO(c.DO.Unscoped())
  161. }
  162. func (c chatGPTLogDo) Create(values ...*model.ChatGPTLog) error {
  163. if len(values) == 0 {
  164. return nil
  165. }
  166. return c.DO.Create(values)
  167. }
  168. func (c chatGPTLogDo) CreateInBatches(values []*model.ChatGPTLog, batchSize int) error {
  169. return c.DO.CreateInBatches(values, batchSize)
  170. }
  171. // Save : !!! underlying implementation is different with GORM
  172. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  173. func (c chatGPTLogDo) Save(values ...*model.ChatGPTLog) error {
  174. if len(values) == 0 {
  175. return nil
  176. }
  177. return c.DO.Save(values)
  178. }
  179. func (c chatGPTLogDo) First() (*model.ChatGPTLog, error) {
  180. if result, err := c.DO.First(); err != nil {
  181. return nil, err
  182. } else {
  183. return result.(*model.ChatGPTLog), nil
  184. }
  185. }
  186. func (c chatGPTLogDo) Take() (*model.ChatGPTLog, error) {
  187. if result, err := c.DO.Take(); err != nil {
  188. return nil, err
  189. } else {
  190. return result.(*model.ChatGPTLog), nil
  191. }
  192. }
  193. func (c chatGPTLogDo) Last() (*model.ChatGPTLog, error) {
  194. if result, err := c.DO.Last(); err != nil {
  195. return nil, err
  196. } else {
  197. return result.(*model.ChatGPTLog), nil
  198. }
  199. }
  200. func (c chatGPTLogDo) Find() ([]*model.ChatGPTLog, error) {
  201. result, err := c.DO.Find()
  202. return result.([]*model.ChatGPTLog), err
  203. }
  204. func (c chatGPTLogDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.ChatGPTLog, err error) {
  205. buf := make([]*model.ChatGPTLog, 0, batchSize)
  206. err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  207. defer func() { results = append(results, buf...) }()
  208. return fc(tx, batch)
  209. })
  210. return results, err
  211. }
  212. func (c chatGPTLogDo) FindInBatches(result *[]*model.ChatGPTLog, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  213. return c.DO.FindInBatches(result, batchSize, fc)
  214. }
  215. func (c chatGPTLogDo) Attrs(attrs ...field.AssignExpr) *chatGPTLogDo {
  216. return c.withDO(c.DO.Attrs(attrs...))
  217. }
  218. func (c chatGPTLogDo) Assign(attrs ...field.AssignExpr) *chatGPTLogDo {
  219. return c.withDO(c.DO.Assign(attrs...))
  220. }
  221. func (c chatGPTLogDo) Joins(fields ...field.RelationField) *chatGPTLogDo {
  222. for _, _f := range fields {
  223. c = *c.withDO(c.DO.Joins(_f))
  224. }
  225. return &c
  226. }
  227. func (c chatGPTLogDo) Preload(fields ...field.RelationField) *chatGPTLogDo {
  228. for _, _f := range fields {
  229. c = *c.withDO(c.DO.Preload(_f))
  230. }
  231. return &c
  232. }
  233. func (c chatGPTLogDo) FirstOrInit() (*model.ChatGPTLog, error) {
  234. if result, err := c.DO.FirstOrInit(); err != nil {
  235. return nil, err
  236. } else {
  237. return result.(*model.ChatGPTLog), nil
  238. }
  239. }
  240. func (c chatGPTLogDo) FirstOrCreate() (*model.ChatGPTLog, error) {
  241. if result, err := c.DO.FirstOrCreate(); err != nil {
  242. return nil, err
  243. } else {
  244. return result.(*model.ChatGPTLog), nil
  245. }
  246. }
  247. func (c chatGPTLogDo) FindByPage(offset int, limit int) (result []*model.ChatGPTLog, count int64, err error) {
  248. result, err = c.Offset(offset).Limit(limit).Find()
  249. if err != nil {
  250. return
  251. }
  252. if size := len(result); 0 < limit && 0 < size && size < limit {
  253. count = int64(size + offset)
  254. return
  255. }
  256. count, err = c.Offset(-1).Limit(-1).Count()
  257. return
  258. }
  259. func (c chatGPTLogDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  260. count, err = c.Count()
  261. if err != nil {
  262. return
  263. }
  264. err = c.Offset(offset).Limit(limit).Scan(result)
  265. return
  266. }
  267. func (c chatGPTLogDo) Scan(result interface{}) (err error) {
  268. return c.DO.Scan(result)
  269. }
  270. func (c chatGPTLogDo) Delete(models ...*model.ChatGPTLog) (result gen.ResultInfo, err error) {
  271. return c.DO.Delete(models)
  272. }
  273. func (c *chatGPTLogDo) withDO(do gen.Dao) *chatGPTLogDo {
  274. c.DO = *do.(*gen.DO)
  275. return c
  276. }