package com.zksy.pole.factory.impl;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zksy.pole.domain.po.DgGatewayStrategy;
import com.zksy.pole.domain.po.DgLampControlledHeartbeat;
import com.zksy.pole.factory.IHandleCmd;
import com.zksy.pole.mapper.DgGatewayStrategyMapper;
import com.zksy.pole.mapper.DgLampControlledHeartbeatMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class HandleDgLampControlledHeartbeatCmd implements IHandleCmd {
    @Autowired
    private DgLampControlledHeartbeatMapper dgLampControlledHeartbeatMapper;
    @Override
    public <T> String HandleCmdMethod(T data) {
        JSONObject obj = JSONUtil.createObj();
        obj.set("cmd",6010);
        obj.set("heard_id",1010);
        try {
            DgLampControlledHeartbeat d = (DgLampControlledHeartbeat) data;
            dgLampControlledHeartbeatMapper.insert(d);
            return obj.toString();
        } catch (Exception e) {
            log.error("DgLampControlledHeartbeat数据插入失败");
            return obj.toString();
        }
    }
}