video_devinfo.gen.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 dao
  5. import (
  6. "context"
  7. "gorm.io/gorm"
  8. "gorm.io/gorm/clause"
  9. "gorm.io/gorm/schema"
  10. "gorm.io/gen"
  11. "gorm.io/gen/field"
  12. "gorm.io/plugin/dbresolver"
  13. "git.rtzhtech.cn/iss/public-lib/model"
  14. )
  15. func newVideoDevinfo(db *gorm.DB) videoDevinfo {
  16. _videoDevinfo := videoDevinfo{}
  17. _videoDevinfo.videoDevinfoDo.UseDB(db)
  18. _videoDevinfo.videoDevinfoDo.UseModel(&model.VideoDevinfo{})
  19. tableName := _videoDevinfo.videoDevinfoDo.TableName()
  20. _videoDevinfo.ALL = field.NewField(tableName, "*")
  21. _videoDevinfo.ID = field.NewInt32(tableName, "id")
  22. _videoDevinfo.Deviceid = field.NewInt32(tableName, "deviceid")
  23. _videoDevinfo.Devicename = field.NewString(tableName, "devicename")
  24. _videoDevinfo.Devicecode = field.NewInt32(tableName, "devicecode")
  25. _videoDevinfo.Stationid = field.NewInt32(tableName, "stationid")
  26. _videoDevinfo.Appid = field.NewInt32(tableName, "appid")
  27. _videoDevinfo.IP = field.NewString(tableName, "ip")
  28. _videoDevinfo.Manufacturer = field.NewString(tableName, "manufacturer")
  29. _videoDevinfo.Model = field.NewString(tableName, "model")
  30. _videoDevinfo.Rtspurl = field.NewString(tableName, "rtspurl")
  31. _videoDevinfo.Online = field.NewInt32(tableName, "online")
  32. _videoDevinfo.CreateAt = field.NewTime(tableName, "create_at")
  33. _videoDevinfo.UpdateAt = field.NewTime(tableName, "update_at")
  34. _videoDevinfo.fillFieldMap()
  35. _videoDevinfo.Base = newBase(tableName, db)
  36. return _videoDevinfo
  37. }
  38. type videoDevinfo struct {
  39. videoDevinfoDo
  40. ALL field.Field
  41. ID field.Int32
  42. Deviceid field.Int32
  43. Devicename field.String
  44. Devicecode field.Int32
  45. Stationid field.Int32
  46. Appid field.Int32
  47. IP field.String
  48. Manufacturer field.String
  49. Model field.String
  50. Rtspurl field.String
  51. Online field.Int32
  52. CreateAt field.Time
  53. UpdateAt field.Time
  54. fieldMap map[string]field.Expr
  55. }
  56. func (v videoDevinfo) Table(newTableName string) *videoDevinfo {
  57. v.videoDevinfoDo.UseTable(newTableName)
  58. return v.updateTableName(newTableName)
  59. }
  60. func (v videoDevinfo) As(alias string) *videoDevinfo {
  61. v.videoDevinfoDo.DO = *(v.videoDevinfoDo.As(alias).(*gen.DO))
  62. return v.updateTableName(alias)
  63. }
  64. func (v *videoDevinfo) updateTableName(table string) *videoDevinfo {
  65. v.ALL = field.NewField(table, "*")
  66. v.ID = field.NewInt32(table, "id")
  67. v.Deviceid = field.NewInt32(table, "deviceid")
  68. v.Devicename = field.NewString(table, "devicename")
  69. v.Devicecode = field.NewInt32(table, "devicecode")
  70. v.Stationid = field.NewInt32(table, "stationid")
  71. v.Appid = field.NewInt32(table, "appid")
  72. v.IP = field.NewString(table, "ip")
  73. v.Manufacturer = field.NewString(table, "manufacturer")
  74. v.Model = field.NewString(table, "model")
  75. v.Rtspurl = field.NewString(table, "rtspurl")
  76. v.Online = field.NewInt32(table, "online")
  77. v.CreateAt = field.NewTime(table, "create_at")
  78. v.UpdateAt = field.NewTime(table, "update_at")
  79. v.fillFieldMap()
  80. return v
  81. }
  82. func (v *videoDevinfo) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
  83. _f, ok := v.fieldMap[fieldName]
  84. if !ok || _f == nil {
  85. return nil, false
  86. }
  87. _oe, ok := _f.(field.OrderExpr)
  88. return _oe, ok
  89. }
  90. func (v *videoDevinfo) fillFieldMap() {
  91. v.fieldMap = make(map[string]field.Expr, 13)
  92. v.fieldMap["id"] = v.ID
  93. v.fieldMap["deviceid"] = v.Deviceid
  94. v.fieldMap["devicename"] = v.Devicename
  95. v.fieldMap["devicecode"] = v.Devicecode
  96. v.fieldMap["stationid"] = v.Stationid
  97. v.fieldMap["appid"] = v.Appid
  98. v.fieldMap["ip"] = v.IP
  99. v.fieldMap["manufacturer"] = v.Manufacturer
  100. v.fieldMap["model"] = v.Model
  101. v.fieldMap["rtspurl"] = v.Rtspurl
  102. v.fieldMap["online"] = v.Online
  103. v.fieldMap["create_at"] = v.CreateAt
  104. v.fieldMap["update_at"] = v.UpdateAt
  105. }
  106. func (v videoDevinfo) clone(db *gorm.DB) videoDevinfo {
  107. v.videoDevinfoDo.ReplaceDB(db)
  108. return v
  109. }
  110. type videoDevinfoDo struct {
  111. gen.DO
  112. Base *Base
  113. }
  114. func (v videoDevinfoDo) Debug() *videoDevinfoDo {
  115. return v.withDO(v.DO.Debug())
  116. }
  117. func (v videoDevinfoDo) WithContext(ctx context.Context) *videoDevinfoDo {
  118. return v.withDO(v.DO.WithContext(ctx))
  119. }
  120. func (v videoDevinfoDo) ReadDB() *videoDevinfoDo {
  121. return v.Clauses(dbresolver.Read)
  122. }
  123. func (v videoDevinfoDo) WriteDB() *videoDevinfoDo {
  124. return v.Clauses(dbresolver.Write)
  125. }
  126. func (v videoDevinfoDo) Clauses(conds ...clause.Expression) *videoDevinfoDo {
  127. return v.withDO(v.DO.Clauses(conds...))
  128. }
  129. func (v videoDevinfoDo) Returning(value interface{}, columns ...string) *videoDevinfoDo {
  130. return v.withDO(v.DO.Returning(value, columns...))
  131. }
  132. func (v videoDevinfoDo) Not(conds ...gen.Condition) *videoDevinfoDo {
  133. return v.withDO(v.DO.Not(conds...))
  134. }
  135. func (v videoDevinfoDo) Or(conds ...gen.Condition) *videoDevinfoDo {
  136. return v.withDO(v.DO.Or(conds...))
  137. }
  138. func (v videoDevinfoDo) Select(conds ...field.Expr) *videoDevinfoDo {
  139. return v.withDO(v.DO.Select(conds...))
  140. }
  141. func (v videoDevinfoDo) Where(conds ...gen.Condition) *videoDevinfoDo {
  142. return v.withDO(v.DO.Where(conds...))
  143. }
  144. func (v videoDevinfoDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) *videoDevinfoDo {
  145. return v.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB()))
  146. }
  147. func (v videoDevinfoDo) Order(conds ...field.Expr) *videoDevinfoDo {
  148. return v.withDO(v.DO.Order(conds...))
  149. }
  150. func (v videoDevinfoDo) Distinct(cols ...field.Expr) *videoDevinfoDo {
  151. return v.withDO(v.DO.Distinct(cols...))
  152. }
  153. func (v videoDevinfoDo) Omit(cols ...field.Expr) *videoDevinfoDo {
  154. return v.withDO(v.DO.Omit(cols...))
  155. }
  156. func (v videoDevinfoDo) Join(table schema.Tabler, on ...field.Expr) *videoDevinfoDo {
  157. return v.withDO(v.DO.Join(table, on...))
  158. }
  159. func (v videoDevinfoDo) LeftJoin(table schema.Tabler, on ...field.Expr) *videoDevinfoDo {
  160. return v.withDO(v.DO.LeftJoin(table, on...))
  161. }
  162. func (v videoDevinfoDo) RightJoin(table schema.Tabler, on ...field.Expr) *videoDevinfoDo {
  163. return v.withDO(v.DO.RightJoin(table, on...))
  164. }
  165. func (v videoDevinfoDo) Group(cols ...field.Expr) *videoDevinfoDo {
  166. return v.withDO(v.DO.Group(cols...))
  167. }
  168. func (v videoDevinfoDo) Having(conds ...gen.Condition) *videoDevinfoDo {
  169. return v.withDO(v.DO.Having(conds...))
  170. }
  171. func (v videoDevinfoDo) Limit(limit int) *videoDevinfoDo {
  172. return v.withDO(v.DO.Limit(limit))
  173. }
  174. func (v videoDevinfoDo) Offset(offset int) *videoDevinfoDo {
  175. return v.withDO(v.DO.Offset(offset))
  176. }
  177. func (v videoDevinfoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) *videoDevinfoDo {
  178. return v.withDO(v.DO.Scopes(funcs...))
  179. }
  180. func (v videoDevinfoDo) Unscoped() *videoDevinfoDo {
  181. return v.withDO(v.DO.Unscoped())
  182. }
  183. func (v videoDevinfoDo) Create(values ...*model.VideoDevinfo) error {
  184. if len(values) == 0 {
  185. return nil
  186. }
  187. return v.DO.Create(values)
  188. }
  189. func (v videoDevinfoDo) CreateInBatches(values []*model.VideoDevinfo, batchSize int) error {
  190. return v.DO.CreateInBatches(values, batchSize)
  191. }
  192. // Save : !!! underlying implementation is different with GORM
  193. // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values)
  194. func (v videoDevinfoDo) Save(values ...*model.VideoDevinfo) error {
  195. if len(values) == 0 {
  196. return nil
  197. }
  198. return v.DO.Save(values)
  199. }
  200. func (v videoDevinfoDo) First() (*model.VideoDevinfo, error) {
  201. if result, err := v.DO.First(); err != nil {
  202. return nil, err
  203. } else {
  204. return result.(*model.VideoDevinfo), nil
  205. }
  206. }
  207. func (v videoDevinfoDo) Take() (*model.VideoDevinfo, error) {
  208. if result, err := v.DO.Take(); err != nil {
  209. return nil, err
  210. } else {
  211. return result.(*model.VideoDevinfo), nil
  212. }
  213. }
  214. func (v videoDevinfoDo) Last() (*model.VideoDevinfo, error) {
  215. if result, err := v.DO.Last(); err != nil {
  216. return nil, err
  217. } else {
  218. return result.(*model.VideoDevinfo), nil
  219. }
  220. }
  221. func (v videoDevinfoDo) Find() ([]*model.VideoDevinfo, error) {
  222. result, err := v.DO.Find()
  223. return result.([]*model.VideoDevinfo), err
  224. }
  225. func (v videoDevinfoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.VideoDevinfo, err error) {
  226. buf := make([]*model.VideoDevinfo, 0, batchSize)
  227. err = v.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error {
  228. defer func() { results = append(results, buf...) }()
  229. return fc(tx, batch)
  230. })
  231. return results, err
  232. }
  233. func (v videoDevinfoDo) FindInBatches(result *[]*model.VideoDevinfo, batchSize int, fc func(tx gen.Dao, batch int) error) error {
  234. return v.DO.FindInBatches(result, batchSize, fc)
  235. }
  236. func (v videoDevinfoDo) Attrs(attrs ...field.AssignExpr) *videoDevinfoDo {
  237. return v.withDO(v.DO.Attrs(attrs...))
  238. }
  239. func (v videoDevinfoDo) Assign(attrs ...field.AssignExpr) *videoDevinfoDo {
  240. return v.withDO(v.DO.Assign(attrs...))
  241. }
  242. func (v videoDevinfoDo) Joins(fields ...field.RelationField) *videoDevinfoDo {
  243. for _, _f := range fields {
  244. v = *v.withDO(v.DO.Joins(_f))
  245. }
  246. return &v
  247. }
  248. func (v videoDevinfoDo) Preload(fields ...field.RelationField) *videoDevinfoDo {
  249. for _, _f := range fields {
  250. v = *v.withDO(v.DO.Preload(_f))
  251. }
  252. return &v
  253. }
  254. func (v videoDevinfoDo) FirstOrInit() (*model.VideoDevinfo, error) {
  255. if result, err := v.DO.FirstOrInit(); err != nil {
  256. return nil, err
  257. } else {
  258. return result.(*model.VideoDevinfo), nil
  259. }
  260. }
  261. func (v videoDevinfoDo) FirstOrCreate() (*model.VideoDevinfo, error) {
  262. if result, err := v.DO.FirstOrCreate(); err != nil {
  263. return nil, err
  264. } else {
  265. return result.(*model.VideoDevinfo), nil
  266. }
  267. }
  268. func (v videoDevinfoDo) FindByPage(offset int, limit int) (result []*model.VideoDevinfo, count int64, err error) {
  269. result, err = v.Offset(offset).Limit(limit).Find()
  270. if err != nil {
  271. return
  272. }
  273. if size := len(result); 0 < limit && 0 < size && size < limit {
  274. count = int64(size + offset)
  275. return
  276. }
  277. count, err = v.Offset(-1).Limit(-1).Count()
  278. return
  279. }
  280. func (v videoDevinfoDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) {
  281. count, err = v.Count()
  282. if err != nil {
  283. return
  284. }
  285. err = v.Offset(offset).Limit(limit).Scan(result)
  286. return
  287. }
  288. func (v videoDevinfoDo) Scan(result interface{}) (err error) {
  289. return v.DO.Scan(result)
  290. }
  291. func (v videoDevinfoDo) Delete(models ...*model.VideoDevinfo) (result gen.ResultInfo, err error) {
  292. return v.DO.Delete(models)
  293. }
  294. func (v *videoDevinfoDo) withDO(do gen.Dao) *videoDevinfoDo {
  295. v.DO = *do.(*gen.DO)
  296. return v
  297. }