package service import ( "iot_manager_service/app/device/dao" "iot_manager_service/util/common" "time" ) // 灯控策略服务 var LightConditionService = new(lightConditionService) type lightConditionService struct{} func (s *lightConditionService) Get(id int) (*dao.LightCondition, *common.Errors) { // 创建查询实例 condition := &dao.LightCondition{ ID: id, } err := condition.Get() if err != nil { return nil, common.FailResponse(err.Error(), nil) } return condition, nil } func (s *lightConditionService) BatchGet(ids []int) []dao.LightCondition { // 创建查询实例 condition := &dao.LightCondition{} conditions, err := condition.BatchGet(ids) if err != nil { return nil } return conditions } func (s *lightConditionService) CreateOrUpdate(req dao.LightCondition) *common.Errors { return nil } func (s *lightConditionService) Remove(userId int, id int) *common.Errors { // 创建查询实例 device := &dao.Gateway{ ID: id, IsDeleted: 1, UpdateUser: userId, UpdateTime: time.Now(), } err := device.Delete() if err != nil { return common.FailResponse(err.Error(), nil) } return nil } func (s *lightConditionService) Save(conditions []dao.LightCondition, lightId int) error { condition := &dao.LightCondition{} return condition.Save(conditions, lightId) }