package com.rj.controller.biz; import com.rj.dto.TopSalesScoreRequestDto; import com.rj.dto.DifyWorkflowResponseDto; import com.rj.service.biz.ITopSalesScoreResultService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.rj.entity.bz.TopSalesScoreResult; import java.util.HashMap; import java.util.Map; @Slf4j @RestController @RequestMapping("/api/topsales") @Tag(name = "TopSales评分工作流", description = "调用【AI】topsales 所有维度-只打分") public class TopSalesController { @Autowired private ITopSalesScoreResultService topSalesScoreResultService; @PostMapping("/score") @Operation(summary = "调用TopSales评分工作流") public ResponseEntity> score(@Valid @RequestBody TopSalesScoreRequestDto requestDto) { Map result = new HashMap<>(); try { result.put("success", true); result.put("message", "TopSales评分成功"); result.put("data", topSalesScoreResultService.callAndSave(requestDto)); return ResponseEntity.ok(result); } catch (Exception e) { String ss ="TopSales评分工作流调用失败: " + e.getMessage() ; result.put("success", true); result.put("message", ss); log.error("调用TopSales评分工作流失败", e); return ResponseEntity.status(500).body(result ); } } @GetMapping("/page") @Operation(summary = "分页查询TopSales评分结果") public ResponseEntity page( @RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, @RequestParam(required = false) String workflowId, @RequestParam(required = false) String status ) { Page page = new Page<>(current, size); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if (workflowId != null && !workflowId.trim().isEmpty()) { wrapper.like(TopSalesScoreResult::getWorkflowId, workflowId); } if (status != null && !status.trim().isEmpty()) { wrapper.eq(TopSalesScoreResult::getStatus, status); } wrapper.orderByDesc(TopSalesScoreResult::getCreatedAt); Page result = topSalesScoreResultService.page(page, wrapper); return ResponseEntity.ok(result); } @GetMapping("/by-workflow/{workflowId}") @Operation(summary = "按workflowId查询TopSales评分结果") public ResponseEntity getByWorkflowId(@PathVariable String workflowId) { return ResponseEntity.ok(topSalesScoreResultService.getByWorkflowId(workflowId)); } }