package com.crm.manager.controller;

import com.crm.manager.service.risk.RiskBbiFeignService;
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.risk.bbi.RiskBbiDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.risk.bbi.RiskBbiAddEntity;
import com.crm.rely.backend.core.entity.risk.bbi.RiskBbiDeleteEntity;
import com.crm.rely.backend.core.entity.risk.bbi.RiskBbiSearchPageEntity;
import com.crm.rely.backend.core.entity.risk.bbi.RiskBbiUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

@RestController
@RequestMapping("/risk/bbi")
public class RiskBbiController {

    @Autowired
    private RiskBbiFeignService riskBbiFeignService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated RiskBbiAddEntity entity) throws Exception {

        return riskBbiFeignService.add(entity);
    }

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated RiskBbiUpdateEntity entity) throws Exception {

        return riskBbiFeignService.update(entity);
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated RiskBbiDeleteEntity entity) throws Exception {

        return riskBbiFeignService.delete(entity);
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<RiskBbiDto> searchPage(@RequestBody @Validated RiskBbiSearchPageEntity entity) throws Exception {

        return riskBbiFeignService.searchPage(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto<RiskBbiDto> searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {

        return riskBbiFeignService.searchSingle(entity);
    }


}
