nginx_log_indices.gen.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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 newNginxLogIndex(db *gorm.DB, opts ...gen.DOOption) nginxLogIndex {
  17. _nginxLogIndex := nginxLogIndex{}
  18. _nginxLogIndex.nginxLogIndexDo.UseDB(db, opts...)
  19. _nginxLogIndex.nginxLogIndexDo.UseModel(&model.NginxLogIndex{})
  20. tableName := _nginxLogIndex.nginxLogIndexDo.TableName()
  21. _nginxLogIndex.ALL = field.NewAsterisk(tableName)
  22. _nginxLogIndex.ID = field.NewField(tableName, "id")
  23. _nginxLogIndex.CreatedAt = field.NewTime(tableName, "created_at")
  24. _nginxLogIndex.UpdatedAt = field.NewTime(tableName, "updated_at")
  25. _nginxLogIndex.Path = field.NewString(tableName, "path")
  26. _nginxLogIndex.MainLogPath = field.NewString(tableName, "main_log_path")
  27. _nginxLogIndex.LastModified = field.NewTime(tableName, "last_modified")
  28. _nginxLogIndex.LastSize = field.NewInt64(tableName, "last_size")
  29. _nginxLogIndex.LastPosition = field.NewInt64(tableName, "last_position")
  30. _nginxLogIndex.LastIndexed = field.NewTime(tableName, "last_indexed")
  31. _nginxLogIndex.IndexStartTime = field.NewTime(tableName, "index_start_time")
  32. _nginxLogIndex.IndexDuration = field.NewInt64(tableName, "index_duration")
  33. _nginxLogIndex.TimeRangeStart = field.NewTime(tableName, "time_range_start")
  34. _nginxLogIndex.TimeRangeEnd = field.NewTime(tableName, "time_range_end")
  35. _nginxLogIndex.DocumentCount = field.NewUint64(tableName, "document_count")
  36. _nginxLogIndex.Enabled = field.NewBool(tableName, "enabled")
  37. _nginxLogIndex.IndexStatus = field.NewString(tableName, "index_status")
  38. _nginxLogIndex.ErrorMessage = field.NewString(tableName, "error_message")
  39. _nginxLogIndex.ErrorTime = field.NewTime(tableName, "error_time")
  40. _nginxLogIndex.RetryCount = field.NewInt(tableName, "retry_count")
  41. _nginxLogIndex.QueuePosition = field.NewInt(tableName, "queue_position")
  42. _nginxLogIndex.fillFieldMap()
  43. return _nginxLogIndex
  44. }
  45. type nginxLogIndex struct {
  46. nginxLogIndexDo
  47. ALL field.Asterisk
  48. ID field.Field
  49. CreatedAt field.Time
  50. UpdatedAt field.Time
  51. Path field.String
  52. MainLogPath field.String
  53. LastModified field.Time
  54. LastSize field.Int64
  55. LastPosition field.Int64
  56. LastIndexed field.Time
  57. IndexStartTime field.Time
  58. IndexDuration field.Int64
  59. TimeRangeStart field.Time
  60. TimeRangeEnd field.Time
  61. DocumentCount field.Uint64
  62. Enabled field.Bool
  63. IndexStatus field.String
  64. ErrorMessage field.String
  65. ErrorTime field.Time
  66. RetryCount field.Int
  67. QueuePosition field.Int
  68. fieldMap map[string]field.Expr
  69. }
  70. func (n nginxLogIndex) Table(newTableName string) *nginxLogIndex {
  71. n.nginxLogIndexDo.UseTable(newTableName)
  72. return n.updateTableName(newTableName)
  73. }
  74. func (n nginxLogIndex) As(alias string) *nginxLogIndex {
  75. n.nginxLogIndexDo.DO = *(n.nginxLogIndexDo.As(alias).(*gen.DO))
  76. return n.updateTableName(alias)
  77. }
  78. func (n *nginxLogIndex) updateTableName(table string) *nginxLogIndex {
  79. n.ALL = field.NewAsterisk(table)
  80. n.ID = field.NewField(table, "id")
  81. n.CreatedAt = field.NewTime(table, "created_at")
  82. n.UpdatedAt = field.NewTime(table, "updated_at")
  83. n.Path = field.NewString(table, "path")
  84. n.MainLogPath = field.NewString(table, "main_log_path")
  85. n.LastModified = field.NewTime(table, "last_modified")
  86. n.LastSize = field.NewInt64(table, "last_size")
  87. n.LastPosition = field.NewInt64(table, "last_position")
  88. n.LastIndexed = field.NewTime(table, "last_indexed")
  89. n.IndexStartTime = field.NewTime(table, "index_start_time")
  90. n.IndexDuration = field.NewInt64(table, "index_duration")
  91. n.TimeRangeStart = field.NewTime(table, "time_range_start")
  92. n.TimeRangeEnd = field.NewTime(table, "time_range_end")
  93. n.DocumentCount = field.NewUint64(table, "document_count")
  94. n.Enabled = field.NewBool(table, "enabled")
  95. n.IndexStatus = field.NewString(table, "index_status")
  96. n.ErrorMessage = field.NewString(table, "error_message")
  97. n.ErrorTime = field.NewTime(table, "error_time")
  98. n.RetryCount = field.NewInt(table, "retry_count")
  99. n.QueuePosition = field.NewInt(table, "queue_position")
  100. n.fillFieldMap()
  101. return n
  102. }
  103. func (n *nginxLogIndex) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  104. _f, ok := n.fieldMap[fieldName]
  105. if !ok || _f == nil {
  106. return nil, false
  107. }
  108. _oe, ok := _f.(field.OrderExpr)
  109. return _oe, ok
  110. }
  111. func (n *nginxLogIndex) fillFieldMap() {
  112. n.fieldMap = make(map[string]field.Expr, 20)
  113. n.fieldMap["id"] = n.ID
  114. n.fieldMap["created_at"] = n.CreatedAt
  115. n.fieldMap["updated_at"] = n.UpdatedAt
  116. n.fieldMap["path"] = n.Path
  117. n.fieldMap["main_log_path"] = n.MainLogPath
  118. n.fieldMap["last_modified"] = n.LastModified
  119. n.fieldMap["last_size"] = n.LastSize
  120. n.fieldMap["last_position"] = n.LastPosition
  121. n.fieldMap["last_indexed"] = n.LastIndexed
  122. n.fieldMap["index_start_time"] = n.IndexStartTime
  123. n.fieldMap["index_duration"] = n.IndexDuration
  124. n.fieldMap["time_range_start"] = n.TimeRangeStart
  125. n.fieldMap["time_range_end"] = n.TimeRangeEnd
  126. n.fieldMap["document_count"] = n.DocumentCount
  127. n.fieldMap["enabled"] = n.Enabled
  128. n.fieldMap["index_status"] = n.IndexStatus
  129. n.fieldMap["error_message"] = n.ErrorMessage
  130. n.fieldMap["error_time"] = n.ErrorTime
  131. n.fieldMap["retry_count"] = n.RetryCount
  132. n.fieldMap["queue_position"] = n.QueuePosition
  133. }
  134. func (n nginxLogIndex) clone(db *gorm.DB) nginxLogIndex {
  135. n.nginxLogIndexDo.ReplaceConnPool(db.Statement.ConnPool)
  136. return n
  137. }
  138. func (n nginxLogIndex) replaceDB(db *gorm.DB) nginxLogIndex {
  139. n.nginxLogIndexDo.ReplaceDB(db)
  140. return n
  141. }
  142. type nginxLogIndexDo struct{ gen.DO }
  143. // FirstByID Where("id=@id")
  144. func (n nginxLogIndexDo) FirstByID(id uint64) (result *model.NginxLogIndex, err error) {
  145. var params []interface{}
  146. var generateSQL strings.Builder
  147. params = append(params, id)
  148. generateSQL.WriteString("id=? ")
  149. var executeSQL *gorm.DB
  150. executeSQL = n.UnderlyingDB().Where(generateSQL.String(), params...).Take(&result) // ignore_security_alert
  151. err = executeSQL.Error
  152. return
  153. }
  154. // DeleteByID update @@table set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=@id
  155. func (n nginxLogIndexDo) DeleteByID(id uint64) (err error) {
  156. var params []interface{}
  157. var generateSQL strings.Builder
  158. params = append(params, id)
  159. generateSQL.WriteString("update nginx_log_indices set deleted_at=strftime('%Y-%m-%d %H:%M:%S','now') where id=? ")
  160. var executeSQL *gorm.DB
  161. executeSQL = n.UnderlyingDB().Exec(generateSQL.String(), params...) // ignore_security_alert
  162. err = executeSQL.Error
  163. return
  164. }
  165. func (n nginxLogIndexDo) Debug() *nginxLogIndexDo {
  166. return n.withDO(n.DO.Debug())
  167. }
  168. func (n nginxLogIndexDo) WithContext(ctx context.Context) *nginxLogIndexDo {
  169. return n.withDO(n.DO.WithContext(ctx))
  170. }
  171. func (n nginxLogIndexDo) ReadDB() *nginxLogIndexDo {
  172. return n.Clauses(dbresolver.Read)
  173. }
  174. func (n nginxLogIndexDo) WriteDB() *nginxLogIndexDo {
  175. return n.Clauses(dbresolver.Write)
  176. }
  177. func (n nginxLogIndexDo) Session(config *gorm.Session) *nginxLogIndexDo {
  178. return n.withDO(n.DO.Session(config))
  179. }
  180. func (n nginxLogIndexDo) Clauses(conds ...clause.Expression) *nginxLogIndexDo {
  181. return n.withDO(n.DO.Clauses(conds...))
  182. }
  183. func (n nginxLogIndexDo) Returning(value interface{}, columns ...string) *nginxLogIndexDo {
  184. return n.withDO(n.DO.Returning(value, columns...))
  185. }
  186. func (n nginxLogIndexDo) Not(conds ...gen.Condition) *nginxLogIndexDo {
  187. return n.withDO(n.DO.Not(conds...))
  188. }
  189. func (n nginxLogIndexDo) Or(conds ...gen.Condition) *nginxLogIndexDo {
  190. return n.withDO(n.DO.Or(conds...))
  191. }
  192. func (n nginxLogIndexDo) Select(conds ...field.Expr) *nginxLogIndexDo {
  193. return n.withDO(n.DO.Select(conds...))
  194. }
  195. func (n nginxLogIndexDo) Where(conds ...gen.Condition) *nginxLogIndexDo {
  196. return n.withDO(n.DO.Where(conds...))
  197. }
  198. func (n nginxLogIndexDo) Order(conds ...field.Expr) *nginxLogIndexDo {
  199. return n.withDO(n.DO.Order(conds...))
  200. }
  201. func (n nginxLogIndexDo) Distinct(cols ...field.Expr) *nginxLogIndexDo {
  202. return n.withDO(n.DO.Distinct(cols...))
  203. }
  204. func (n nginxLogIndexDo) Omit(cols ...field.Expr) *nginxLogIndexDo {
  205. return n.withDO(n.DO.Omit(cols...))
  206. }
  207. func (n nginxLogIndexDo) Join(table schema.Tabler, on ...field.Expr) *nginxLogIndexDo {
  208. return n.withDO(n.DO.Join(table, on...))
  209. }
  210. func (n nginxLogIndexDo) LeftJoin(table schema.Tabler, on ...field.Expr) *nginxLogIndexDo {
  211. return n.withDO(n.DO.LeftJoin(table, on...))
  212. }
  213. func (n nginxLogIndexDo) RightJoin(table schema.Tabler, on ...field.Expr) *nginxLogIndexDo {
  214. return n.withDO(n.DO.RightJoin(table, on...))
  215. }
  216. func (n nginxLogIndexDo) Group(cols ...field.Expr) *nginxLogIndexDo {
  217. return n.withDO(n.DO.Group(cols...))
  218. }
  219. func (n nginxLogIndexDo) Having(conds ...gen.Condition) *nginxLogIndexDo {
  220. return n.withDO(n.DO.Having(conds...))
  221. }
  222. func (n nginxLogIndexDo) Limit(limit int) *nginxLogIndexDo {
  223. return n.withDO(n.DO.Limit(limit))
  224. }
  225. func (n nginxLogIndexDo) Offset(offset int) *nginxLogIndexDo {
  226. return n.withDO(n.DO.Offset(offset))
  227. }
  228. func (n nginxLogIndexDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *nginxLogIndexDo {
  229. return n.withDO(n.DO.Scopes(funcs...))
  230. }
  231. func (n nginxLogIndexDo) Unscoped() *nginxLogIndexDo {
  232. return n.withDO(n.DO.Unscoped())
  233. }
  234. func (n nginxLogIndexDo) Create(values ...*model.NginxLogIndex) error {
  235. if len(values) == 0 {
  236. return nil
  237. }
  238. return n.DO.Create(values)
  239. }
  240. func (n nginxLogIndexDo) CreateInBatches(values []*model.NginxLogIndex, batchSize int) error {
  241. return n.DO.CreateInBatches(values, batchSize)
  242. }
  243. // Save : !!! underlying implementation is different with GORM
  244. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  245. func (n nginxLogIndexDo) Save(values ...*model.NginxLogIndex) error {
  246. if len(values) == 0 {
  247. return nil
  248. }
  249. return n.DO.Save(values)
  250. }
  251. func (n nginxLogIndexDo) First() (*model.NginxLogIndex, error) {
  252. if result, err := n.DO.First(); err != nil {
  253. return nil, err
  254. } else {
  255. return result.(*model.NginxLogIndex), nil
  256. }
  257. }
  258. func (n nginxLogIndexDo) Take() (*model.NginxLogIndex, error) {
  259. if result, err := n.DO.Take(); err != nil {
  260. return nil, err
  261. } else {
  262. return result.(*model.NginxLogIndex), nil
  263. }
  264. }
  265. func (n nginxLogIndexDo) Last() (*model.NginxLogIndex, error) {
  266. if result, err := n.DO.Last(); err != nil {
  267. return nil, err
  268. } else {
  269. return result.(*model.NginxLogIndex), nil
  270. }
  271. }
  272. func (n nginxLogIndexDo) Find() ([]*model.NginxLogIndex, error) {
  273. result, err := n.DO.Find()
  274. return result.([]*model.NginxLogIndex), err
  275. }
  276. func (n nginxLogIndexDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.NginxLogIndex, err error) {
  277. buf := make([]*model.NginxLogIndex, 0, batchSize)
  278. err = n.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  279. defer func() { results = append(results, buf...) }()
  280. return fc(tx, batch)
  281. })
  282. return results, err
  283. }
  284. func (n nginxLogIndexDo) FindInBatches(result *[]*model.NginxLogIndex, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  285. return n.DO.FindInBatches(result, batchSize, fc)
  286. }
  287. func (n nginxLogIndexDo) Attrs(attrs ...field.AssignExpr) *nginxLogIndexDo {
  288. return n.withDO(n.DO.Attrs(attrs...))
  289. }
  290. func (n nginxLogIndexDo) Assign(attrs ...field.AssignExpr) *nginxLogIndexDo {
  291. return n.withDO(n.DO.Assign(attrs...))
  292. }
  293. func (n nginxLogIndexDo) Joins(fields ...field.RelationField) *nginxLogIndexDo {
  294. for _, _f := range fields {
  295. n = *n.withDO(n.DO.Joins(_f))
  296. }
  297. return &n
  298. }
  299. func (n nginxLogIndexDo) Preload(fields ...field.RelationField) *nginxLogIndexDo {
  300. for _, _f := range fields {
  301. n = *n.withDO(n.DO.Preload(_f))
  302. }
  303. return &n
  304. }
  305. func (n nginxLogIndexDo) FirstOrInit() (*model.NginxLogIndex, error) {
  306. if result, err := n.DO.FirstOrInit(); err != nil {
  307. return nil, err
  308. } else {
  309. return result.(*model.NginxLogIndex), nil
  310. }
  311. }
  312. func (n nginxLogIndexDo) FirstOrCreate() (*model.NginxLogIndex, error) {
  313. if result, err := n.DO.FirstOrCreate(); err != nil {
  314. return nil, err
  315. } else {
  316. return result.(*model.NginxLogIndex), nil
  317. }
  318. }
  319. func (n nginxLogIndexDo) FindByPage(offset int, limit int) (result []*model.NginxLogIndex, count int64, err error) {
  320. result, err = n.Offset(offset).Limit(limit).Find()
  321. if err != nil {
  322. return
  323. }
  324. if size := len(result); 0 < limit && 0 < size && size < limit {
  325. count = int64(size + offset)
  326. return
  327. }
  328. count, err = n.Offset(-1).Limit(-1).Count()
  329. return
  330. }
  331. func (n nginxLogIndexDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  332. count, err = n.Count()
  333. if err != nil {
  334. return
  335. }
  336. err = n.Offset(offset).Limit(limit).Scan(result)
  337. return
  338. }
  339. func (n nginxLogIndexDo) Scan(result interface{}) (err error) {
  340. return n.DO.Scan(result)
  341. }
  342. func (n nginxLogIndexDo) Delete(models ...*model.NginxLogIndex) (result gen.ResultInfo, err error) {
  343. return n.DO.Delete(models)
  344. }
  345. func (n *nginxLogIndexDo) withDO(do gen.Dao) *nginxLogIndexDo {
  346. n.DO = *do.(*gen.DO)
  347. return n
  348. }