Ver Fonte

api 模块接口改用具体 HTTP 方法注解

- 71 个接口的 @RequestMapping(method={GET,POST}) 全量改为 @GetMapping/@PostMapping
- HTTP 方法依据 uniapp 前端 api/*.js 的 request.get/request.post 实际调用逐条确定
- 保留 set_default/setDefault 等下划线与驼峰双路径别名,index 入口保留 produces
- 更严格的语义后可防止写接口被 GET 误触发(405 拦截)
- 新增 tools/migrate_api_mapping_annotations.py / tidy_api_mapping_annotations.py
- admin、store 模块未改动
tanlie há 7 horas atrás
pai
commit
20eb6f06ae
19 ficheiros alterados com 322 adições e 90 exclusões
  1. 186 0
      tools/migrate_api_mapping_annotations.py
  2. 37 0
      tools/tidy_api_mapping_annotations.py
  3. 9 8
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiAddressController.java
  4. 5 4
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCaptchaController.java
  5. 7 6
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCartController.java
  6. 5 4
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCashierController.java
  7. 4 3
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCheckoutController.java
  8. 7 7
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiContentController.java
  9. 7 7
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiGoodsController.java
  10. 2 3
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiIndexController.java
  11. 9 8
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiMarketingController.java
  12. 10 9
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiOrderController.java
  13. 5 5
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiPassportController.java
  14. 6 5
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRechargeController.java
  15. 7 6
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRefundController.java
  16. 3 3
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRegionController.java
  17. 3 3
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiStoreController.java
  18. 2 2
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiUploadController.java
  19. 8 7
      yoshop-java/src/main/java/cn/yoshop/api/controller/ApiUserController.java

+ 186 - 0
tools/migrate_api_mapping_annotations.py

@@ -0,0 +1,186 @@
+"""把 api 模块控制器里的 @RequestMapping(value=..., method={GET,POST}) 改成 @GetMapping / @PostMapping。
+
+HTTP 方法依据 uniapp 前端 api/*.js 的实际调用(request.get / request.post)逐条确定,
+admin / store 模块不动。
+"""
+import re
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).parent))
+from _root import ROOT  # noqa: E402
+
+CTRL_DIR = ROOT / "yoshop-java" / "src/main/java/cn/yoshop/api/controller"
+
+# (完整路径 -> 方法),路径已含控制器类上的前缀
+METHODS = {
+    # 收货地址
+    "/api/address/list": "Get",
+    "/api/address/defaultId": "Get",
+    "/api/address/detail": "Get",
+    "/api/address/add": "Post",
+    "/api/address/edit": "Post",
+    "/api/address/setDefault": "Post",
+    "/api/address/remove": "Post",
+    # 图形 / 短信验证码
+    "/api/captcha/image": "Get",
+    "/api/captcha/sendSmsCaptcha": "Post",
+    # 购物车
+    "/api/cart/list": "Get",
+    "/api/cart/total": "Get",
+    "/api/cart/add": "Post",
+    "/api/cart/update": "Post",
+    "/api/cart/clear": "Post",
+    # 收银台
+    "/api/cashier/orderInfo": "Get",
+    "/api/cashier/orderPay": "Post",
+    "/api/cashier/tradeQuery": "Get",
+    # 结算台
+    "/api/checkout/order": "Get",
+    "/api/checkout/submit": "Post",
+    # 内容
+    "/api/category/list": "Get",
+    "/api/article/list": "Get",
+    "/api/article/detail": "Get",
+    "/api/article.category/list": "Get",
+    "/api/help/list": "Get",
+    "/api/page/detail": "Get",
+    # 商品
+    "/api/goods/list": "Get",
+    "/api/goods/detail": "Get",
+    "/api/goods/basic": "Get",
+    "/api/goods/specData": "Get",
+    "/api/goods/skuInfo": "Get",
+    "/api/goods.service/list": "Get",
+    # 站点入口(纯文本兜底)
+    "/api/index/index": "Get",
+    # 营销
+    "/api/comment/list": "Get",
+    "/api/comment/total": "Get",
+    "/api/comment/listRows": "Get",
+    "/api/coupon/list": "Get",
+    "/api/myCoupon/list": "Get",
+    "/api/myCoupon/receive": "Post",
+    "/api/express/list": "Get",
+    # 订单
+    "/api/order/list": "Get",
+    "/api/order/detail": "Get",
+    "/api/order/express": "Get",
+    "/api/order/cancel": "Post",
+    "/api/order/receipt": "Post",
+    "/api/order/todoCounts": "Get",
+    "/api/order.comment/list": "Get",
+    "/api/order.comment/submit": "Post",
+    # 登录
+    "/api/passport/login": "Post",
+    "/api/passport/loginMpWx": "Post",
+    "/api/passport/loginMpWxMobile": "Post",
+    "/api/passport/isPersonalMpweixin": "Post",
+    # 充值
+    "/api/recharge/center": "Get",
+    "/api/recharge/submit": "Post",
+    "/api/recharge/tradeQuery": "Get",
+    "/api/recharge.order/list": "Get",
+    # 售后
+    "/api/refund/list": "Get",
+    "/api/refund/goods": "Get",
+    "/api/refund/apply": "Post",
+    "/api/refund/detail": "Get",
+    "/api/refund/delivery": "Post",
+    # 地区
+    "/api/region/all": "Get",
+    "/api/region/tree": "Get",
+    # 商城 / 设置
+    "/api/store/data": "Get",
+    "/api/setting/data": "Get",
+    # 上传
+    "/api/upload/image": "Post",
+    # 用户
+    "/api/user/info": "Get",
+    "/api/user/assets": "Get",
+    "/api/user/bindMobile": "Post",
+    "/api/user/personal": "Post",
+    "/api/balance.log/list": "Get",
+    "/api/points.log/list": "Get",
+}
+
+ANN_RE = re.compile(r"@RequestMapping\((.*?)\)", re.S)
+VALUE_RE = re.compile(r'value\s*=\s*(\{[^}]*\}|"[^"]*")')
+PRODUCES_RE = re.compile(r'produces\s*=\s*("[^"]*"|[A-Za-z0-9_.]+)')
+
+
+def paths_of(value_expr):
+    return re.findall(r'"([^"]*)"', value_expr)
+
+
+def norm_path(p):
+    """把下划线写法归一成驼峰写法,用于查表。"""
+    if "_" in p:
+        head, *rest = p.split("_")
+        # spec_data / sku_info / list_rows / todo_counts / set_default / default_id
+        return head + "".join(w[:1].upper() + w[1:] for w in rest)
+    return p
+
+
+def process(path: Path):
+    src = path.read_text(encoding="utf-8")
+    cls = re.search(r'^@RequestMapping\("([^"]+)"\)', src, re.M)
+    prefix = cls.group(1) if cls else ""
+    changed = 0
+
+    def repl(m):
+        nonlocal changed
+        body = m.group(1)
+        vm = VALUE_RE.search(body)
+        if not vm:
+            return m.group(0)
+        value_expr = vm.group(1)
+        paths = paths_of(value_expr)
+        full = prefix + paths[0]
+        key = norm_path(full)
+        if key not in METHODS:
+            raise SystemExit(f"未定义 HTTP 方法: {path.name} -> {full}")
+        ann = METHODS[key]
+        pm = PRODUCES_RE.search(body)
+        parts = [f"value = {value_expr}"]
+        if pm:
+            parts.append(f"produces = {pm.group(1)}")
+        changed += 1
+        return f"@{ann}Mapping({', '.join(parts)})"
+
+    new_src = ANN_RE.sub(repl, src)
+    if not changed:
+        return 0
+
+    # 清理 / 补齐 import
+    if "RequestMethod." not in new_src:
+        new_src = new_src.replace(
+            "import org.springframework.web.bind.annotation.RequestMethod;\n", "")
+    for name in ("GetMapping", "PostMapping"):
+        if f"@{name}(" in new_src and f"import org.springframework.web.bind.annotation.{name};" not in new_src:
+            new_src = new_src.replace(
+                "import org.springframework.web.bind.annotation.RequestMapping;",
+                f"import org.springframework.web.bind.annotation.{name};\n"
+                "import org.springframework.web.bind.annotation.RequestMapping;", 1)
+    # import 块按字母排序
+    lines = new_src.split("\n")
+    idx = [i for i, ln in enumerate(lines) if ln.startswith("import ")]
+    if idx:
+        start, end = idx[0], idx[-1]
+        block = lines[start:end + 1]
+        if all(ln.startswith("import ") for ln in block):
+            lines[start:end + 1] = sorted(set(block))
+    new_src = "\n".join(lines)
+    path.write_text(new_src, encoding="utf-8")
+    return changed
+
+
+total = 0
+for f in sorted(CTRL_DIR.glob("*.java")):
+    if f.name == "ApiNotifyController.java":
+        continue
+    n = process(f)
+    if n:
+        print(f"{f.name}: {n}")
+    total += n
+print("合计:", total)

+ 37 - 0
tools/tidy_api_mapping_annotations.py

@@ -0,0 +1,37 @@
+"""收尾:去掉 @GetMapping/@PostMapping 里多余的 value =,并按字母重排 import。"""
+import re
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).parent))
+from _root import ROOT  # noqa: E402
+
+CTRL_DIR = ROOT / "yoshop-java" / "src/main/java/cn/yoshop/api/controller"
+
+
+def clean(text: str) -> str:
+    text = re.sub(r'@(Get|Post)Mapping\(value = ((\{[^}]*\}|"[^"]*"))\)',
+                  r'@\1Mapping(\2)', text)
+    lines = text.split("\n")
+    out, i = [], 0
+    while i < len(lines):
+        if lines[i].startswith("import "):
+            j = i
+            while j < len(lines) and lines[j].startswith("import "):
+                j += 1
+            out.extend(sorted(lines[i:j]))
+            i = j
+        else:
+            out.append(lines[i])
+            i += 1
+    return "\n".join(out)
+
+
+n = 0
+for f in sorted(CTRL_DIR.glob("*.java")):
+    src = f.read_text(encoding="utf-8")
+    new = clean(src)
+    if new != src:
+        f.write_text(new, encoding="utf-8")
+        n += 1
+print("整理文件数:", n)

+ 9 - 8
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiAddressController.java

@@ -10,9 +10,10 @@ import cn.yoshop.common.util.Params;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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;
@@ -29,7 +30,7 @@ public class ApiAddressController {
     private final ApiAddressService apiAddressService;
 
     /** /api/address/list 收货地址列表 */
-    @RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/list")
     public R<Map<String, Object>> list(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> data = new LinkedHashMap<>();
@@ -38,7 +39,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/default_id(兼容驼峰 /defaultId) */
-    @RequestMapping(value = {"/default_id", "/defaultId"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping({"/default_id", "/defaultId"})
     public R<Map<String, Object>> defaultId(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> data = new LinkedHashMap<>();
@@ -47,7 +48,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/detail 收货地址详情 */
-    @RequestMapping(value = "/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/detail")
     public R<Map<String, Object>> detail(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -59,7 +60,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/add 添加收货地址 */
-    @RequestMapping(value = "/add", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/add")
     public R<Void> add(@RequestBody(required = false) Map<String, Object> body, HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         apiAddressService.add(user, Params.merge(body, request));
@@ -67,7 +68,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/edit 编辑收货地址 */
-    @RequestMapping(value = "/edit", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/edit")
     public R<Void> edit(@RequestBody(required = false) Map<String, Object> body, HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> params = Params.merge(body, request);
@@ -76,7 +77,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/set_default 设为默认收货地址(兼容驼峰 /setDefault) */
-    @RequestMapping(value = {"/set_default", "/setDefault"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping({"/set_default", "/setDefault"})
     public R<Void> setDefault(@RequestBody(required = false) Map<String, Object> body, HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> params = Params.merge(body, request);
@@ -85,7 +86,7 @@ public class ApiAddressController {
     }
 
     /** /api/address/remove 删除收货地址 */
-    @RequestMapping(value = "/remove", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/remove")
     public R<Void> remove(@RequestBody(required = false) Map<String, Object> body, HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> params = Params.merge(body, request);

+ 5 - 4
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCaptchaController.java

@@ -6,9 +6,10 @@ import cn.yoshop.common.util.Params;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -24,13 +25,13 @@ public class ApiCaptchaController {
     private final ApiCaptchaService apiCaptchaService;
 
     /** /api/captcha/image 图形验证码(base64 / key / md5) */
-    @RequestMapping(value = "/captcha/image", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/captcha/image")
     public R<Map<String, Object>> image() {
         return R.ok(apiCaptchaService.createImage());
     }
-
+    
     /** /api/captcha/sendSmsCaptcha 发送短信验证码(表单:mobile / captchaCode / captchaKey) */
-    @RequestMapping(value = "/captcha/sendSmsCaptcha", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/captcha/sendSmsCaptcha")
     public R<Void> sendSmsCaptcha(@RequestBody(required = false) Map<String, Object> body,
                                   HttpServletRequest request) {
         Map<String, Object> params = Params.merge(body, request);

+ 7 - 6
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCartController.java

@@ -9,9 +9,10 @@ import cn.yoshop.common.util.Params;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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;
@@ -29,14 +30,14 @@ public class ApiCartController {
     private final ApiCartService apiCartService;
 
     /** /api/cart/list 购物车列表 */
-    @RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/list")
     public R<Map<String, Object>> list(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         return R.ok(apiCartService.list(user));
     }
 
     /** /api/cart/total 购物车商品总数量 */
-    @RequestMapping(value = "/total", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/total")
     public R<Map<String, Object>> total(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> data = new LinkedHashMap<>();
@@ -45,7 +46,7 @@ public class ApiCartController {
     }
 
     /** /api/cart/add 加入购物车 */
-    @RequestMapping(value = "/add", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/add")
     public R<Map<String, Object>> add(@RequestBody(required = false) Map<String, Object> body,
                                       HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -58,7 +59,7 @@ public class ApiCartController {
     }
 
     /** /api/cart/update 更新购物车商品数量 */
-    @RequestMapping(value = "/update", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/update")
     public R<Map<String, Object>> update(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -71,7 +72,7 @@ public class ApiCartController {
     }
 
     /** /api/cart/clear 删除购物车记录(cartIds 为空时清空) */
-    @RequestMapping(value = "/clear", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/clear")
     public R<Map<String, Object>> clear(@RequestBody(required = false) Map<String, Object> body,
                                         HttpServletRequest request) {
         User user = ApiContext.requireUser(request);

+ 5 - 4
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCashierController.java

@@ -8,9 +8,10 @@ import cn.yoshop.common.util.Params;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -26,7 +27,7 @@ public class ApiCashierController {
     private final ApiCashierService apiCashierService;
 
     /** /api/cashier/orderInfo 待支付订单信息(orderId / client) */
-    @RequestMapping(value = "/cashier/orderInfo", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/cashier/orderInfo")
     public R<Map<String, Object>> orderInfo(@RequestBody(required = false) Map<String, Object> body,
                                             HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -37,7 +38,7 @@ public class ApiCashierController {
     }
 
     /** /api/cashier/orderPay 确认支付(orderId / method / client / extra) */
-    @RequestMapping(value = "/cashier/orderPay", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/cashier/orderPay")
     public R<Map<String, Object>> orderPay(@RequestBody(required = false) Map<String, Object> body,
                                            HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -50,7 +51,7 @@ public class ApiCashierController {
     }
 
     /** /api/cashier/tradeQuery 交易查询(outTradeNo / method / client) */
-    @RequestMapping(value = "/cashier/tradeQuery", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/cashier/tradeQuery")
     public R<Map<String, Object>> tradeQuery(@RequestBody(required = false) Map<String, Object> body,
                                              HttpServletRequest request) {
         ApiContext.requireUser(request);

+ 4 - 3
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiCheckoutController.java

@@ -9,9 +9,10 @@ import cn.yoshop.common.util.Params;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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;
@@ -34,7 +35,7 @@ public class ApiCheckoutController {
     private final ApiCheckoutService apiCheckoutService;
 
     /** /api/checkout/order 结算台信息(GET)或提交订单(POST) */
-    @RequestMapping(value = "/order", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/order")
     public R<Map<String, Object>> order(@RequestBody(required = false) Map<String, Object> body,
                                         HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -46,7 +47,7 @@ public class ApiCheckoutController {
     }
 
     /** /api/checkout/submit 提交订单 */
-    @RequestMapping(value = "/submit", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/submit")
     public R<Map<String, Object>> submit(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);

+ 7 - 7
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiContentController.java

@@ -5,9 +5,9 @@ import cn.yoshop.api.support.ApiContext;
 import cn.yoshop.common.api.R;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
 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;
 
 
@@ -26,7 +26,7 @@ public class ApiContentController {
     private final ApiContentService apiContentService;
 
     /** /api/category/list 商品分类树 */
-    @RequestMapping(value = "/category/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/category/list")
     public R<Map<String, Object>> categoryList() {
         Map<String, Object> data = new LinkedHashMap<>();
         data.put("list", apiContentService.categoryList());
@@ -34,7 +34,7 @@ public class ApiContentController {
     }
 
     /** /api/article/list 文章列表(分页 15) */
-    @RequestMapping(value = "/article/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/article/list")
     public R<Map<String, Object>> articleList(@RequestBody(required = false)
                                               Map<String, Object> body,
                                               HttpServletRequest request) {
@@ -47,7 +47,7 @@ public class ApiContentController {
     }
 
     /** /api/article/detail 文章详情(阅读数 +1) */
-    @RequestMapping(value = "/article/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/article/detail")
     public R<Map<String, Object>> articleDetail(@RequestBody(required = false)
                                                 Map<String, Object> body,
                                                 HttpServletRequest request) {
@@ -62,7 +62,7 @@ public class ApiContentController {
     }
 
     /** /api/article.category/list 文章分类 */
-    @RequestMapping(value = "/article.category/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/article.category/list")
     public R<Map<String, Object>> articleCategoryList() {
         Map<String, Object> data = new LinkedHashMap<>();
         data.put("list", apiContentService.articleCategoryList());
@@ -70,7 +70,7 @@ public class ApiContentController {
     }
 
     /** /api/help/list 帮助中心(分页 15) */
-    @RequestMapping(value = "/help/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/help/list")
     public R<Map<String, Object>> helpList(@RequestBody(required = false)
                                            Map<String, Object> body,
                                            HttpServletRequest request) {
@@ -81,7 +81,7 @@ public class ApiContentController {
     }
 
     /** /api/page/detail DIY 页面数据(不传 pageId 取首页) */
-    @RequestMapping(value = "/page/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/page/detail")
     public R<Map<String, Object>> pageDetail(@RequestBody(required = false)
                                              Map<String, Object> body,
                                              HttpServletRequest request) {

+ 7 - 7
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiGoodsController.java

@@ -10,9 +10,9 @@ import cn.yoshop.common.page.PageVO;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
 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;
@@ -31,7 +31,7 @@ public class ApiGoodsController {
     private final ApiGoodsService apiGoodsService;
 
     /** 商品列表(固定只返回上架商品,分页 15) */
-    @RequestMapping(value = "/goods/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/goods/list")
     public R<Map<String, Object>> list(@RequestBody(required = false) Map<String, Object> body,
                                        HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -42,7 +42,7 @@ public class ApiGoodsController {
     }
 
     /** 商品详情(含 SKU / 规格 / 视频) */
-    @RequestMapping(value = "/goods/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/goods/detail")
     public R<Map<String, Object>> detail(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -54,7 +54,7 @@ public class ApiGoodsController {
     }
 
     /** 商品基础信息(仅主信息 + 图片) */
-    @RequestMapping(value = "/goods/basic", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/goods/basic")
     public R<Map<String, Object>> basic(@RequestBody(required = false) Map<String, Object> body,
                                         HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -66,7 +66,7 @@ public class ApiGoodsController {
     }
 
     /** 规格数据:{skuList, specList}(兼容驼峰 /goods/specData) */
-    @RequestMapping(value = {"/goods/spec_data", "/goods/specData"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping({"/goods/spec_data", "/goods/specData"})
     public R<Map<String, Object>> specData(@RequestBody(required = false) Map<String, Object> body,
                                            HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -77,7 +77,7 @@ public class ApiGoodsController {
     }
 
     /** 指定 SKU 信息(兼容驼峰 /goods/skuInfo) */
-    @RequestMapping(value = {"/goods/sku_info", "/goods/skuInfo"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping({"/goods/sku_info", "/goods/skuInfo"})
     public R<Map<String, Object>> skuInfo(@RequestBody(required = false) Map<String, Object> body,
                                           HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -93,7 +93,7 @@ public class ApiGoodsController {
     }
 
     /** 商品服务与承诺 */
-    @RequestMapping(value = "/goods.service/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/goods.service/list")
     public R<Map<String, Object>> serviceList(@RequestBody(required = false) Map<String, Object> body,
                                               HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);

+ 2 - 3
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiIndexController.java

@@ -1,7 +1,7 @@
 package cn.yoshop.api.controller;
 
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -13,8 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/api/index")
 public class ApiIndexController {
 
-    @RequestMapping(value = "/index", method = {RequestMethod.GET, RequestMethod.POST},
-            produces = "text/plain;charset=UTF-8")
+    @GetMapping(value = "/index", produces = "text/plain;charset=UTF-8")
     public String index() {
         return "当前访问的index.php,请将index.html设为默认站点入口";
     }

+ 9 - 8
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiMarketingController.java

@@ -16,9 +16,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.ArrayList;
@@ -42,7 +43,7 @@ public class ApiMarketingController {
     private final cn.yoshop.api.support.ApiView view;
 
     /** /api/comment/list 商品评价(分页 15,scoreType 10/20/30) */
-    @RequestMapping(value = "/comment/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/comment/list")
     public R<Map<String, Object>> commentList(@RequestBody(required = false) Map<String, Object> body,
                                               HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -54,7 +55,7 @@ public class ApiMarketingController {
     }
 
     /** /api/comment/total 评价统计 {all, praise, review, negative} */
-    @RequestMapping(value = "/comment/total", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/comment/total")
     public R<Map<String, Object>> commentTotal(@RequestBody(required = false) Map<String, Object> body,
                                                HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -62,7 +63,7 @@ public class ApiMarketingController {
     }
 
     /** /api/comment/list_rows 限条数评价(默认 5 条,兼容驼峰 /comment/listRows) */
-    @RequestMapping(value = {"/comment/list_rows", "/comment/listRows"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping({"/comment/list_rows", "/comment/listRows"})
     public R<Map<String, Object>> commentListRows(@RequestBody(required = false) Map<String, Object> body,
                                                   HttpServletRequest request) {
         Map<String, Object> params = ApiContext.params(request, body);
@@ -74,7 +75,7 @@ public class ApiMarketingController {
     }
 
     /** /api/coupon/list 优惠券中心 */
-    @RequestMapping(value = "/coupon/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/coupon/list")
     public R<Map<String, Object>> couponList(HttpServletRequest request) {
         List<ObjectNode> list = apiCouponService.list(null, false, null, List.of(), ApiContext.user(request));
         Map<String, Object> data = new LinkedHashMap<>();
@@ -83,7 +84,7 @@ public class ApiMarketingController {
     }
 
     /** /api/myCoupon/list 我的优惠券(dataType:all/isUsable/isUnused/isExpire/isUse,amount 为订单金额) */
-    @RequestMapping(value = "/myCoupon/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/myCoupon/list")
     public R<PageVO<ObjectNode>> myCouponList(@RequestBody(required = false) Map<String, Object> body,
                                              HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -95,7 +96,7 @@ public class ApiMarketingController {
     }
 
     /** /api/myCoupon/receive 领取优惠券 */
-    @RequestMapping(value = "/myCoupon/receive", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/myCoupon/receive")
     public R<Void> myCouponReceive(@RequestBody(required = false) Map<String, Object> body,
                                    HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -104,7 +105,7 @@ public class ApiMarketingController {
     }
 
     /** /api/express/list 物流公司(隐藏 kuaidi100Code / kdniaoCode / sort) */
-    @RequestMapping(value = "/express/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/express/list")
     public R<Map<String, Object>> expressList() {
         List<Express> list = expressMapper.selectList(Wrappers.<Express>lambdaQuery()
                 .orderByAsc(Express::getSort)

+ 10 - 9
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiOrderController.java

@@ -11,9 +11,10 @@ import cn.yoshop.common.util.Params;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.ArrayList;
@@ -33,7 +34,7 @@ public class ApiOrderController {
     private final ApiOrderCommentService apiOrderCommentService;
 
     /** /api/order/list 我的订单(dataType: all/payment/delivery/received/comment) */
-    @RequestMapping(value = "/order/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/order/list")
     public R<Map<String, Object>> list(@RequestBody(required = false) Map<String, Object> body,
                                        HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -44,7 +45,7 @@ public class ApiOrderController {
     }
 
     /** /api/order/detail 订单详情 */
-    @RequestMapping(value = "/order/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/order/detail")
     public R<Map<String, Object>> detail(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -53,7 +54,7 @@ public class ApiOrderController {
     }
 
     /** /api/order/express 物流信息 */
-    @RequestMapping(value = "/order/express", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/order/express")
     public R<Map<String, Object>> express(@RequestBody(required = false) Map<String, Object> body,
                                           HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -64,7 +65,7 @@ public class ApiOrderController {
     }
 
     /** /api/order/cancel 取消订单 */
-    @RequestMapping(value = "/order/cancel", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/order/cancel")
     public R<Void> cancel(@RequestBody(required = false) Map<String, Object> body,
                           HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -73,7 +74,7 @@ public class ApiOrderController {
     }
 
     /** /api/order/receipt 确认收货 */
-    @RequestMapping(value = "/order/receipt", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/order/receipt")
     public R<Void> receipt(@RequestBody(required = false) Map<String, Object> body,
                            HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -83,7 +84,7 @@ public class ApiOrderController {
     }
 
     /** /api/order/todo_counts 待处理订单数量(兼容驼峰 /order/todoCounts) */
-    @RequestMapping(value = {"/order/todo_counts", "/order/todoCounts"}, method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping({"/order/todo_counts", "/order/todoCounts"})
     public R<Map<String, Object>> todoCounts(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         return R.ok(apiOrderService.todoCounts(user));
@@ -92,7 +93,7 @@ public class ApiOrderController {
     // ------------------------------------------------------------------ 评价
 
     /** /api/order.comment/list 待评价订单商品 */
-    @RequestMapping(value = "/order.comment/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/order.comment/list")
     public R<Map<String, Object>> commentList(@RequestBody(required = false) Map<String, Object> body,
                                               HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -104,7 +105,7 @@ public class ApiOrderController {
     }
 
     /** /api/order.comment/submit 提交商品评价(表单为数组:[{orderGoodsId, score, content, uploaded}]) */
-    @RequestMapping(value = "/order.comment/submit", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/order.comment/submit")
     public R<Void> commentSubmit(@RequestBody(required = false) Object body, HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         Map<String, Object> params = Params.merge(null, request);

+ 5 - 5
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiPassportController.java

@@ -7,9 +7,9 @@ import cn.yoshop.common.util.Params;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -25,7 +25,7 @@ public class ApiPassportController {
     private final ApiPassportService apiPassportService;
 
     /** /api/passport/login 手机号 + 短信验证码登录(自动注册) */
-    @RequestMapping(value = "/passport/login", method = {RequestMethod.POST})
+    @PostMapping("/passport/login")
     public R<Map<String, Object>> login(@RequestBody(required = false) Map<String, Object> body,
                                         HttpServletRequest request) {
         Map<String, Object> form = Params.merge(body, request);
@@ -33,7 +33,7 @@ public class ApiPassportController {
     }
 
     /** /api/passport/loginMpWx 微信小程序一键登录 */
-    @RequestMapping(value = "/passport/loginMpWx", method = {RequestMethod.POST})
+    @PostMapping("/passport/loginMpWx")
     public R<Map<String, Object>> loginMpWx(@RequestBody(required = false) Map<String, Object> body,
                                             HttpServletRequest request) {
         Map<String, Object> form = Params.merge(body, request);
@@ -41,7 +41,7 @@ public class ApiPassportController {
     }
 
     /** /api/passport/loginMpWxMobile 微信小程序授权手机号登录 */
-    @RequestMapping(value = "/passport/loginMpWxMobile", method = {RequestMethod.POST})
+    @PostMapping("/passport/loginMpWxMobile")
     public R<Map<String, Object>> loginMpWxMobile(@RequestBody(required = false) Map<String, Object> body,
                                                   HttpServletRequest request) {
         Map<String, Object> form = Params.merge(body, request);
@@ -49,7 +49,7 @@ public class ApiPassportController {
     }
 
     /** /api/passport/isPersonalMpweixin 是否需要填写昵称头像(前端 POST 提交 code) */
-    @RequestMapping(value = "/passport/isPersonalMpweixin", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/passport/isPersonalMpweixin")
     public R<Map<String, Object>> isPersonalMpweixin(@RequestBody(required = false) Map<String, Object> body,
                                                      HttpServletRequest request) {
         Map<String, Object> params = Params.merge(body, request);

+ 6 - 5
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRechargeController.java

@@ -10,9 +10,10 @@ import cn.yoshop.common.util.Params;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -28,7 +29,7 @@ public class ApiRechargeController {
     private final ApiRechargeService apiRechargeService;
 
     /** /api/recharge/center 充值中心(client 为当前客户端) */
-    @RequestMapping(value = "/recharge/center", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/recharge/center")
     public R<Map<String, Object>> center(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -37,7 +38,7 @@ public class ApiRechargeController {
     }
 
     /** /api/recharge/submit 确认充值订单(表单:method / client / planId / customMoney / extra) */
-    @RequestMapping(value = "/recharge/submit", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/recharge/submit")
     public R<Map<String, Object>> submit(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -47,7 +48,7 @@ public class ApiRechargeController {
     }
 
     /** /api/recharge/tradeQuery 交易查询(outTradeNo / method / client) */
-    @RequestMapping(value = "/recharge/tradeQuery", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/recharge/tradeQuery")
     public R<Map<String, Object>> tradeQuery(@RequestBody(required = false) Map<String, Object> body,
                                              HttpServletRequest request) {
         Map<String, Object> params = Params.merge(body, request);
@@ -58,7 +59,7 @@ public class ApiRechargeController {
     }
 
     /** /api/recharge.order/list 我的充值记录(分页 15) */
-    @RequestMapping(value = "/recharge.order/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/recharge.order/list")
     public R<PageVO<ObjectNode>> orderList(@RequestBody(required = false) Map<String, Object> body,
                                            HttpServletRequest request) {
         User user = ApiContext.requireUser(request);

+ 7 - 6
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRefundController.java

@@ -11,9 +11,10 @@ import cn.yoshop.common.util.Params;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -29,7 +30,7 @@ public class ApiRefundController {
     private final ApiRefundService apiRefundService;
 
     /** /api/refund/list 售后单列表(state 默认 -1 全部) */
-    @RequestMapping(value = "/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/list")
     public R<PageVO<ObjectNode>> list(@RequestBody(required = false) Map<String, Object> body,
                                       HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -40,7 +41,7 @@ public class ApiRefundController {
     }
 
     /** /api/refund/goods 申请售后前的订单商品信息 */
-    @RequestMapping(value = "/goods", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/goods")
     public R<Map<String, Object>> goods(@RequestBody(required = false) Map<String, Object> body,
                                         HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -49,7 +50,7 @@ public class ApiRefundController {
     }
 
     /** /api/refund/apply 申请售后(表单:type / content / images[]) */
-    @RequestMapping(value = "/apply", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/apply")
     public R<Void> apply(@RequestBody(required = false) Map<String, Object> body,
                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -58,7 +59,7 @@ public class ApiRefundController {
     }
 
     /** /api/refund/detail 售后单详情 */
-    @RequestMapping(value = "/detail", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/detail")
     public R<Map<String, Object>> detail(@RequestBody(required = false) Map<String, Object> body,
                                          HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -67,7 +68,7 @@ public class ApiRefundController {
     }
 
     /** /api/refund/delivery 用户发货(表单:expressId / expressNo) */
-    @RequestMapping(value = "/delivery", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/delivery")
     public R<Void> delivery(@RequestBody(required = false) Map<String, Object> body,
                             HttpServletRequest request) {
         User user = ApiContext.requireUser(request);

+ 3 - 3
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiRegionController.java

@@ -4,8 +4,8 @@ import cn.yoshop.common.api.R;
 import cn.yoshop.store.service.RegionService;
 
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
 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;
@@ -22,14 +22,14 @@ public class ApiRegionController {
 
     private final RegionService regionService;
 
-    @RequestMapping(value = "/all", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/all")
     public R<Map<String, Object>> all() {
         Map<String, Object> data = new LinkedHashMap<>();
         data.put("list", regionService.getAll());
         return R.ok(data);
     }
 
-    @RequestMapping(value = "/tree", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/tree")
     public R<Map<String, Object>> tree() {
         Map<String, Object> data = new LinkedHashMap<>();
         data.put("list", regionService.getTree());

+ 3 - 3
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiStoreController.java

@@ -6,8 +6,8 @@ import cn.yoshop.common.api.R;
 
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Map;
@@ -23,13 +23,13 @@ public class ApiStoreController {
     private final ApiSettingService apiSettingService;
 
     /** /api/store/data:{storeInfo, client, setting, clientData} */
-    @RequestMapping(value = "/store/data", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/store/data")
     public R<Map<String, Object>> storeData(HttpServletRequest request) {
         return R.ok(apiSettingService.storeData(ApiContext.platform(request)));
     }
 
     /** /api/setting/data:仅暴露可公开的设置项 */
-    @RequestMapping(value = "/setting/data", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/setting/data")
     public R<Map<String, Object>> settingData() {
         return R.ok(apiSettingService.settingData());
     }

+ 2 - 2
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiUploadController.java

@@ -9,8 +9,8 @@ import cn.yoshop.store.service.UploadService;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
@@ -39,7 +39,7 @@ public class ApiUploadController {
     private final ApiView view;
 
     /** /api/upload/image 图片上传 */
-    @RequestMapping(value = "/image", method = {RequestMethod.POST})
+    @PostMapping("/image")
     public R<Map<String, Object>> image(@RequestParam(value = "file", required = false) MultipartFile file,
                                         @RequestParam(value = "checkLogin", required = false, defaultValue = "1")
                                         int checkLogin,

+ 8 - 7
yoshop-java/src/main/java/cn/yoshop/api/controller/ApiUserController.java

@@ -11,9 +11,10 @@ import cn.yoshop.common.util.Params;
 import tools.jackson.databind.node.ObjectNode;
 import jakarta.servlet.http.HttpServletRequest;
 import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 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.Map;
@@ -30,21 +31,21 @@ public class ApiUserController {
     private final ApiLogService apiLogService;
 
     /** /api/user/info 当前用户详情 */
-    @RequestMapping(value = "/user/info", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/user/info")
     public R<Map<String, Object>> info(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         return R.ok(apiUserService.info(user));
     }
 
     /** /api/user/assets 账户资产(余额 / 积分 / 可用优惠券数量) */
-    @RequestMapping(value = "/user/assets", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/user/assets")
     public R<Map<String, Object>> assets(HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
         return R.ok(apiUserService.assets(user));
     }
 
     /** /api/user/bindMobile 绑定手机号(表单:mobile / smsCode) */
-    @RequestMapping(value = "/user/bindMobile", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/user/bindMobile")
     public R<Void> bindMobile(@RequestBody(required = false) Map<String, Object> body,
                               HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -52,7 +53,7 @@ public class ApiUserController {
     }
 
     /** /api/user/personal 修改个人信息(表单:avatarId / nickName) */
-    @RequestMapping(value = "/user/personal", method = {RequestMethod.GET, RequestMethod.POST})
+    @PostMapping("/user/personal")
     public R<Void> personal(@RequestBody(required = false) Map<String, Object> body,
                             HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -60,7 +61,7 @@ public class ApiUserController {
     }
 
     /** /api/balance.log/list 余额账单明细(分页 15) */
-    @RequestMapping(value = "/balance.log/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/balance.log/list")
     public R<PageVO<ObjectNode>> balanceList(@RequestBody(required = false) Map<String, Object> body,
                                              HttpServletRequest request) {
         User user = ApiContext.requireUser(request);
@@ -69,7 +70,7 @@ public class ApiUserController {
     }
 
     /** /api/points.log/list 积分明细(分页 15) */
-    @RequestMapping(value = "/points.log/list", method = {RequestMethod.GET, RequestMethod.POST})
+    @GetMapping("/points.log/list")
     public R<PageVO<ObjectNode>> pointsList(@RequestBody(required = false) Map<String, Object> body,
                                             HttpServletRequest request) {
         User user = ApiContext.requireUser(request);