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

import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.app.dto.cmd.UploadKillMicrophoneCmd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 上传麦克风情况.
 *
 * @author pengliang on 2023/6/9
 * @eo.api-type http
 * @eo.groupName 系统服务.上传麦克风情况
 * @eo.path /sys/microphone
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(value = "/sys/microphone", produces = MediaType.APPLICATION_JSON_VALUE)
public class MicrophoneUploadRestController extends BaseController {

  /**
   * 声音抖动干掉麦克风.
   *
   * @eo.name 声音抖动干掉麦克风.
   * @eo.url /kill/upload
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/kill/upload")
  public void killMicrophone(@RequestBody @Validated UploadKillMicrophoneCmd cmd) {
    cmd.setCode("CHECK_KILL_MICROPHONE");
    // 业务使用非常少，交给客户单上传数据不靠谱，容易造成不可控数据， 后期开启注意限流
    // userUploadService.uploadKillMicrophone(cmd);
  }

  /**
   * T人日志.
   *
   * @param cmd
   * @eo.name T人日志.
   * @eo.url /kill-user/upload
   * @eo.method post
   * @eo.request-type json
   */
  @PostMapping("/kill-user/upload")
  public void killUserMicrophone(@RequestBody @Validated UploadKillMicrophoneCmd cmd) {
    cmd.setCode("KILL_MICROPHONE_USER");
    // 业务使用非常少，交给客户单上传数据不靠谱，容易造成不可控数据， 后期开启注意限流
//    apiOperationLogService.add(ApiOperationLog.builder()
//        .id(IdWorkerUtils.getIdStr())
//        .requestUserId(cmd.getCmdOriginUserId())
//        .apiDesc("声音检测T麦克风")
//        .businessCode(cmd.getCode())
//        .businessContent(Objects.toString(cmd.getRoomId()))
//        .cmd(JacksonUtils.toJson(cmd))
//        .createTime(TimestampUtils.now())
//        .expiredTime(TimestampUtils.nowPlusDays(7))
//        .build());
  }


}
