package com.corewing.app.modules.app;

import com.corewing.app.common.Result;
import com.corewing.app.common.annotation.CommonLog;
import com.corewing.app.dto.publicFirmware.PublicBoardTypeListRequest;
import com.corewing.app.dto.publicFirmware.PublicFirmwareListRequest;
import com.corewing.app.dto.publicFirmware.PublicFirmwareVersionListRequest;
import com.corewing.app.entity.AppPublicFirmwarePlane;
import com.corewing.app.entity.AppPublicFirmwareVersion;
import com.corewing.app.entity.BizDict;
import com.corewing.app.service.AppPublicFirmwarePlaneService;
import com.corewing.app.service.AppPublicFirmwareVersionService;
import com.corewing.app.service.BizDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "公共固件接口")
@RestController
@RequestMapping("/public_firmware")
public class AppPublicFirmwareController {

    @Resource
    private BizDictService bizDictService;

    @Resource
    private AppPublicFirmwareVersionService appPublicFirmwareVersionService;

    @Resource
    private AppPublicFirmwarePlaneService appPublicFirmwarePlaneService;

    @CommonLog("获取固件类型集合")
    @ApiOperation("获取固件类型集合")
    @GetMapping("/getFirmwareTypeAll")
    public Result<List<BizDict>> getFirmwareTypeAll() {
        return Result.success(bizDictService.getDataListByKey());
    }

    @CommonLog("根据固件类型获取版本集合")
    @ApiOperation("根据固件类型获取版本集合")
    @GetMapping("/getVersionList")
    public Result<List<AppPublicFirmwareVersion>> getVersionList(PublicFirmwareVersionListRequest publicFirmwareVersionListRequest) {
        return Result.success(appPublicFirmwareVersionService.getVersionList(publicFirmwareVersionListRequest));
    }

    @CommonLog("根据固件类型&版本获取板载类型集合")
    @ApiOperation("根据固件类型&版本获取板载类型集合")
    @GetMapping("/getBoardTypeList")
    public Result<List<String>> getBoardTypeList(PublicBoardTypeListRequest publicBoardTypeListRequest) {
        return Result.success(appPublicFirmwarePlaneService.getBoardTypeList(publicBoardTypeListRequest));
    }

    @CommonLog("根据固件类型&版本&板载获取固件集合")
    @ApiOperation("根据固件类型&版本&板载获取固件集合")
    @GetMapping("/getFirmwareList")
    public Result<List<AppPublicFirmwarePlane>> getFirmwareList(PublicFirmwareListRequest publicFirmwareListRequest) {
        return Result.success(appPublicFirmwarePlaneService.getFirmwareList(publicFirmwareListRequest));
    }






}
