社区feed流/topsales
This commit is contained in:
70
src/main/java/com/rj/controller/biz/TopSalesController.java
Normal file
70
src/main/java/com/rj/controller/biz/TopSalesController.java
Normal file
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
|
||||
@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<DifyWorkflowResponseDto> score(@Valid @RequestBody TopSalesScoreRequestDto requestDto) {
|
||||
try {
|
||||
return ResponseEntity.ok(topSalesScoreResultService.callAndSave(requestDto));
|
||||
} catch (Exception e) {
|
||||
log.error("调用TopSales评分工作流失败", e);
|
||||
DifyWorkflowResponseDto error = DifyWorkflowResponseDto.failure(
|
||||
"TopSales评分工作流调用失败: " + e.getMessage(),
|
||||
e.getClass().getSimpleName()
|
||||
);
|
||||
return ResponseEntity.status(500).body(error);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "分页查询TopSales评分结果")
|
||||
public ResponseEntity<Object> page(
|
||||
@RequestParam(defaultValue = "1") Integer current,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) String workflowId,
|
||||
@RequestParam(required = false) String status
|
||||
) {
|
||||
Page<TopSalesScoreResult> page = new Page<>(current, size);
|
||||
LambdaQueryWrapper<TopSalesScoreResult> 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<TopSalesScoreResult> result = topSalesScoreResultService.page(page, wrapper);
|
||||
return ResponseEntity.ok(result);
|
||||
}
|
||||
|
||||
@GetMapping("/by-workflow/{workflowId}")
|
||||
@Operation(summary = "按workflowId查询TopSales评分结果")
|
||||
public ResponseEntity<TopSalesScoreResult> getByWorkflowId(@PathVariable String workflowId) {
|
||||
return ResponseEntity.ok(topSalesScoreResultService.getByWorkflowId(workflowId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user