timeConditionDao.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import "time"
  3. type TimeCondition struct {
  4. ID int `gorm:"primary key" json:"id"` //编号
  5. LightId int `gorm:"type: int" json:"lightId"` //照明策略id
  6. StartTime string `gorm:"type:time" json:"startTime"` //开始时间
  7. EndTime string `gorm:"type:time" json:"endTime"` //结束时间
  8. Luminance int `gorm:"type:int " json:"luminance"` //开灯亮度
  9. Remark string `gorm:"type:varchar(255)" json:"remark"` //备注
  10. CreateTime time.Time `gorm:"type:datetime" json:"createTime"` //新增时间
  11. CreateUser string `gorm:"type:varchar(60)" json:"createUser"` //新增记录操作用户ID
  12. UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"` //修改时间
  13. UpdateUser string `gorm:"type:varchar(60)" json:"updateUser"` //修改用户
  14. IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
  15. Sunshine int `gorm:"type:int;default 1" json:"sunshine"` //日出日落 设置 2=开启,1=不开启
  16. }
  17. func (TimeCondition) TableName() string {
  18. return "t_strategy_time_condition"
  19. }
  20. func (c *TimeCondition) Get() error {
  21. return Db.Model(&c).Where("id = ?", c.ID).Find(&c).Error
  22. }
  23. func (c *TimeCondition) BatchGet(ids []int) ([]TimeCondition, error) {
  24. var conditions []TimeCondition
  25. err := Db.Model(&c).Where("id in ?", ids).Find(&conditions).Error
  26. return conditions, err
  27. }
  28. func (c *TimeCondition) GetByLightId() ([]TimeCondition, error) {
  29. var conditions []TimeCondition
  30. err := Db.Model(&c).Where("light_id = ?", c.LightId).Find(&conditions).Error
  31. return conditions, err
  32. }