| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package com.etotem.cfc.controller;
- import com.etotem.cfc.common.Result;
- import com.etotem.cfc.service.GrowthMilestoneService;
- import com.etotem.cfc.service.GrowthRecommendationService;
- import com.etotem.cfc.util.ParamUtils;
- import io.swagger.v3.oas.annotations.Operation;
- import io.swagger.v3.oas.annotations.tags.Tag;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- @Tag(name = "成长板块", description = "成长页面推荐内容")
- @RestController
- @RequestMapping("/api/growth")
- public class GrowthController {
- @Resource
- private GrowthRecommendationService growthRecommendationService;
- @Resource
- private GrowthMilestoneService growthMilestoneService;
- @Operation(summary = "获取成长板块推荐内容")
- @PostMapping("/recommendations")
- public Result<Map<String, Object>> getRecommendations(
- @RequestParam(defaultValue = "health") String category,
- @RequestParam(defaultValue = "3") int limit) {
- List<Map<String, Object>> articles = growthRecommendationService.getRecommendedArticles(category, limit);
- List<Map<String, Object>> products = growthRecommendationService.getRecommendedProducts(category, limit);
- Map<String, Object> data = new HashMap<>();
- data.put("articles", articles);
- data.put("products", products);
- return Result.success(data);
- }
- @Operation(summary = "AI 自动分类文章(批量)")
- @PostMapping("/articles/ai-classify")
- public Result<Map<String, Object>> autoClassifyArticles(
- @RequestParam(defaultValue = "20") int batchSize) {
- return Result.success(growthRecommendationService.autoClassifyArticles(batchSize));
- }
- @Operation(summary = "AI 自动分类商品(批量)")
- @PostMapping("/products/ai-classify")
- public Result<Map<String, Object>> autoClassifyProducts(
- @RequestParam(defaultValue = "20") int batchSize) {
- return Result.success(growthRecommendationService.autoClassifyProducts(batchSize));
- }
- // ========== 成长里程碑(SC-P-51 / 缺口 G-2:growth.milestone.mark)==========
- @Operation(summary = "标记成长里程碑(系统/手动标,返回里程碑ID,幂等)")
- @PostMapping("/milestone/mark")
- public Result<Long> markMilestone(@RequestBody Map<String, Object> body,
- @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
- Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
- Long recordId = ParamUtils.getLong(body.get("recordId"));
- String milestoneType = body.get("milestoneType") != null
- ? body.get("milestoneType").toString() : "manual";
- if (memberId == null || recordId == null) {
- return Result.error("缺少必要参数: memberId, recordId");
- }
- Long milestoneId = growthMilestoneService.markMilestone(memberId, recordId, milestoneType);
- return Result.success("标记成功", milestoneId);
- }
- @Operation(summary = "查询成长记录是否已标记里程碑(时间线高亮判定)")
- @PostMapping("/milestone/marked")
- public Result<Map<String, Object>> isMilestoneMarked(@RequestBody Map<String, Object> body,
- @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
- Long memberId = ParamUtils.getLong(body.get("memberId"), currentMemberId);
- Long recordId = ParamUtils.getLong(body.get("recordId"));
- String milestoneType = body.get("milestoneType") != null
- ? body.get("milestoneType").toString() : "manual";
- if (memberId == null || recordId == null) {
- return Result.error("缺少必要参数: memberId, recordId");
- }
- boolean marked = growthMilestoneService.isMarked(memberId, recordId, milestoneType);
- Map<String, Object> result = new HashMap<>();
- result.put("marked", marked);
- return Result.success(result);
- }
- }
|