aKeyAlarmRecordService.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package service
  2. import (
  3. "iot_manager_service/app/record/dao"
  4. "iot_manager_service/app/record/edge_service"
  5. )
  6. var AKeyAlarmRecordService = new(aKeyAlarmRecordService)
  7. type aKeyAlarmRecordService struct{}
  8. func (s aKeyAlarmRecordService) List(searchValue string, start string, end string, id int, current int, size int) ([]dao.AkeyAlarmRecord, error) {
  9. var record dao.AkeyAlarmRecord
  10. offset := (current - 1) * size
  11. limit := size
  12. records, err := record.GetRecords(offset, limit, start, end, searchValue, id)
  13. if err != nil {
  14. return nil, err
  15. }
  16. return records, nil
  17. }
  18. func (s aKeyAlarmRecordService) Detail(id int) (*dao.AkeyAlarmRecord, error) {
  19. record := &dao.AkeyAlarmRecord{
  20. ID: id,
  21. }
  22. return record.Get()
  23. }
  24. func (s aKeyAlarmRecordService) Refresh() {
  25. // TODO:边缘数据
  26. up := edge_service.RecordAlarmSos{}
  27. maxId, maxUpDateTime := dao.AkeyAlarmRecord{}.GetMaxIdAndUpDateTime()
  28. recordLightUpDatas, err := up.SyncRecord(maxId, maxUpDateTime)
  29. dao.AkeyAlarmRecord{}.BatchCreate(recordLightUpDatas)
  30. if err != nil {
  31. return
  32. }
  33. }
  34. func (s aKeyAlarmRecordService) UpdateRemark(id int, remark string) error {
  35. record := dao.AkeyAlarmRecord{ID: id}
  36. record.Remark = remark
  37. err := record.Update()
  38. if err != nil {
  39. return err
  40. }
  41. return nil
  42. }