package com.seer.teach.pay.app.wallet.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.pay.app.wallet.convert.CoinConfigConvert;
import com.seer.teach.pay.app.wallet.resp.CoinConfigResp;
import com.seer.teach.pay.app.wallet.service.IAppCoinConfigService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学豆配置表 前端控制器
 * </p>
 *
 * @author Captain
 * @since 2025-06-17
 */
@RestController
@RequestMapping("/app/wallet/coin-config")
@Tag(name = "APP - 学豆配置")
@Validated
@RequiredArgsConstructor
@DecryptionAnnotation
@EncryptionAnnotation
public class AppCoinConfigController {

    private final IAppCoinConfigService coinConfigService;

    @Operation(summary = "获取配置的学豆兑换比例")
    @GetMapping
    @SaCheckPermission("app:wallet:coin-config:view")
    public ResultBean<CoinConfigResp> list(){
        return ResultBean.success(CoinConfigConvert.INSTANCE.convertOne(coinConfigService.getActiveAndLatestCoinConfig()));
    }

}