package com.crm.manager.controller;

import com.crm.manager.service.ucard.UcardBlockchainFeignService;
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 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")
public class UcardBlockchainController {

    @Autowired
    private UcardBlockchainFeignService ucardBlockchainFeignService;

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

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

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

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

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

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

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

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

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