123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package dao
- import (
- "time"
- )
- type CaptureUint struct {
- ID int `gorm:"primary_key" json:"id"`
- CaptureName string `gorm:"type:varchar(64)" json:"captureName"`
- CaptureSN string `gorm:"type:varchar(60)" json:"captureSn"`
- PointId int `gorm:"type:int" json:"pointId"`
- LampPoleId int `gorm:"type:int" json:"lampPoleId"`
- WayName string `gorm:"type:varchar(64)" json:"wayName"`
- CaptureDirection int `gorm:"type:int" json:"captureDirection"`
- InstallTime time.Time `gorm:"type:date" json:"installTime"`
- TerrainClearance float32 `gorm:"type:float(10,1);default 0.0" json:"terrainClearance"`
- CaptureLane string `gorm:"type:varchar(120)" json:"captureLane"`
- VidiconPixel int `gorm:"type:int" json:"vidiconPixel"`
- VidiconSpecification string `gorm:"type:varchar(255)" json:"vidiconSpecification"`
- RadarCount int `gorm:"type:int" json:"radarCount"`
- RadarSpecification string `gorm:"type:varchar(255)" json:"radar_specification"`
- SuggestSpeed int `gorm:"type:int" json:"suggestSpeed"`
- FillLightCount int `gorm:"type:int" json:"fillLightCount"`
- FillLightSpecification string `gorm:"type:varchar(255)" json:"fillLightSpecification"`
- PowerSpecification string `gorm:"type:varchar(255)" json:"powerSpecification"`
- CaptureIp string `gorm:"type:varchar(60)" json:"captureIp"`
- CapturePort int `gorm:"type:int" json:"capturePort"`
- GatewayId int `gorm:"type:int" json:"gatewayId"`
- GatewayName string `gorm:"type:varchar(80)" json:"gatewayName"`
- GatewaySN string `gorm:"type:varchar(30)" json:"gatewaySn"`
- TenantId string `gorm:"type:varchar(12)" json:"tenantId"`
- CreateTime time.Time `gorm:"type:datetime" json:"createTime"`
- CreateUser string `gorm:"type:varchar(30)" json:"createUser"`
- UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"`
- UpdateUser string `gorm:"type:varchar(30)" json:"updateUser"`
- IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"`
- }
- func (CaptureUint) TableName() string {
- return "t_dev_capture_uint"
- }
- func (c CaptureUint) IsExistedBySN() bool {
- var count = 0
- _ = Db.Model(&c).Where("capture_sn = ? and is_deleted = ?",
- c.CaptureSN, c.IsDeleted).Count(&count).Error
- return count > 0
- }
- func (c *CaptureUint) Create() error {
- return Db.Model(&c).Save(&c).Error
- }
- func (c *CaptureUint) Update() error {
- return Db.Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
- }
- func (c *CaptureUint) GetDevice() error {
- err := Db.Model(&c).Where(" id = ? ", c.ID).First(&c).Error
- return err
- }
- func (c CaptureUint) GetDevices(offset, limit int) ([]CaptureUint, error) {
- var Captures []CaptureUint
- db := Db.Model(&c)
- if c.CaptureSN != "" {
- db = db.Where("capture_name like ? or capture_sn like ?", "%"+c.CaptureSN+"%", "%"+c.CaptureSN+"%")
- }
- err := db.Where("is_deleted = 0").Offset(offset).Limit(limit).Find(&Captures).Error
- return Captures, err
- }
- func (c *CaptureUint) Delete() error {
- return Db.Model(&c).Where("id = ?", c.ID).Updates(map[string]interface{}{"update_time": c.UpdateTime,
- "update_user": c.UpdateUser, "is_deleted": c.IsDeleted}).Error
- }
- func (c CaptureUint) GetAllDevices() ([]*CaptureUint, error) {
- var Captures []*CaptureUint
- err := Db.Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&Captures).Error
- return Captures, err
- }
|