package com.sikey.wa04.api.message.client.rest;

import com.sikey.wa04.business.application.service.message.RemoteControlService;
import com.sikey.wa04.business.infrastructure.configuration.ProjectContextConstant;
import com.sikey.wa04.common.BaseController;
import com.sikey.wa04.common.interceptor.Authenticated;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
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;

/**
 * 远程控制 Controller
 *
 * @author luoyangwei
 */
@RestController
@RequestMapping(ProjectContextConstant.MESSAGE_URL + "/messaging/publish/remote-control")
public class RemoteControlController extends BaseController {

    @Resource
    private RemoteControlService remoteControlService;

    /**
     * 关机
     *
     * @param cid 小孩ID
     */
    @Authenticated
    @GetMapping("/shutdown")
    public void shutdown(@NotBlank(message = "小孩ID不能为空") @RequestParam("cid") String cid) {
        remoteControlService.shutdown(genericManufacturerHeader(), cid);
    }

    /**
     * 重启
     *
     * @param cid 小孩ID
     */
    @Authenticated
    @GetMapping("/reboot")
    public void reboot(@NotBlank(message = "小孩ID不能为空") @RequestParam("cid") String cid) {
        remoteControlService.reboot(genericManufacturerHeader(), cid);
    }

    /**
     * 恢复出厂设置
     *
     * @param cid 小孩ID
     */
    @Authenticated
    @GetMapping("/restoreFactorySettings")
    public void restoreFactorySettings(@NotBlank(message = "小孩ID不能为空") @RequestParam("cid") String cid) {
        remoteControlService.restoreFactorySettings(genericManufacturerHeader(), cid);
    }


}
