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

import com.red.circle.console.app.dto.clienobject.props.RoomThemeUserCustomizeCO;
import com.red.circle.console.app.dto.cmd.app.props.ApprovalThemeCmd;
import com.red.circle.console.app.service.app.props.RoomThemeUserCustomizeService;
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.material.RoomThemeUserCustomizeOpsPageQryCmd;
import lombok.RequiredArgsConstructor;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户房间主题 前端控制器.
 *
 * @author houyong on 2021-01-14
 */
@RestController
@RequestMapping("/room/user/theme")
@RequiredArgsConstructor
public class RoomThemeUserCustomizeRestController extends BaseController {

  private final RoomThemeUserCustomizeService roomThemeUserCustomizeService;

  @GetMapping("/page")
  public PageResult<RoomThemeUserCustomizeCO> pageRoomUserTheme(
      RoomThemeUserCustomizeOpsPageQryCmd pageQryCmd) {
    return roomThemeUserCustomizeService.pageOps(pageQryCmd);
  }

  @OpsOperationReqLog("主题审批")
  @PostMapping("/approve")
  public void themeApprove(@RequestBody @Validated ApprovalThemeCmd cmd) {
    cmd.setApprovalUserId(getReqUserId());
    roomThemeUserCustomizeService.themeApprove(cmd);
  }

}
