123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package dao
- import (
- "iot_manager_service/app/data/dao"
- "iot_manager_service/util/common"
- )
- // ManholeCoverDao 井盖数据
- type ManholeCoverDao struct {
- ID int `gorm:"primary_key" json:"id"` //编号
- DeviceId int `json:"deviceId"` //设备id
- CSQ int `json:"CSQ"` //信号
- LeanAngle int `json:"lean_angle"` //倾斜角度
- Temperature float64 `json:"temperature"` //温度
- BatteryLevel float64 `json:"battery_level"` //电压
- IMEI string `json:"IMEI"`
- ICCID string `json:"ICCID"`
- PostTime common.Time `gorm:"type:datetime" json:"postTime"` //采集时间
- CreateDate string `gorm:"type:varchar(50)" json:"createDate"` //显示时间 日期
- }
- func (ManholeCoverDao) TableName() string {
- return "manhole_cover_record"
- }
- func (c *ManholeCoverDao) Save() error {
- return dao.Db.Model(&c).Create(&c).Error
- }
- func (c *ManholeCoverDao) BatchSave(data []ManholeCoverDao) error {
- return dao.Db.Model(&c).Create(&data).Error
- }
- func (c *ManholeCoverDao) Get() error {
- return dao.Db.Model(&c).Where("device_id = ?", c.DeviceId).Order("id desc").Find(&c).Error
- }
- func (c *ManholeCoverDao) GetList(start, end string) ([]ManholeCoverDao, error) {
- var record []ManholeCoverDao
- err := dao.Db.Where("device_id = ? and create_date>=? and create_date<=?", c.DeviceId, start, end).Find(&record).Error
- if err != nil {
- return nil, err
- }
- return record, nil
- }
|