package cn.iocoder.yudao.module.crm.controller.admin.crmanalysis;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.AchievementPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.CustomerLevelVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.UserRecordVO;
import cn.iocoder.yudao.module.crm.controller.admin.crmanalysis.vo.UserVolumeVO;
import cn.iocoder.yudao.module.crm.service.crmanalysis.CustomerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 客户分析")
@RestController
@RequestMapping("/crm/analysis-customer")
@Validated
public class CustomerController {

    @Resource
    private CustomerService customerService;



    @GetMapping("/level")
    @Operation(summary = "获得客户等级分析")
    public CommonResult<CustomerLevelVO> getCustomerLevel() {
        return success(customerService.getCustomerLevel());
    }

    @GetMapping("/source")
    @Operation(summary = "获得客户来源分析")
    public CommonResult<CustomerLevelVO> getCustomerSource() {
        return success(customerService.getCustomerSource());
    }

    @GetMapping("/industry")
    @Operation(summary = "获得客户行业分析")
    public CommonResult<CustomerLevelVO> getCustomerIndustry() {
        return success(customerService.getCustomerIndustry());
    }

    @GetMapping("/volume")
    @Operation(summary = "获得客户量分析")
    public CommonResult<PageResult<UserVolumeVO>> getAchievementPage(@Valid AchievementPageReqVO pageReqVO) {
        return success(customerService.getCustomerVolume(pageReqVO));
    }

    @GetMapping("/record")
    @Operation(summary = "获得跟进分析")
    public CommonResult<PageResult<UserRecordVO>> getRecord(@Valid AchievementPageReqVO pageReqVO) {
        return success(customerService.getRecord(pageReqVO));
    }
}
