package com.red.circle.other.adapter.app.user.user;

import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.cmd.user.user.UploadDeviceCmd;
import com.red.circle.other.app.service.user.device.DeviceService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 设备服务.
 *
 * @author pengliang on 2023/5/31
 * @eo.api-type http
 * @eo.groupName 用户服务.设备服务
 * @eo.path /user/device
 */
@Validated
@RestController
@RequestMapping(value = "/user/device", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class DeviceRestController extends BaseController {

  private final DeviceService deviceService;

  /**
   * 上传最新设备信息.
   *
   * @eo.name 上传最新设备信息.
   * @eo.url /upload
   * @eo.method post
   * @eo.request-type formdata
   */
  @PostMapping("/upload")
  public void uploadLatestDevice(UploadDeviceCmd cmd) {
    deviceService.uploadLatestDevice(cmd);
  }

  /**
   * 检查设备是否可用.
   *
   * @eo.name 检查设备是否可用.
   * @eo.url /check-available
   * @eo.method get
   * @eo.request-type formdata
   */
  @GetMapping("/check-available")
  public String checkAvailable(AppExtCommand cmd) {
    return deviceService.checkAvailable(cmd);
  }

}
