package com.ruoyi.web.app;

import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.bst.channel.domain.ChannelQuery;
import com.ruoyi.bst.channel.service.ChannelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.domain.JsonViewProfile;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/app/channel")
public class AppChannelController extends BaseController {

    @Autowired
    private ChannelService channelService;

    @ApiOperation("获取可用支付渠道列表")
    @GetMapping("/list")
    @JsonView(JsonViewProfile.App.class)
    public AjaxResult list(ChannelQuery query) {
        if (query.getAppId() == null) {
            return error("appId不能为空");
        }
        query.setEnabled(true);
        return success(channelService.selectChannelList(query));
    }

}
