package com.sptg.device.api.feigns;

import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.device.api.dto.TimeStrategyPushTaskDto;
import com.sptg.device.api.entity.TimeStrategyPushTask;
import com.sptg.device.api.entity.TimeStrategyTaskDeviceDetails;
import com.sptg.device.api.feigns.fallback.TimeStrategyPushTaskFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * title: TimeStrategyPushTaskFeign
 * package: com.sptg.device.api.feigns
 * description:时间策略发布任务-对外服务接口
 */
@FeignClient(value = "smart-house-device",fallbackFactory = TimeStrategyPushTaskFallbackFactory.class )
public interface TimeStrategyPushTaskFeign {

    /**
     * 功能描述:分页查询时间策略发布任务
     * @param dto
     * @return  ResultBean<Page<TimeStrategyPushTask>>
     */
    @PostMapping(value = "/time/strategy/push/task/pagingQuery")
    ResultBean<Page<TimeStrategyPushTask>> pagingQuery(@RequestBody TimeStrategyPushTaskDto dto);

    /**
     * 功能描述:时间策略发布任务添加
     * @param dto
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/time/strategy/push/task/addEntity")
    ResultBean<Boolean> addEntity(@RequestBody TimeStrategyPushTaskDto dto);

    /**
     * 功能描述:获取时间策略发布任务信息
     * @param dto
     * @return TimeStrategyPushTask
     */
    @PostMapping(value = "/time/strategy/push/task/getEntityById")
    TimeStrategyPushTask getEntityById(@RequestBody TimeStrategyPushTaskDto dto);

    /**
     * 功能描述:获取时间策略详细外键id
     * @param taskId 任务id
     * @return List<Long>
     */
    @GetMapping(value = "/time/strategy/push/task/getFkIdListByTaskId/{taskId}")
    List<Long> getFkIdListByTaskId(@PathVariable(value = "taskId") Long taskId);

    /**
     * 功能描述:撤回任务
     * @param dto
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/time/strategy/push/task/rollback")
    ResultBean<Boolean> rollback(@RequestBody TimeStrategyPushTaskDto dto);

    /**
     * 修改策略任务下发的推送状态
     * @param details
     * {
     *     taskId       :   任务Id
     *     serialNumber :   设备序列号
     *     pushStatus   :   任务执行状态{ 1：成功，2：失败 }
     *     remark       :   备注（失败原因）,选填
     * }
     * @return ResultBean<Boolean>
     */
    @PostMapping(value = "/time/strategy/push/task/details/updatePushStatus")
    ResultBean<Boolean> updatePushStatus(@RequestBody TimeStrategyTaskDeviceDetails details);
}
