package com.crm.manager.controller;

import com.crm.manager.service.SalesDpsVolumeCommissionService;
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.SalesDpsVolumeCommissionDto;
import com.crm.rely.backend.core.dto.sales.SalesDpsVolumeCommissionSumDto;
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.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;

@RestController
@RequestMapping("/sales/dps/volume/commission")
public class SalesDpsVolumeCommissionController {

    @Autowired
    private SalesDpsVolumeCommissionService salesDpsVolumeCommissionService;

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


}
