1
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.web.controller.publicapi;
|
||||
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 评论生成 公共接口(免登录)
|
||||
*/
|
||||
@Anonymous
|
||||
@RestController
|
||||
@RequestMapping("/public/comment")
|
||||
public class CommentPublicController extends BaseController {
|
||||
|
||||
/**
|
||||
* 获取可选型号/类型(示例)
|
||||
*/
|
||||
@GetMapping("/types")
|
||||
public AjaxResult types() {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
list.add(map("烟灶套餐", "ZQD150F-EB150"));
|
||||
list.add(map("单烟机", "CXW-298-IQ92DPRO"));
|
||||
return AjaxResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成评论(示例实现:返回两条通用好评与空图片列表)
|
||||
* 入参:productType(型号/类型)
|
||||
*/
|
||||
@PostMapping("/generate")
|
||||
public AjaxResult generate(@RequestBody Map<String, String> body) {
|
||||
String productType = body != null ? body.getOrDefault("productType", "") : "";
|
||||
List<Map<String, Object>> comments = new ArrayList<>();
|
||||
comments.add(comment("到货很快,安装专业,使用体验不错,噪音小,性价比高。"));
|
||||
comments.add(comment("外观大气,做工扎实,吸力强劲,细节处理到位,家人都满意。"));
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("productType", productType);
|
||||
resp.put("list", comments);
|
||||
return AjaxResult.success(resp);
|
||||
}
|
||||
|
||||
private Map<String, String> map(String name, String value) {
|
||||
Map<String, String> m = new HashMap<>();
|
||||
m.put("name", name);
|
||||
m.put("value", value);
|
||||
return m;
|
||||
}
|
||||
|
||||
private Map<String, Object> comment(String text) {
|
||||
Map<String, Object> m = new HashMap<>();
|
||||
m.put("commentText", text);
|
||||
m.put("images", Collections.emptyList());
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user