package com.crm.pay.controller;

import com.crm.pay.service.SysChannelBankService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.model.dto.sys.remittance.channel.bank.SysChannelBankByChannelCodeDto;
import com.crm.rely.backend.model.entity.sys.remittance.channel.bank.SysChannelBankByChannelCodeListEntity;
import com.crm.rely.backend.model.entity.sys.remittance.channel.bank.SysChannelBankByCodeEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 根据通道code获取银行列表
 */
@RestController
@RequestMapping("/channel/bank")
public class SysChannelBankController {

    @Autowired
    private SysChannelBankService sysChannelBankService;

    /**
     * 根据通道code获取银行列表
     *
     * @param sysChannelBankByChannelCodeListEntity
     * @return
     * @throws Exception
     */
    @PostMapping("/list")
    public BaseResultDto<List<SysChannelBankByChannelCodeDto>> selectList(@RequestBody @Validated SysChannelBankByChannelCodeListEntity sysChannelBankByChannelCodeListEntity) throws Exception {

        return sysChannelBankService.getAllByChannelCode(sysChannelBankByChannelCodeListEntity);
    }

    /**
     * 根据银行code 获取银行信息
     *
     * @param sysChannelBankByCodeEntity
     * @return
     * @throws Exception
     */
    @PostMapping("/code")
    public BaseResultDto<SysChannelBankByChannelCodeDto> getByCode(@RequestBody @Validated SysChannelBankByCodeEntity sysChannelBankByCodeEntity) throws Exception {

        return sysChannelBankService.getByCode(sysChannelBankByCodeEntity);
    }

}
