package com.nbport.zgwl.contractpush.controller;

import com.nbport.zgwl.common.R;
import com.nbport.zgwl.contractpush.dto.ApproveQueryRequestDTO;
import com.nbport.zgwl.contractpush.dto.ApproveViewUrlRequestDTO;
import com.nbport.zgwl.contractpush.dto.PushPayloadDTO;
import com.nbport.zgwl.contractpush.dto.PushTokenRequestDTO;
import com.nbport.zgwl.contractpush.service.SettlementPushService;
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;

import java.util.Map;

/**
 * 结算平台推送相关接口
 * 对应《结算平台推送合同接口文档V9.5》
 */
@RestController
@RequestMapping("/contract/push/settlement")
public class SettlementPushController {

    private final SettlementPushService settlementPushService;

    public SettlementPushController(SettlementPushService settlementPushService) {
        this.settlementPushService = settlementPushService;
    }

    @GetMapping("/token")
    public R<Map<String, Object>> getToken(PushTokenRequestDTO requestDTO) {
        return R.success(settlementPushService.getToken(requestDTO));
    }

    @PostMapping("/contract")
    public R<Map<String, Object>> pushContract(@RequestBody PushPayloadDTO requestDTO) {
        return R.success(settlementPushService.pushContract(requestDTO));
    }

    @PostMapping("/approve/query")
    public R<Map<String, Object>> queryApproveInfo(@RequestBody ApproveQueryRequestDTO requestDTO) {
        return R.success(settlementPushService.queryApproveInfo(requestDTO));
    }

    @PostMapping("/archive")
    public R<Map<String, Object>> pushArchive(@RequestBody PushPayloadDTO requestDTO) {
        return R.success(settlementPushService.pushArchive(requestDTO));
    }

    @PostMapping("/approve/view-url")
    public R<Map<String, Object>> buildApproveViewUrl(@RequestBody ApproveViewUrlRequestDTO requestDTO) {
        return R.success(settlementPushService.buildApproveViewUrl(requestDTO));
    }
}
