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

import com.github.microservice.auth.security.annotations.ResourceAuth;
import com.github.microservice.auth.security.type.AuthType;
import com.github.microservice.net.ResultContent;
import com.zhongshu.card.client.model.paySetting.paySetting.PayOrderSettingModel;
import com.zhongshu.card.client.model.paySetting.paySetting.PayOrderSettingParam;
import com.zhongshu.card.server.core.service.paySetting.PayOrderSettingService;
import com.zhongshu.card.server.core.service.paySetting.ProjectChannelConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 项目支付顺序设置
 *
 * @author TRX
 * @date 2024/7/26
 */
@RestController
@RequestMapping("/projectPayOrder")
@Tag(name = "支付管理-支付顺序")
public class PayOrderSettingController {

    @Autowired
    private ProjectChannelConfigService projectChannelConfigService;

    @Autowired
    private PayOrderSettingService payOrderSettingService;

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "得到用户的支付渠道排序数据", description = "得到用户的支付渠道排序数据")
    @RequestMapping(value = "getUserPayOrderSetting", method = {RequestMethod.GET})
    public ResultContent<List<PayOrderSettingModel>> getUserPayOrderSetting() {
        return payOrderSettingService.getUserPayOrderSetting();
    }

    @ResourceAuth(value = "user", type = AuthType.User)
    @Operation(summary = "保存用户的支付顺序", description = "保存用户的支付顺序")
    @RequestMapping(value = "saveOrder", method = {RequestMethod.POST})
    public ResultContent saveOrder(@RequestBody @Valid PayOrderSettingParam param) {
        return payOrderSettingService.saveOrder(param);
    }


}
