package com.sptg.gateway.controller;

import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.device.api.entity.TimeStrategyTaskDeviceDetails;
import lombok.RequiredArgsConstructor;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * title: StrategyController
 * package: com.sptg.gateway.controller
 * description: 策略-控制器
 *
 *                  
 *                
 */
@RestController
@RequiredArgsConstructor
public class StrategyController {

    /**
     * 功能描述: 策略下发任务执行完毕
     * @param dto
     * {
     *     taskId       :   任务Id
     *     serialNumber :   设备序列号
     *     pushStatus   :   任务执行状态{ 1：成功，2：失败 }
     *     remark       :   备注（失败原因）,选填
     * }
     * @return ResultBean<Boolean>
     *                  
     *                    
     */
    @PostMapping(value = "/strategy/task/end")
    public ResultBean<Boolean> taskEnd(@RequestBody TimeStrategyTaskDeviceDetails dto){
        Assert.notNull(dto.getTaskId(),"任务Id不能为空");
        Assert.hasText(dto.getSerialNumber(),"设备序列号不能为空");
        Assert.notNull(dto.getPushStatus(),"任务执行状态不能为空");
        if (null == dto.getTaskId() || null == dto.getSerialNumber() || null == dto.getPushStatus()){
            return new ResultBean<>(ResultEnum.PARAMETER_ANOMALY);
        }
        return new ResultBean<>(ResultEnum.SUCCESS);
    }
}
