package com.YuyeTech.TPlat.controller;

import com.YuyeTech.TPlat.VO.ResultVO;
import com.YuyeTech.TPlat.dataobject.OtaInfo;
import com.YuyeTech.TPlat.service.OtaInfoService;
import com.YuyeTech.TPlat.utils.ResultVOUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

import static com.YuyeTech.TPlat.enums.ResultEnum.NO_OTA;

/**
 * @author:slambb
 * @date:2020/1/10
 */
@RestController
@RequestMapping("/OTA")
@Slf4j
public class OtaController {

    @Autowired
    private OtaInfoService otaInfoService;
    /**
     * 获取游戏分类
     * @return
     */
    @GetMapping("/get_ota")
    public ResultVO getFcCategoryByType(@RequestParam(value = "bleType", required = false) Integer bleType){
        OtaInfo ota =  otaInfoService.findOTAByBLETypeAndStatus(bleType,1);
        if(ota == null){
            return ResultVOUtil.error(NO_OTA.getCode(), NO_OTA.getMessage());

        }
        Map otaMap = new HashMap();
        otaMap.put("otaName",ota.getOtaName());
        otaMap.put("bleName",ota.getBleName());
        otaMap.put("otaDownload",ota.getOtaDownload());
        return ResultVOUtil.success(otaMap);
    }

}
