package com.storlead.crm.customer.controller;

import com.storlead.crm.customer.dto.CustomerSingleAnalysisRequestDTO;
import com.storlead.crm.customer.entity.CustomerAnalysisResultEntity;
import com.storlead.crm.customer.service.CustomerAiAnalysisService;
import com.storlead.framework.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/customer/analysis")
@Api(tags = "客户AI分析")
public class CustomerAiAnalysisController {

    @Resource
    private CustomerAiAnalysisService customerAiAnalysisService;

    @PostMapping("/single")
    @ApiOperation("单客户AI分析并保存结果")
    public Result<Object> analyzeSingle(@RequestBody CustomerSingleAnalysisRequestDTO request) {
        if (request == null || request.getCustomerId() == null) {
            return Result.error("customerId不能为空");
        }
        CustomerAnalysisResultEntity result = customerAiAnalysisService
                .analyzeSingleCustomer(request.getCustomerId(), request.getAnalysisScene());
        return Result.ok(result);
    }
}
