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

import com.red.circle.console.app.dto.clienobject.user.UserConfessionRecordCO;
import com.red.circle.console.app.service.app.user.ConfessionRecordService;
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.tool.core.date.TimestampUtils;
import com.red.circle.other.inner.model.cmd.user.UserConfessionRecordQryCmd;
import com.red.circle.other.inner.model.dto.user.UserConfessionDTO;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
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>
 * CP告白审核 前端控制器.
 * </p>
 *
 * @author zongpubin on 2023-06-15 16:02
 */
@RestController
@AllArgsConstructor
@RequestMapping("/user/confession/record")
public class UserCpConfessionRestController extends BaseController {

  private final ConfessionRecordService userConfessionRecordService;


  /**
   * CP告白分页列表.
   */
  @GetMapping("/page")
  public PageResult<UserConfessionRecordCO> userConfessionRecordPage(
      UserConfessionRecordQryCmd query) {
    return userConfessionRecordService.pageListQuery(query);
  }

  /**
   * 审核CP告白信息
   */
  @OpsOperationReqLog("审核CP告白信息")
  @PutMapping
  public void auditUserConfession(@RequestBody UserConfessionDTO dto) {
    dto.setUpdateUser(getReqUserId());
    dto.setUpdateTime(TimestampUtils.now());
    userConfessionRecordService.auditUserConfession(dto);
  }

}

