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.CardIdTypeConfigDto;
import com.crm.rely.backend.core.entity.base.BaseDeleteEntities;
import com.crm.rely.backend.core.entity.ucard.CardIdTypeConfigAddEntity;
import com.crm.rely.backend.core.entity.ucard.CardIdTypeConfigPageEntity;
import com.crm.rely.backend.core.entity.ucard.CardIdTypeConfigUpdateEntity;
import com.crm.rely.backend.exception.ServiceException;
import com.crm.ucard.service.UcardTypeConfigService;
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;

import java.util.List;

/**
 * 银行卡服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/id/type/config/manager")
public class ManagerUcardIdTypeController {

    @Autowired
    private UcardTypeConfigService ucardTypeConfigService;

    /**
     * 证件类型配置列表
     *
     * @param entity
     * @return
     */
    @PostMapping("/list")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardIdTypeConfigDto> getCardIdTypeConfigList(@RequestBody CardIdTypeConfigPageEntity entity) throws ServiceException {
        return ucardTypeConfigService.getCardIdTypeConfigList(entity);
    }

    /**
     * 批量新增证件类型配置
     *
     * @param entitys
     * @return
     */
    @PostMapping("/add")
    @FeignClientAnnotation
    public BaseResultDto batchAddCardIdTypeConfig(@RequestBody List<CardIdTypeConfigAddEntity> entitys) throws ServiceException {
        return ucardTypeConfigService.batchAddCardIdTypeConfig(entitys);
    }

    /**
     * 修改证件类型配置
     *
     * @param entity
     * @return
     */
    @PostMapping("/update")
    @FeignClientAnnotation
    public BaseResultDto updateCardIdTypeConfig(@RequestBody CardIdTypeConfigUpdateEntity entity) throws ServiceException {
        return ucardTypeConfigService.updateCardIdTypeConfig(entity);
    }

    /**
     * 删除证件类型配置
     *
     * @param entity
     * @return
     */
    @PostMapping("/delete")
    @FeignClientAnnotation
    public BaseResultDto deleteCardIdTypeConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException {
        return ucardTypeConfigService.deleteCardIdTypeConfig(entity);
    }


}
