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.CardFileDto;
import com.crm.rely.backend.core.entity.base.BaseDeleteEntities;
import com.crm.rely.backend.core.entity.ucard.CardFileAddEntity;
import com.crm.rely.backend.core.entity.ucard.CardFilePageEntity;
import com.crm.rely.backend.core.entity.ucard.CardFileUpdateEntity;
import com.crm.rely.backend.exception.ServiceException;
import com.crm.ucard.service.UcardFileService;
import com.crm.ucard.service.WasabiDocumentApiService;
import lombok.extern.slf4j.Slf4j;
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;

/**
 * 银行卡文件服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/file/manager")
public class ManagerUcardFileController {


    @Autowired
    private WasabiDocumentApiService wasabiDocumentApiService;
    @Autowired
    private UcardFileService ucardFileService;

    /**
     * 校验文件
     */
    @PostMapping("/validated/file")
    @FeignClientAnnotation
    public void validatedFile(@RequestParam(value = "file") MultipartFile file) throws ServiceException {
        wasabiDocumentApiService.validatedFile(file);
    }


    /**
     * 添加文件记录
     */
    @PostMapping("/add")
    @FeignClientAnnotation
    public BaseResultDto cardVideoAdd(@RequestBody @Validated CardFileAddEntity entity) throws ServiceException {
        return ucardFileService.cardFileAdd(entity);
    }

    /**
     * 修改文件
     */
    @PostMapping("/update")
    @FeignClientAnnotation
    public BaseResultDto cardVideoUpdate(@RequestBody @Validated CardFileUpdateEntity entity) throws ServiceException {
        return ucardFileService.cardFileUpdate(entity);
    }

    /**
     * 删除文件
     */
    @PostMapping("/delete")
    @FeignClientAnnotation
    public BaseResultDto cardVideoDelete(@RequestBody BaseDeleteEntities entity) throws ServiceException {
        return ucardFileService.cardFileDelete(entity);
    }

    /**
     * 文件分页列表
     */
    @PostMapping("/search/list")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardFileDto> cardFileSearchList(@RequestBody CardFilePageEntity entity) throws ServiceException {
        return ucardFileService.cardFileSearchList(entity);
    }


}
