12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package service
- import (
- "iot_manager_service/app/record/dao"
- "iot_manager_service/app/record/edge_service"
- )
- var AKeyAlarmRecordService = new(aKeyAlarmRecordService)
- type aKeyAlarmRecordService struct{}
- func (s aKeyAlarmRecordService) List(searchValue string, start string, end string, id int, current int, size int) ([]dao.AkeyAlarmRecord, error) {
- var record dao.AkeyAlarmRecord
- offset := (current - 1) * size
- limit := size
- records, err := record.GetRecords(offset, limit, start, end, searchValue, id)
- if err != nil {
- return nil, err
- }
- return records, nil
- }
- func (s aKeyAlarmRecordService) Detail(id int) (*dao.AkeyAlarmRecord, error) {
- record := &dao.AkeyAlarmRecord{
- ID: id,
- }
- return record.Get()
- }
- func (s aKeyAlarmRecordService) Refresh() {
- // TODO:边缘数据
- up := edge_service.RecordAlarmSos{}
- maxId, maxUpDateTime := dao.AkeyAlarmRecord{}.GetMaxIdAndUpDateTime()
- recordLightUpDatas, err := up.SyncRecord(maxId, maxUpDateTime)
- dao.AkeyAlarmRecord{}.BatchCreate(recordLightUpDatas)
- if err != nil {
- return
- }
- }
- func (s aKeyAlarmRecordService) UpdateRemark(id int, remark string) error {
- record := dao.AkeyAlarmRecord{ID: id}
- record.Remark = remark
- err := record.Update()
- if err != nil {
- return err
- }
- return nil
- }
|