package com.crm.manager.controller;

import com.crm.manager.service.finance.FinanceTransferRiskRemindFeignService;
import com.crm.rely.backend.core.constant.Constants;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.finance.transfer.risk.remind.FinanceTransferRiskRemindSearchDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.finance.transfer.risk.remind.FinanceTransferRiskRemindApproveEntity;
import com.crm.rely.backend.core.entity.finance.transfer.risk.remind.FinanceTransferRiskRemindDeleteEntity;
import com.crm.rely.backend.core.entity.finance.transfer.risk.remind.FinanceTransferRiskRemindSearchEntity;
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;

/**
 * @description: 内转风险提示
 * @author: houn
 * @create: 2022-11-08 18:01
 **/
@RestController
@RequestMapping("/finance/transfer/risk/remind")
public class FinanceTransferRiskRemindController {

    @Autowired
    private FinanceTransferRiskRemindFeignService FinanceTransferRiskRemindFeignService;

    @PostMapping("/confirm")
    public BaseResultDto confirm(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        FinanceTransferRiskRemindApproveEntity financeTransferRiskRemindApproveEntity =
                new FinanceTransferRiskRemindApproveEntity();
        financeTransferRiskRemindApproveEntity.setId(entity.getId());
        financeTransferRiskRemindApproveEntity.setStatus(Constants.PASSED_STATUS);
        return this.FinanceTransferRiskRemindFeignService.approve(financeTransferRiskRemindApproveEntity);
    }

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

        return this.FinanceTransferRiskRemindFeignService.delete(entity);
    }

    @PostMapping("/search/list")
    public BaseResultDto searcherPageList(@RequestBody @Validated FinanceTransferRiskRemindSearchEntity entity) throws Exception {

        BaseResultDto resultWithPagerDto =
                this.FinanceTransferRiskRemindFeignService.searchPageList(entity);
        return resultWithPagerDto;
    }

    @PostMapping("/list")
    public BaseResultDto searchList(@RequestBody @Validated FinanceTransferRiskRemindSearchEntity entity) throws Exception {
        entity.setStatus(Constants.APPLY_STATUS);
        BaseResultDto resultWithPagerDto =
                this.FinanceTransferRiskRemindFeignService.searchList(entity);
        return resultWithPagerDto;
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        BaseResultDto<FinanceTransferRiskRemindSearchDto> resultDto =
                this.FinanceTransferRiskRemindFeignService.searchSingle(entity);
        return resultDto;
    }

}
