package com.fs.watch.service.impl;

import com.fs.watch.domain.WatchSosCallLogs;
import com.fs.watch.mapper.WatchSosCallLogsMapper;
import com.fs.watch.service.WatchSosCallLogsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * sos报警日志(WatchSosCallLogs)表服务实现类
 *
 * @author makejava
 * @since 2024-12-24 14:30:26
 */
@Service("watchSosCallLogsService")
@Slf4j
public class WatchSosCallLogsServiceImpl implements WatchSosCallLogsService {
    @Autowired
    private WatchSosCallLogsMapper mapper;




    /**
     * 新增数据
     *
     * @param data 实例对象
     * @return 实例对象
     */
    @Override
    public Boolean insert(WatchSosCallLogs data) {
        try {
            mapper.insert(data);
        } catch (Exception e) {
            log.error("===============watchSosCall:insert=========================={}", e.getMessage());
            return false;
        }
        return true;
    }

    @Override
    public Boolean batchInsertData(List<WatchSosCallLogs> list) {
        try {
            if (list.size() > 0) {
                mapper.batchInsertData(list);

            }
        } catch (Exception e) {
            log.error("===============watchSosCall:insert=========================={}", e.getMessage());
            return false;
        }
        return true;
    }

    private Map<String, Object> getSosCallMap(WatchSosCallLogs data) {
        Map<String, Object> params = new HashMap<>();
        params.put("id", data.getId());
        params.put("deviceId", data.getDeviceId());
        params.put("alarmTime", data.getAlarmTime());
        params.put("lat", data.getLat());
        params.put("lon", data.getLon());
        params.put("callLogs", data.getCallLogs());
        return params;
    }

}
