package com.bonus.canteen.core.android.controller;

import cn.hutool.core.util.ObjectUtil;
import com.bonus.canteen.core.android.dto.AppDTO;
import com.bonus.canteen.core.android.service.DeviceService;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "android-双屏消费机-设备信息")
@RestController
@RequestMapping("/api/android/device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;



    @ApiOperation("获取设备信息")
    @RequestMapping("/getDeviceInfo")
    public AjaxResult getDeviceInfo(@RequestBody AppDTO dto) {
        if (ObjectUtil.isEmpty(dto.getDeviceSn())) {
            throw new ServiceException("设备sn不能为空");
        }
        return deviceService.getDeviceInfo(dto);
    }
    @ApiOperation("获取设备版本信息")
    @RequestMapping("/getAppVersion")
    public AjaxResult getAppVersion(@RequestBody AppDTO dto) {
        if (ObjectUtil.isEmpty(dto.getId())) {
            throw new ServiceException("Version不能为空");
        }
        return deviceService.getAppVersion(dto);
    }
}
