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


import com.red.circle.console.app.service.app.props.RoomThemeStoreService;
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.RoomThemePageQryCmd;
import com.red.circle.other.inner.model.dto.material.RoomThemeStoreDTO;
import com.red.circle.tool.core.date.TimestampUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
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;

/**
 * 房间主题 前端控制器
 *
 * @author houyong on 2020/12/15
 */
@RestController
@RequestMapping("/room/theme")
@RequiredArgsConstructor
public class RoomThemeStoreRestController extends BaseController {

  private final RoomThemeStoreService roomThemeStoreService;

  /**
   * 获取房间主题分页列表.
   */
  @GetMapping(value = "/list")
  public PageResult<RoomThemeStoreDTO> pageOps(RoomThemePageQryCmd pageQryCmd) {
    return roomThemeStoreService.pageOps(pageQryCmd);
  }

  @OpsOperationReqLog("添加房间主题")
  @PostMapping
  public void addRoomTheme(@RequestBody RoomThemeStoreDTO roomTheme) {
    roomThemeStoreService.addRoomTheme(roomTheme);
  }

  @OpsOperationReqLog("修改房间主题")
  @PutMapping
  public void updateRoomTheme(@RequestBody RoomThemeStoreDTO roomTheme) {
    roomTheme.setUpdateUser(getReqUserId());
    roomTheme.setUpdateTime(TimestampUtils.now());
    roomThemeStoreService.updateRoomTheme(roomTheme);
  }

}
