package com.crm.manager.controller;

import com.crm.manager.service.ucard.UcardAppFeignService;
import com.crm.manager.service.ucard.UcardIdTypeFeignService;
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 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;

/**
 * ucard证件类型服务接口
 */
@Slf4j
@RestController
@RequestMapping("/ucard/id/type/config")
public class UcardIdTypeController {

    @Autowired
    private UcardIdTypeFeignService ucardIdTypeFeignService;

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

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

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

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

}
