1234567891011121314151617181920212223242526272829303132333435363738 |
- package dao
- import "time"
- type LightCondition struct {
- ID int `gorm:"primary key" json:"id"` //编号
- LightId int `gorm:"type:int" json:"lightId"` //照明策略id
- ScopeStart int `gorm:"type:int" json:"scopeStart"` //光照度范围开始值
- ScopeEnd int `gorm:"type:int" json:"scopeEnd"` //光照度范围结束值
- Luminance int `gorm:"type:int " json:"luminance"` //开灯亮度
- Remark string `gorm:"type:varchar(255)" json:"remark"` //备注
- CreateTime time.Time `gorm:"type:datetime" json:"createTime"` //新增时间
- CreateUser int `gorm:"type:int" json:"createUser"` //新增记录操作用户ID
- UpdateTime time.Time `gorm:"type:datetime" json:"updateTime"` //修改时间
- UpdateUser int `gorm:"type:int" json:"updateUser"` //修改用户
- IsDeleted int `gorm:"type:int;default 0" json:"isDeleted"` //是否删除 0=未删除,1=删除
- }
- func (LightCondition) TableName() string {
- return "strategy_light_condition"
- }
- func (c *LightCondition) Get() error {
- return Db.Model(&c).Where("id = ?", c.ID).Find(&c).Error
- }
- func (c *LightCondition) BatchGet(ids []int) ([]LightCondition, error) {
- var conditions []LightCondition
- err := Db.Model(&c).Where("id in ?", ids).Find(&conditions).Error
- return conditions, err
- }
- func (c *LightCondition) Save(conditions []LightCondition, lightId int) error {
- for i, _ := range conditions {
- conditions[i].LightId = lightId
- }
- return Db.Model(&c).Save(&conditions).Error
- }
|