package com.crm.ucard.controller;

import com.crm.rely.backend.core.constant.FeignClientAnnotation;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.ucard.CardBlockchainConfigDto;
import com.crm.rely.backend.core.dto.ucard.CardBlockchainRateConfigDto;
import com.crm.rely.backend.core.entity.base.BaseDeleteEntities;
import com.crm.rely.backend.core.entity.ucard.*;
import com.crm.rely.backend.exception.ServiceException;
import com.crm.ucard.service.UcardBlockchainService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * 银行卡服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/blockchain/manager")
public class ManagerUcardBlockchainController {

    @Autowired
    private UcardBlockchainService ucardBlockchainService;

    /**
     * 区块链配置列表
     */
    @PostMapping("/config/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardBlockchainConfigDto> getCardBlockchainConfigPageList(@RequestBody CardBlockchainConfigPageEntity entity) throws ServiceException{
        return ucardBlockchainService.getCardBlockchainConfigPageList(entity);
    }

    /**
     * 区块链下拉列表
     */
    @PostMapping("/dropdown")
    @FeignClientAnnotation
    BaseResultDto getCardBlockchainDropdown() throws ServiceException{
        return ucardBlockchainService.getCardBlockchainDropdown();
    }

    /**
     * 新增区块链配置
     */
    @PostMapping("/config/add")
    @FeignClientAnnotation
    BaseResultDto addCardBlockchainConfig(@RequestBody CardBlockchainConfigAddEntity entity) throws ServiceException{
        return ucardBlockchainService.addCardBlockchainConfig(entity);
    }

    /**
     * 修改区块链配置
     */
    @PostMapping("/config/update")
    @FeignClientAnnotation
    BaseResultDto updateCardBlockchainConfig(@RequestBody CardBlockchainConfigUpdateEntity entity) throws ServiceException{
        return ucardBlockchainService.updateCardBlockchainConfig(entity);
    }

    /**
     * 删除区块链配置
     */
    @PostMapping("/config/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardBlockchainConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardBlockchainService.deleteCardBlockchainConfig(entity);
    }

    /**
     * 区块链配置列表
     */
    @PostMapping("/rate/config/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardBlockchainRateConfigDto> getCardBlockchainRateConfigPageList(@RequestBody CardBlockchainRateConfigPageEntity entity) throws ServiceException{
        return ucardBlockchainService.getCardBlockchainRateConfigPageList(entity);
    }

    /**
     * 新增区块链配置
     */
    @PostMapping("/rate/config/add")
    @FeignClientAnnotation
    BaseResultDto addCardBlockchainRateConfig(@RequestBody CardBlockchainRateConfigAddEntity entity) throws ServiceException{
        return ucardBlockchainService.addCardBlockchainRateConfig(entity);
    }

    /**
     * 修改区块链配置
     */
    @PostMapping("/rate/config/update")
    @FeignClientAnnotation
    BaseResultDto updateCardBlockchainRateConfig(@RequestBody CardBlockchainRateConfigUpdateEntity entity) throws ServiceException{
        return ucardBlockchainService.updateCardBlockchainRateConfig(entity);
    }

    /**
     * 删除区块链配置
     */
    @PostMapping("/rate/config/delete")
    @FeignClientAnnotation
    BaseResultDto deleteCardBlockchainRateConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return ucardBlockchainService.deleteCardBlockchainRateConfig(entity);
    }

}
