package com.jeesharp.business.modules.pay.paymerchant.controller;

import com.jeesharp.business.modules.pay.paymerchant.application.PayMerchantApplicationService;
import com.jeesharp.business.modules.pay.paymerchant.dto.PayMerchantSaveDTO;
import com.jeesharp.business.modules.pay.paymerchant.entity.PayMerchant;
import com.jeesharp.business.modules.pay.paymerchant.vo.PayMerchantInfoVO;
import com.jeesharp.business.modules.pay.paymerchant.vo.PayMerchantListVO;
import com.jeesharp.business.modules.pay.paymerchant.vo.PayMerchantQueryVO;
import com.jeesharp.framework.pojo.AjaxResult;
import com.jeesharp.framework.pojo.Page;
import com.jeesharp.framework.pojo.query.PageRespVO;
import com.jeesharp.framework.web.controller.BaseController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * 支付商户管理端 REST 接口（已废弃，请使用 {@link com.jeesharp.business.modules.pay.paypufaconfig.controller.PayPufaConfigController}）。
 *
 * @author jeesharp
 * @since 2026-05-25
 * @deprecated 杏花村 C 端支付不再使用 pay_merchant，浦发参数请配置 pay_pufa_config
 */
@Deprecated
@RestController
@RequestMapping(value = "${jeesharp.web.adminPath}/manager/business/pay/payMerchant/v1")
@Tag(name = "支付商户")
@AllArgsConstructor
public class PayMerchantController extends BaseController {

    private final PayMerchantApplicationService payMerchantApplicationService;

    @GetMapping("info")
    @Operation(summary = "获取详情")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payMerchant:info')")
    public AjaxResult<PayMerchantInfoVO> info(@RequestParam("id") String id) {
        return AjaxResult.okData(payMerchantApplicationService.get(id));
    }

    @PostMapping("list")
    @Operation(summary = "分页列表")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payMerchant:list')")
    public AjaxResult<PageRespVO<PayMerchantListVO>> list(@RequestBody PayMerchantQueryVO query) {
        return AjaxResult.okData(payMerchantApplicationService.findPage(new Page<>(query), query));
    }

    @PostMapping("save")
    @Operation(summary = "保存")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payMerchant:save')")
    public AjaxResult<Void> save(@RequestBody @Valid PayMerchantSaveDTO dto) {
        payMerchantApplicationService.save(dto);
        return AjaxResult.ok("保存成功");
    }

    @GetMapping("delete")
    @Operation(summary = "删除")
    @PreAuthorize("@ss.hasPermission('manager:business:pay:payMerchant:delete')")
    public AjaxResult<Void> delete(@RequestParam("ids") String ids) {
        payMerchantApplicationService.delete(ids);
        return AjaxResult.ok("删除成功");
    }
}
