package cn.iocoder.yudao.module.system.controller.admin.device;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.service.watch.WatchDeviceService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;


@Tag(name = "手表回调地址控制层")
@RestController
@RequestMapping("/device/watchData")
public class WatchDeviceController {

    @Resource
    private WatchDeviceService watchDeviceService;

    @PostMapping("/watchDataCallBack")
    @PermitAll
    public CommonResult<Boolean> watchDataCallBack(@RequestBody JSONObject jsonObject) {
//        {
//            "imei":"xxxxxx",                 //设备号
//                "cmd":"CZW01",                   //标识
//                "pushTimestamp": 1670774400000,  //推送时间
//                "deviceModel": 1,                //设备型号 1：L16/L18/MF5（默认），2：GT3/MF6，3：MF3，4:Y001，5: MF2，6:MF9 7: TW-C1 12:MF12
//                "electric":100,                  //属性字段
//                "step":1000,                     //属性字段
//                "calories": 50                   //属性字段
//        }
        //开启异步处理业务
        watchDeviceService.asyncHandleWatchData(jsonObject);
        return success(true);
    }


}
