/*
 * Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
 *
 */
package net.northking.cctp.device.api.mobile;

import cn.gjing.tools.auth.annotation.RequiredPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.northking.cctp.common.http.ResultWrapper;

import net.northking.cctp.device.api.mobile.service.CdMobileDeviceApiService;
import net.northking.cctp.device.api.pcDevice.service.CdPcDeviceApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.integration.redis.util.RedisLockRegistry;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "移动设备信息表")
@RequestMapping("/v1")
@RestController
public class CdMobileDeviceQueryCtrl {
    /**
     * 日志
     */
    private final static Logger logger = LoggerFactory.getLogger(CdMobileDeviceQueryCtrl.class);

    @Autowired
    private CdMobileDeviceApiService apiService;

    @Autowired
    private CdPcDeviceApiService pcDeviceApiService;

    @Autowired
    private RedisLockRegistry redisLockRegistry;

    @ApiOperation(value = "移除设备")
    @GetMapping(value = "/device/mobile/remove/{uuid}",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<Integer> removeDevice(@PathVariable("uuid") String uuid) {
        ResultWrapper<Integer> wrapper = new ResultWrapper<>();
        Integer result = this.apiService.removeDevice(uuid);
        return wrapper.success(result);
    }



    @ApiOperation(value = "重启设备")
    @RequiredPermissions({"ui-restartMobDevice","ui-mobileBatchRestart","ui-sassBatchRestart","ui-sassRestart"})
    @PostMapping(value = "/device/mobile/remote/restart",
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE,
            consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultWrapper<String> restart(@RequestBody List<String> ids){
        logger.info("重启移动设备----------------------------------->start");
        ResultWrapper<String> wrapper = new ResultWrapper<>();
        String result = this.apiService.restartDevice(ids);
        logger.info("重启移动设备----------------------------------->end");
        return wrapper.success(result);
    }

}


