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

import com.red.circle.console.app.service.app.sys.SysMikeTypeConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.sys.SysMikeTypeConfigQryCmd;
import com.red.circle.other.inner.model.dto.sys.SysMikeTypeConfigDTO;
import com.red.circle.tool.core.date.TimestampUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 麦位类型配置 前端控制器.
 * </p>
 *
 * @author zongpubin on 2023-04-18 16:00
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/sys/mike-type/config")
public class SysMikeTypeConfigRestController extends BaseController {

  private final SysMikeTypeConfigService sysMikeTypeConfigService;

  /**
   * 获取麦位类型配置
   */
  @GetMapping
  public PageResult<SysMikeTypeConfigDTO> getMikeType(SysMikeTypeConfigQryCmd query) {
    return sysMikeTypeConfigService.getMikeType(query);
  }

  @OpsOperationReqLog("添加麦位类型")
  @PostMapping
  public void addMikeType(@RequestBody SysMikeTypeConfigDTO dto) {
    sysMikeTypeConfigService.addMikeType(dto);
  }

  @OpsOperationReqLog("删除麦位类型")
  @DeleteMapping("/delete/{id}")
  public void deleteMikeType(@PathVariable("id") Long id
  ) {
    sysMikeTypeConfigService.removeMikeType(id);
  }

  @OpsOperationReqLog("修改麦位类型")
  @PutMapping
  public void updateMikeType(@RequestBody SysMikeTypeConfigDTO dto) {
    dto.setUpdateUser(getReqUserId());
    dto.setUpdateTime(TimestampUtils.now());
    sysMikeTypeConfigService.updateMikeType(dto);
  }


}
