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


import com.red.circle.console.app.dto.clienobject.approval.ApprovalProfileDescCO;
import com.red.circle.console.app.service.app.approval.ApprovalDataInfoService;
import com.red.circle.console.app.service.app.approval.ApprovalUserSettingInfoService;
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.approval.ApprovalProfileDescQryCmd;
import com.red.circle.other.inner.model.cmd.approval.ApprovalUserProfileQryCmd;
import com.red.circle.other.inner.model.dto.approval.ApprovalUserProfileDTO;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDateInfoCmd;
import lombok.AllArgsConstructor;
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 pengliang on 2020/12/10
 */
@RestController
@RequestMapping("/data/approval")
@AllArgsConstructor
public class DataApprovalRestController extends BaseController {

  private final ApprovalDataInfoService approvalDataInfoService;
  private final ApprovalUserSettingInfoService approvalUserSettingInfoService;

  @OpsOperationReqLog("资料审批")
  @PostMapping
  public void approvalPass(@RequestBody ApprovalDateInfoCmd cmd) {
    cmd.setApprovalUserId(getReqUserId());
    approvalDataInfoService.approval(cmd);
  }

  /**
   * 用户个新签名审批列表
   */
  @GetMapping("/user-profile-desc/page")
  public PageResult<ApprovalProfileDescCO> pageProfileDescApproval(
      ApprovalProfileDescQryCmd query) {
    return approvalUserSettingInfoService.pageProfileDescApproval(query);
  }

  /**
   * 用户头像/昵称审批列表
   */
  @GetMapping("/user-profile/page")
  public PageResult<ApprovalUserProfileDTO> pageUserAvatarApproval(
      ApprovalUserProfileQryCmd query) {
    return approvalUserSettingInfoService.pageUserProfileApproval(query);
  }


}
