package com.czg.controller.admin;

import com.czg.account.dto.merchant.ShopMerchantEditDTO;
import com.czg.account.entity.ShopMerchant;
import com.czg.account.service.ShopMerchantService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaAdminCheckRole;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 商户信息管理
 * @author Administrator
 */
@RestController
@RequestMapping("/admin/shopMerchant")
public class ShopMerchantController {
    @Resource
    private ShopMerchantService shopMerchantService;

    /**
     * 商户支付信息获取
     * 权限标识: shopMerchant:detail
     * @param shopId 店铺id
     * @return 支付信息
     */
    @SaAdminCheckRole("管理员")
    @SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
    @GetMapping
    public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
        return CzgResult.success(shopMerchantService.detail(shopId));
    }

    /**
     * 商户支付信息修改
     * 权限标识: shopMerchant:edit
     * @return 是否成功
     */
    @SaAdminCheckRole("管理员")
    @SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
    @PutMapping
    public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
        return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
    }
}
