|
|
@@ -1,14 +1,16 @@
|
|
|
package cn.yoshop.api.controller;
|
|
|
|
|
|
import cn.yoshop.api.service.ApiContentService;
|
|
|
+import cn.yoshop.api.support.ApiContext;
|
|
|
import cn.yoshop.common.api.R;
|
|
|
-import tools.jackson.databind.node.ArrayNode;
|
|
|
-
|
|
|
+import jakarta.servlet.http.HttpServletRequest;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -33,10 +35,10 @@ public class ApiContentController {
|
|
|
|
|
|
/** /api/article/list 文章列表(分页 15) */
|
|
|
@RequestMapping(value = "/article/list", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
- public R<Map<String, Object>> articleList(@org.springframework.web.bind.annotation.RequestBody(required = false)
|
|
|
+ public R<Map<String, Object>> articleList(@RequestBody(required = false)
|
|
|
Map<String, Object> body,
|
|
|
- jakarta.servlet.http.HttpServletRequest request) {
|
|
|
- Map<String, Object> params = cn.yoshop.api.support.ApiContext.params(request, body);
|
|
|
+ HttpServletRequest request) {
|
|
|
+ Map<String, Object> params = ApiContext.params(request, body);
|
|
|
Integer categoryId = intOrNull(params.get("categoryId"));
|
|
|
int page = intVal(params.get("page"), 1);
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
@@ -46,10 +48,10 @@ public class ApiContentController {
|
|
|
|
|
|
/** /api/article/detail 文章详情(阅读数 +1) */
|
|
|
@RequestMapping(value = "/article/detail", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
- public R<Map<String, Object>> articleDetail(@org.springframework.web.bind.annotation.RequestBody(required = false)
|
|
|
+ public R<Map<String, Object>> articleDetail(@RequestBody(required = false)
|
|
|
Map<String, Object> body,
|
|
|
- jakarta.servlet.http.HttpServletRequest request) {
|
|
|
- Map<String, Object> params = cn.yoshop.api.support.ApiContext.params(request, body);
|
|
|
+ HttpServletRequest request) {
|
|
|
+ Map<String, Object> params = ApiContext.params(request, body);
|
|
|
Integer articleId = intOrNull(params.get("articleId"));
|
|
|
if (articleId == null) {
|
|
|
throw cn.yoshop.common.exception.BizException.silent("参数错误:articleId");
|
|
|
@@ -69,10 +71,10 @@ public class ApiContentController {
|
|
|
|
|
|
/** /api/help/list 帮助中心(分页 15) */
|
|
|
@RequestMapping(value = "/help/list", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
- public R<Map<String, Object>> helpList(@org.springframework.web.bind.annotation.RequestBody(required = false)
|
|
|
+ public R<Map<String, Object>> helpList(@RequestBody(required = false)
|
|
|
Map<String, Object> body,
|
|
|
- jakarta.servlet.http.HttpServletRequest request) {
|
|
|
- Map<String, Object> params = cn.yoshop.api.support.ApiContext.params(request, body);
|
|
|
+ HttpServletRequest request) {
|
|
|
+ Map<String, Object> params = ApiContext.params(request, body);
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
data.put("list", apiContentService.helpList(intVal(params.get("page"), 1)));
|
|
|
return R.ok(data);
|
|
|
@@ -80,13 +82,13 @@ public class ApiContentController {
|
|
|
|
|
|
/** /api/page/detail DIY 页面数据(不传 pageId 取首页) */
|
|
|
@RequestMapping(value = "/page/detail", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
- public R<Map<String, Object>> pageDetail(@org.springframework.web.bind.annotation.RequestBody(required = false)
|
|
|
+ public R<Map<String, Object>> pageDetail(@RequestBody(required = false)
|
|
|
Map<String, Object> body,
|
|
|
- jakarta.servlet.http.HttpServletRequest request) {
|
|
|
- Map<String, Object> params = cn.yoshop.api.support.ApiContext.params(request, body);
|
|
|
+ HttpServletRequest request) {
|
|
|
+ Map<String, Object> params = ApiContext.params(request, body);
|
|
|
Map<String, Object> data = new LinkedHashMap<>();
|
|
|
data.put("pageData", apiContentService.pageDetail(intOrNull(params.get("pageId")),
|
|
|
- cn.yoshop.api.support.ApiContext.user(request)));
|
|
|
+ ApiContext.user(request)));
|
|
|
return R.ok(data);
|
|
|
}
|
|
|
|