package com.crm.manager.controller;

import com.crm.manager.service.custom.CustomBankFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.entity.custom.bank.CustomBankAddEntity;
import com.crm.rely.backend.core.entity.custom.bank.CustomBankAllEntity;
import com.crm.rely.backend.core.entity.custom.bank.CustomBankDeleteEntity;
import com.crm.rely.backend.core.entity.custom.bank.CustomBankUpdateEntity;
import com.crm.rely.backend.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @description: 客户银行卡信息控制
 * @author: houn
 * @create: 2020-06-13 17:52
 **/
@RestController
@RequestMapping("/custom/bank")
public class CustomBankController {

    @Autowired
    private CustomBankFeignService customBankFeignService;

    @PostMapping("/search/list")
    public BaseResultDto searchCustomList(@RequestBody @Validated CustomBankAllEntity entity) throws ServiceException {

        return customBankFeignService.searchCustomList(entity);
    }

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated CustomBankAddEntity entity) throws Exception {
        return customBankFeignService.add(entity);
    }

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated CustomBankUpdateEntity entity) throws Exception {
        return customBankFeignService.update(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated CustomBankDeleteEntity entity) throws Exception {
        return customBankFeignService.delete(entity);
    }

    @PostMapping("/upload")
    public BaseResultDto upload(@RequestParam(value = "file", required = false) MultipartFile file,
                                @RequestParam(value = "customId", required = false) Long customId) throws Exception {
        return customBankFeignService.managerUpload(file, customId);
    }

    @PostMapping("/verify")
    public BaseResultDto manageVerify(@RequestBody @Validated CustomBankUpdateEntity entity) throws Exception {

        return customBankFeignService.verify(entity);
    }

}
