package com.kingdee.eas.custom.integration.riskcontrol.controller;

import com.kingdee.eas.custom.integration.base.annotation.ApiDoc;
import com.kingdee.eas.custom.integration.base.controller.AbstractIntegrationController;
import com.kingdee.eas.custom.integration.base.dto.ApiResult;
import com.kingdee.eas.custom.integration.riskcontrol.dto.BatchComplaintDonationDeductRequest;
import com.kingdee.eas.custom.integration.riskcontrol.dto.ComplaintDonationDeductResponse;
import com.kingdee.eas.custom.integration.riskcontrol.service.ComplaintDonationDeductService;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 风控平台数据同步接口
 * 访问路径: /risk-control/*
 * 无需登录认证（供风控平台回调）
 */
@RestController
@RequestMapping("/risk-control")
public class RiskControlSyncController extends AbstractIntegrationController {

    @Autowired
    private ComplaintDonationDeductService complaintDonationDeductService;

    /**
     * 投诉捐赠扣除数据同步
     * POST /risk-control/complaint-donation-deduct/sync
     */
    @PostMapping("/complaint-donation-deduct/sync")
    @ApiDoc(name = "投诉捐赠扣除数据同步", desc = "投诉捐赠扣除数据同步")
    public ApiResult<ComplaintDonationDeductResponse> syncComplaintDonationDeduct(
            @RequestBody BatchComplaintDonationDeductRequest request) {
        log.info("收到投诉捐赠扣除同步请求 - 记录数: {}",
                request.getRecords() != null ? request.getRecords().size() : 0);

        ComplaintDonationDeductResponse response =
                complaintDonationDeductService.writeComplaintDonationDeduct(request);
        return success(response);
    }
}
