123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package dao
- import (
- "time"
- )
- //CaptureUint 抓拍单元
- 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"` //卡口ID
- LampPoleId int `gorm:"type:int" json:"lampPoleId"` //灯杆ID
- WayName string `gorm:"type:varchar(64)" json:"wayName"` //道路名称
- CaptureDirection int `gorm:"type:int" json:"captureDirection"` //灯杆sn
- 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"` //ip
- CapturePort int `gorm:"type:int" json:"capturePort"` //端口
- GatewayId int `gorm:"type:int" json:"gatewayId"` //网关ID
- GatewayName string `gorm:"type:varchar(80)" json:"gatewayName"` //网关名称
- GatewaySN string `gorm:"type:varchar(30)" json:"gatewaySn"` //网关编码
- TenantId string `gorm:"type:varchar(12)" json:"tenantId"` //租户ID
- CreateTime time.Time `gorm:"type:datetime" json:"createTime"` //新增时间
- CreateUser string `gorm:"type:varchar(30)" json:"createUser"` //新增记录操作用户ID
- 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"` //是否删除 0=未删除,1=删除
- }
- func (CaptureUint) TableName() string {
- return "t_dev_capture_uint"
- }
- func (c CaptureUint) IsExistedBySN() bool {
- var count = 0
- _ = Db.Debug().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.Debug().Model(&c).Save(&c).Error
- }
- func (c *CaptureUint) Update() error {
- return Db.Debug().Model(&c).Where(" id = ? ", c.ID).Update(&c).Error
- }
- func (c *CaptureUint) GetDevice() error {
- err := Db.Debug().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.Debug().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.Debug().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.Debug().Model(&c).Where(" tenant_id = ? and is_deleted = ? ", c.TenantId, c.IsDeleted).Scan(&Captures).Error
- return Captures, err
- }
|