package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.common.controller.IController;
import com.kym.entity.Faq;
import com.kym.entity.PlatformFeeRate;
import com.kym.entity.queryParams.FaqQueryParam;
import com.kym.entity.queryParams.PlatformFeeRateQueryParam;
import com.kym.service.PlatformFeeRateService;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 站点平台费率表 前端控制器
 * </p>
 *
 * @author skyline
 * @since 2025-04-18
 */
@RestController
@RequestMapping("/platform-fee-rate")
public class PlatformFeeRateController extends IController {

    private final PlatformFeeRateService platformFeeRateService;

    public PlatformFeeRateController(PlatformFeeRateService platformFeeRateService) {
        this.platformFeeRateService = platformFeeRateService;
    }

    /**
     * 新增平台费率配置
     *
     * @param platformFeeRate
     * @return Res
     */
    @PostMapping("add")
    @SysLog(value = "新增平台费率配置")
    public R<?> add(@Valid @RequestBody PlatformFeeRate platformFeeRate) {
        return resp(() -> platformFeeRateService.save(platformFeeRate));
    }

    /**
     * 更新平台费率配置
     *
     * @return Res
     */
    @PostMapping("modify")
    @SysLog(value = "更新平台费率配置")
    public R<?> modify(@Valid @RequestBody PlatformFeeRate platformFeeRate) {
        return resp((t) -> platformFeeRateService.updateById(platformFeeRate));
    }


    /**
     * 平台费率配置列表
     *
     * @return Res
     */
    @PostMapping("list")
    @SysLog(value = "平台费率配置列表")
    public R<?> list(@RequestBody PlatformFeeRateQueryParam params) {
        return resp(() -> platformFeeRateService.listPlatformFeeRate(params));
    }

}
