package com.sptg.permissions.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.PageBean;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.permissions.api.dto.AppPackageDto;
import com.sptg.permissions.api.entity.AppPackage;
import com.sptg.permissions.api.feigns.fallback.AppPackageFallbackFactory;
import org.apache.ibatis.annotations.Param;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * title: AppPackageFeign
 * package: com.sptg.permissions.api.feigns
 * description:app安装包-对外服务接口
 *
 *
 *
 */
@FeignClient(value = "smart-house-permissions",fallbackFactory = AppPackageFallbackFactory.class)
public interface AppPackageFeign {

    /**
     * 功能描述:app安装包分页查询
     * @param pageBean
     * @return ResultBean<Page>
     *
     *
     */
    @PostMapping(value = "/appPackage/pagingQuery")
    ResultBean<Page> pagingQuery(@RequestBody PageBean<AppPackage, AppPackageDto> pageBean);

    /**
     * 功能描述:app安装包添加
     * @param dto
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/appPackage/add")
    ResultBean<Boolean> addEntity(@RequestBody AppPackageDto dto);

    /**
     * 功能描述:app安装包更新
     * @param dto
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/appPackage/edit")
    ResultBean<Boolean> editEntity(@RequestBody AppPackageDto dto);

    /**
     * 功能描述:根据id获取app安装包信息
     * @param id
     * @return ResultBean<AppPackage>
     *
     *
     */
    @GetMapping(value = "/appPackage/getEntity/{id}")
    AppPackage getEntity(@PathVariable(value = "id") Long id);

    /**
     * 功能描述:删除app安装包记录
     * @param dto
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/appPackage/delete")
    ResultBean<Boolean> deleteEntity(@RequestBody AppPackageDto dto);

    /**
     * 功能描述:更新app安装包启用状态
     * @param dto
     * @return ResultBean<Boolean>
     *
     *
     */
    @PostMapping(value = "/appPackage/updateEnable")
    ResultBean<Boolean> updateEnable(@RequestBody AppPackageDto dto);

    /**
     * 获取最新版本安装包
     * @param appPackage 查询条件
     * @return AppPackage
     */
    @PostMapping(value = "/appPackage/getNewestVersion")
    AppPackage getNewestVersion(@RequestBody AppPackage appPackage);

    /**
     * App检查更新
     * @param appPackage 查询条件
     * @return AppPackage
     */
    @PostMapping(value = "/appPackage/appPackageCheck")
    AppPackage appPackageCheck(@RequestBody AppPackage appPackage);

    @PostMapping(value = "/appPackage/getListByLikeVersion")
    ResultBean<AppPackage> getListByLikeVersion(@RequestBody AppPackageDto appPackageDto);

    /**
     * 根据型号和设备厂商获取升级包
     * @param model 设备型号
     * @param factory 设备厂商
     * @return
     */
    @PostMapping(value = "/appPackage/getListByModelAndFactory/{model}/{factory}")
    List<AppPackage> getListByModelAndFactory(@PathVariable(value = "model") String model,  @PathVariable(value = "factory") String factory);

    @GetMapping(value = "/appPackage/checkPackageNameIsExist")
    boolean checkPackageNameIsExist(@RequestParam("packageName") String packageName);

    @PostMapping(value = "/appPackage/setRestore")
    boolean setRestore(@RequestBody List<String> ids);

    @PostMapping(value = "/appPackage/getRestore/{model}/{factory}")
    AppPackage getRestore(@PathVariable(value = "model") String model, @PathVariable(value = "factory") String factory);

    @GetMapping(value = "/appPackage/checkVersionIsExist")
    boolean checkVersionIsExist(@RequestParam("version") String version);
}
