package com.crm.manager.controller;

import com.crm.manager.service.SalesDpsDwService;
import com.crm.rely.backend.core.constant.PrefixEnum;
import com.crm.rely.backend.core.dto.base.BaseReportResultDto;
import com.crm.rely.backend.core.dto.sales.SalesDpsDwDto;
import com.crm.rely.backend.core.dto.sales.SalesDpsDwSumDto;
import com.crm.rely.backend.core.entity.base.BaseIbReportListEntity;
import com.crm.rely.backend.core.entity.custom.info.InfoEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sales/dps/dw")
public class SalesDpsDwController {

    @Autowired
    private SalesDpsDwService salesDpsDwService;

    @PostMapping("/search/list")
    public BaseReportResultDto<List<SalesDpsDwDto>, SalesDpsDwSumDto> searchList(@RequestBody BaseIbReportListEntity entity, InfoEntity infoEntity) throws Exception {
        if (PrefixEnum.PREFIX_SALE.equals(infoEntity.getPrefix())) {
            entity.setSalesId(infoEntity.getIbInfo().getId());
        }
        return salesDpsDwService.searchList(entity, infoEntity);
    }

}
