package com.xingxi.web.controller.business.MerchantWxpay.controller;

import com.xingxi.business.MerchantWxpay.domain.MerchantWxpay;
import com.xingxi.business.MerchantWxpay.service.IMerchantWxpayService;
import com.xingxi.common.annotation.Log;
import com.xingxi.common.core.controller.BaseController;
import com.xingxi.common.core.domain.AjaxResult;
import com.xingxi.common.core.page.TableDataInfo;
import com.xingxi.common.enums.BusinessType;
import com.xingxi.common.utils.poi.ExcelUtil;
import com.xingxi.web.controller.business.MerchantWxpay.domain.MerchantWxpayVo;
import com.xingxi.web.controller.business.MerchantWxpay.service.IMerchantWxpayVoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 店铺微信支付信息Controller
 *
 * @author ruoyi
 * @date 2025-03-09
 */
@Controller
@RequestMapping("/business/merchant/wxpay")
public class MerchantWxpayController extends BaseController {
    private String prefix = "business/merchant/wxpay";

    @Resource
    private IMerchantWxpayService merchantWxpayService;
    @Resource
    private IMerchantWxpayVoService merchantWxpayVoService;

    /**
     * 修改店铺微信支付信息
     */
    @RequiresPermissions("business:merchant:wxpay:edit")
    @GetMapping("/edit/{mercId}")
    public String edit(@PathVariable("mercId") Long mercId, ModelMap mmap) {
        MerchantWxpayVo merchantWxpayVo = merchantWxpayVoService.selectMerchantWxpayVoByMercId(mercId);
        if (merchantWxpayVo == null) {
            merchantWxpayVo = new MerchantWxpayVo();
        }
        mmap.put("merchantWxpay", merchantWxpayVo);
        return prefix + "/edit";
    }

    /**
     * 修改保存店铺微信支付信息
     */
    @RequiresPermissions("business:merchant:wxpay:edit")
    @Log(title = "店铺微信支付信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(MerchantWxpay merchantWxpay) {
        return toAjax(merchantWxpayService.updateMerchantWxpay(merchantWxpay));
    }
}
