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

import com.red.circle.console.app.dto.clienobject.user.UserBankIdentityInfoCO;
import com.red.circle.console.app.service.app.user.UserBankIdentityInfoService;
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.UserBankIdentityInfoCmd;
import com.red.circle.other.inner.model.cmd.user.UserBankIdentityInfoExportQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBankIdentityInfoQryCmd;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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>
 * 用户身份信息 前端控制器.
 * </p>
 *
 * @author zongpubin on 2023-06-15 16:02
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/user/bank-identity-info")
public class UserBankIdentityInfoRestController extends BaseController {

  private final UserBankIdentityInfoService userBankIdentityInfoService;


  /**
   * 用户身份分页列表.
   */
  @GetMapping("/page")
  public PageResult<UserBankIdentityInfoCO> userBankIdentityInfoPage(
      UserBankIdentityInfoQryCmd query) {
    return userBankIdentityInfoService.pageListQuery(query);
  }

  /**
   * 审核用户身份信息
   */
  @OpsOperationReqLog("审核用户身份信息")
  @PutMapping
  public void auditUserBankIdentityInfo(@RequestBody UserBankIdentityInfoCmd cmd) {
    cmd.setUpdateUser(cmd.getReqUserId());
    cmd.setUpdateTime(TimestampUtils.now());
    userBankIdentityInfoService.updateUserBankIdentityInfo(cmd);
  }

  /**
   * 审核用户身份信息-导出
   */
  @OpsOperationReqLog(value = "导出-审核用户身份信息", ignoreRequestParam = true)
  @GetMapping("/export")
  public void exportCandy(HttpServletResponse response,
      @Validated UserBankIdentityInfoExportQryCmd query) throws IOException {

    userBankIdentityInfoService.listExport(response, query);
  }


}

