package com.zhongshu.card.server.core.controller.payment;

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.zhongshu.card.client.model.payment.*;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.server.core.service.payment.PaymentSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author TRX
 * @date 2024/6/19
 */
@RestController
@RequestMapping("/school/paymentSetting")
@Tag(name = "学校-支付设置")
public class PaymentSettingController {

    @Autowired
    PaymentSettingService paymentSettingService;

    @Operation(summary = "设置支付密码")
    @ResourceAuth(value = "user", type = AuthType.User)
    @RequestMapping(value = "settingPayPassword", method = RequestMethod.POST)
    public ResultContent settingPayPassword(@Valid @RequestBody PaymentSettingPasswordParam baseModel) {
        return paymentSettingService.settingPayPassword(baseModel);
    }

    @Operation(summary = "置空支付密码")
    @ResourceAuth(value = "user", type = AuthType.User)
    @RequestMapping(value = "resetPayPassword", method = RequestMethod.POST)
    public ResultContent resetPayPassword(
            @Parameter(name = "logInPassWord", description = "logInPassWord")
            @RequestParam(name = "logInPassWord")
            String logInPassWord) {
        return paymentSettingService.resetPayPassword(logInPassWord);
    }

    @Operation(summary = "设置每天最大支付金额")
    @ResourceAuth(value = "user", type = AuthType.User)
    @RequestMapping(value = "settingMaxPay", method = RequestMethod.POST)
    public ResultContent settingMaxPay(@Valid @RequestBody PaymentSettingMaxParam baseModel) {
        return paymentSettingService.settingMaxPay(baseModel);
    }


    @Operation(summary = "得到支付设置详情")
    @ResourceAuth(value = "user", type = AuthType.User)
    @RequestMapping(value = "getSettingDetail", method = RequestMethod.POST)
    public ResultContent<PaymentSettingModel> getSettingDetail() {
        return paymentSettingService.getSettingDetail();
    }
}
