video.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package model
  4. import (
  5. "github.com/jinzhu/gorm"
  6. "time"
  7. )
  8. type Vssdevtbl struct {
  9. Id int64 `gorm:"column:ID" json:"id" form:"id"`
  10. Devpubid string `gorm:"column:DevPubID" json:"devpubid" form:"devpubid"`
  11. Devnickname string `gorm:"column:DevNickname" json:"devnickname" form:"devnickname"`
  12. Username string `gorm:"column:UserName" json:"username" form:"username"`
  13. Passwd string `gorm:"column:Passwd" json:"passwd" form:"passwd"`
  14. Corpid string `gorm:"column:CorpID" json:"corpid" form:"corpid"`
  15. Ip string `gorm:"column:IP" json:"ip" form:"ip"`
  16. Port int64 `gorm:"column:Port" json:"port" form:"port"`
  17. Alive int64 `gorm:"column:Alive" json:"alive" form:"alive"`
  18. Subcatalogtime int64 `gorm:"column:SubCatalogTime" json:"subcatalogtime" form:"subcatalogtime"`
  19. Devmode string `gorm:"column:DevMode" json:"devmode" form:"devmode"`
  20. Mediatransport string `gorm:"column:MediaTransport" json:"mediatransport" form:"mediatransport"`
  21. Dmarker int64 `gorm:"column:DMarker" json:"dmarker" form:"dmarker"`
  22. UpdateTime time.Time `gorm:"column:updatetime" json:"updatetime" form:"updatetime"`
  23. ChannelCount int
  24. }
  25. func (Vssdevtbl) TableName() string {
  26. return "VSSDevTbl"
  27. }
  28. func (p *Vssdevtbl) Insert(db *gorm.DB) error {
  29. return db.Create(p).Error
  30. }
  31. func (p *Vssdevtbl) Del(db *gorm.DB, where map[string]interface{}) error {
  32. cond, val, err := whereBuild(where)
  33. if err != nil {
  34. return err
  35. }
  36. return db.Table(p.TableName()).Where(cond, val...).Delete(p).Error
  37. }
  38. func (p *Vssdevtbl) Find(db *gorm.DB, where map[string]interface{}) error {
  39. cond, val, err := whereBuild(where)
  40. if err != nil {
  41. return err
  42. }
  43. return db.Table(p.TableName()).Where(cond, val...).First(p).Error
  44. }
  45. func (p *Vssdevtbl) Update(db *gorm.DB, where map[string]interface{}, values map[string]interface{}) error {
  46. cond, val, err := whereBuild(where)
  47. if err != nil {
  48. return err
  49. }
  50. return db.Table(p.TableName()).Where(cond, val...).Updates(values).Error
  51. }
  52. func (p *Vssdevtbl) FindSort(db *gorm.DB, where map[string]interface{}, sort string) error {
  53. cond, val, err := whereBuild(where)
  54. if err != nil {
  55. return err
  56. }
  57. ps := []Vssdevtbl{}
  58. err = db.Table(p.TableName()).Where(cond, val...).Order(sort).Limit(1).Find(&ps).Error
  59. if err != nil {
  60. return err
  61. }
  62. if len(ps) > 0 {
  63. *p = ps[0]
  64. }
  65. return nil
  66. }
  67. func (p *Vssdevtbl) Save(db *gorm.DB) error {
  68. return db.Save(p).Error
  69. }
  70. func (p *Vssdevtbl) Count(db *gorm.DB, where map[string]interface{}) (int64, error) {
  71. if len(where) > 0 {
  72. cond, val, err := whereBuild(where)
  73. if err != nil {
  74. return 0, err
  75. }
  76. ret := int64(0)
  77. err = db.Table(p.TableName()).Where(cond, val...).Count(&ret).Error
  78. return ret, err
  79. }
  80. ret := int64(0)
  81. err := db.Table(p.TableName()).Count(&ret).Error
  82. return ret, err
  83. }
  84. func (p *Vssdevtbl) List(db *gorm.DB, where map[string]interface{}, page int) (list []Vssdevtbl, err error) {
  85. offset := (int32(page) - 1) *PageSize
  86. if len(where) > 0 {
  87. cond, val, err := whereBuild(where)
  88. if err != nil {
  89. return list, err
  90. }
  91. result := db.Table(p.TableName()).Where(cond, val...).Limit(PageSize).Offset(offset).Find(&list)
  92. return list, result.Error
  93. }
  94. result := db.Table(p.TableName()).Limit(PageSize).Offset(offset).Find(&list)
  95. return list, result.Error
  96. }
  97. type Vsschanneltbl struct {
  98. ID int64 `gorm:"column:ID"`
  99. Devpubid string `gorm:"column:DevPubID"`
  100. Restype int64 `gorm:"column:ResType"`
  101. Nickname string `gorm:"column:Nickname"`
  102. Chanpubid string `gorm:"column:ChanPubID"`
  103. Alive int64 `gorm:"column:Alive"`
  104. Corpid string `gorm:"column:CorpID"`
  105. Model string `gorm:"column:Model"`
  106. Owner string `gorm:"column:Owner"`
  107. Civilcode string `gorm:"column:CivilCode"`
  108. Address string `gorm:"column:Address"`
  109. Parental int64 `gorm:"column:Parental"`
  110. Parentid string `gorm:"column:ParentId"`
  111. Ip string `gorm:"column:IP"`
  112. Port int64 `gorm:"column:Port"`
  113. Longitude float64 `gorm:"column:Longitude"`
  114. Latitude float64 `gorm:"column:Latitude"`
  115. Altitude float64 `gorm:"column:Altitude"`
  116. Ptztype int64 `gorm:"column:PTZType"`
  117. Roomtype int64 `gorm:"column:RoomType"`
  118. Directiontype int64 `gorm:"column:DirectionType"`
  119. Streamtype int64 `gorm:"column:StreamType"`
  120. Chanrtspurl string `gorm:"column:ChanRtspUrl"`
  121. Realrtspurl string `gorm:"column:RealRtspUrl"`
  122. Dmarker int64 `gorm:"column:DMarker"`
  123. Updatetime time.Time `gorm:"column:UpdateTime"`
  124. }
  125. func (Vsschanneltbl) TableName() string {
  126. return "VSSChannelTbl"
  127. }
  128. func (p *Vsschanneltbl) Insert(db *gorm.DB) error {
  129. return db.Create(p).Error
  130. }
  131. func (p *Vsschanneltbl) Del(db *gorm.DB, where map[string]interface{}) error {
  132. cond, val, err := whereBuild(where)
  133. if err != nil {
  134. return err
  135. }
  136. return db.Table(p.TableName()).Where(cond, val...).Delete(p).Error
  137. }
  138. func (p *Vsschanneltbl) Find(db *gorm.DB, where map[string]interface{}) error {
  139. cond, val, err := whereBuild(where)
  140. if err != nil {
  141. return err
  142. }
  143. return db.Table(p.TableName()).Where(cond, val...).First(p).Error
  144. }
  145. func (p *Vsschanneltbl) Update(db *gorm.DB, where map[string]interface{}, values map[string]interface{}) error {
  146. cond, val, err := whereBuild(where)
  147. if err != nil {
  148. return err
  149. }
  150. return db.Table(p.TableName()).Where(cond, val...).Updates(values).Error
  151. }
  152. func (p *Vsschanneltbl) Save(db *gorm.DB) error {
  153. return db.Save(p).Error
  154. }
  155. func (p *Vsschanneltbl) Count(db *gorm.DB, where map[string]interface{}) (int64, error) {
  156. if len(where) > 0 {
  157. cond, val, err := whereBuild(where)
  158. if err != nil {
  159. return 0, err
  160. }
  161. ret := int64(0)
  162. err = db.Table(p.TableName()).Where(cond, val...).Count(&ret).Error
  163. return ret, err
  164. }
  165. ret := int64(0)
  166. err := db.Table(p.TableName()).Count(&ret).Error
  167. return ret, err
  168. }
  169. func (p *Vsschanneltbl) List(db *gorm.DB, where map[string]interface{}, page int32) (list []Vsschanneltbl, err error) {
  170. offset := (page - 1) *PageSize
  171. if len(where) > 0 {
  172. cond, val, err := whereBuild(where)
  173. if err != nil {
  174. return list, err
  175. }
  176. result := db.Table(p.TableName()).Where(cond, val...).Limit(PageSize).Offset(offset).Find(&list)
  177. return list, result.Error
  178. }
  179. result := db.Table(p.TableName()).Limit(PageSize).Offset(offset).Find(&list)
  180. return list, result.Error
  181. }