{"id":49,"date":"2026-04-05T19:15:46","date_gmt":"2026-04-05T11:15:46","guid":{"rendered":"https:\/\/blog.higgus17.cloud\/?p=49"},"modified":"2026-04-05T21:24:38","modified_gmt":"2026-04-05T13:24:38","slug":"%e8%8a%8b%e9%81%93%e4%bb%a3%e7%a0%81%e8%a7%a3%e6%9e%90%ef%bc%880%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.higgus17.cloud\/?p=49","title":{"rendered":"\u828b\u9053\u4ee3\u7801\u89e3\u6790-\u540e\u7aef\u7bc7\uff080\uff09"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-left\">\u6c5f\u7554\u4f55\u4eba\u521d\u89c1\u6708\uff1f\u6c5f\u6708\u4f55\u5e74\u521d\u7167\u4eba\uff1f<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u4eba\u751f\u4ee3\u4ee3\u65e0\u7a77\u5df2\uff0c\u6c5f\u6708\u5e74\u5e74\u671b\u76f8\u4f3c\u3002<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u4e0d\u77e5\u6c5f\u6708\u5f85\u4f55\u4eba\uff0c\u4f46\u89c1\u957f\u6c5f\u9001\u6d41\u6c34\u3002<\/p>\n\n\n\n<p class=\"has-text-align-right\">\u2014\u2014\u5510\u00b7\u5f20\u82e5\u865a\u300a\u6625\u6c5f\u82b1\u6708\u591c\u300b<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5148\u4e0d\u770b\u6240\u6709\u7684\u79df\u6237\u7ba1\u7406\u3001\u5b89\u5168\u7ba1\u7406\u548c\u6846\u67b6\u90e8\u5206\uff0c\u5148\u4ece\u4e00\u4e2a\u5b8c\u6574\u7684\u524d\u7aef\u8bf7\u6c42\u94fe\u8def\u6765\u770b\u828b\u9053\u4e2d\u4e00\u4e2a\u6700\u5178\u578b\u7684\u8bf7\u6c42\u7684\u5b8c\u6574\u540e\u7aef\u884c\u4e3a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Controller \u90e8\u5206<\/h3>\n\n\n\n<p>Controller \u76d1\u542c\u6765\u81ea\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\uff0c\u4e5f\u5c31\u662f\u6765\u81ea\u524d\u7aef\u7684 HTTP \u8bf7\u6c42\uff08\u786e\u5207\u5730\u8bf4\uff0c\u662f Restful API \u8bf7\u6c42\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Tag(name = \"\u7ba1\u7406\u540e\u53f0 - \u5546\u54c1 SPU\")\n@RestController\n@RequestMapping(\"\/product\/spu\")\n@Validated\npublic class ProductSpuController {\n    @Resource\n    private ProductSpuService productSpuService;\n    @Resource\n    private ProductSkuService productSkuService;\n...\n    @GetMapping(\"\/get-detail\")\n    @Operation(summary = \"\u83b7\u5f97\u5546\u54c1 SPU \u660e\u7ec6\")\n    @Parameter(name = \"id\", description = \"\u7f16\u53f7\", required = true, example = \"1024\")\n    @PreAuthorize(\"@ss.hasPermission('product:spu:query')\")\n    public CommonResult&lt;ProductSpuRespVO> getSpuDetail(@RequestParam(\"id\") Long id) {\n        \/\/ \u83b7\u5f97\u5546\u54c1 SPU\n        ProductSpuDO spu = productSpuService.getSpu(id);\n        if (spu == null) {\n            return success(null);\n        }\n        \/\/ \u67e5\u8be2\u5546\u54c1 SKU\n        List&lt;ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());\n        return success(ProductSpuConvert.INSTANCE.convert(spu, skus));\n    }\n...<\/code><\/pre>\n\n\n\n<p>\u9996\u5148\u5b9a\u4e49\u8be5\u7c7b\u4e3a\u4e00\u4e2a RestController\uff0c\u4fbf\u4e8e Spring Boot \u626b\u63cf\u3001\u6ce8\u518c\u3001\u8fdb\u884c\u7ba1\u7406\uff0c\u63a5\u7740\u5b9a\u4e49\u8be5 Controller \u7ba1\u7406\u7684\u5168\u5c40\u8bf7\u6c42\u7684\u8def\u7531\u8fde\u63a5 \/product\/spu\uff0c\u5176\u4ed6\u7684\u6ce8\u89e3\u5927\u591a\u662f\u7528\u4e8e\u56e2\u961f\u534f\u4f5c\u7684\u6587\u6863\u578b\u6ce8\u89e3\u3002<\/p>\n\n\n\n<p>\u63a5\u7740\uff0c\u542f\u52a8 Service \u5b9e\u4f8b\u3002\u6211\u4eec\u8981\u7528\u5230\u7684\u5927\u90e8\u5206\u4e1a\u52a1\u4ee3\u7801\uff0c\u90fd\u4f1a\u901a\u8fc7\u8be5\u5b9e\u4f8b\u8fdb\u884c\u8c03\u7528\uff0c\u4ece\u800c\u9690\u85cf\u4e86\u5177\u4f53\u7684\u4e1a\u52a1\u903b\u8f91\u7ec6\u8282\uff0c\u5b9e\u73b0\u4e86\u89e3\u8026\u7684\u76ee\u7684\u3002\u89e3\u8026\u4f7f\u4ee3\u7801\u66f4\u52a0\u6613\u4e8e\u56e2\u961f\u534f\u4f5c\u548c\u7ef4\u62a4\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@RestController\n@RequestMapping(\"\/product\/spu\")\npublic class ProductSpuController {\n    @Resource\n    private ProductSpuService productSpuService;\n    @Resource\n    private ProductSkuService productSkuService;\n...\n}<\/code><\/pre>\n\n\n\n<p>\u968f\u540e\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u5177\u4f53\u5b9e\u73b0\u7684 Controller \u7c7b\u65b9\u6cd5\u3002\u4ee5 getSpuDetail \u4e3a\u4f8b\u3002\u9996\u5148\uff0c\u8be5\u65b9\u6cd5\u7684\u6838\u5fc3\u6ce8\u89e3 @GetMapping \u5b9a\u4e49\u4e86\u5177\u4f53\u7684\u8def\u7531 \/get-detail\uff0c\u968f\u540e\u6ce8\u89e3 @PreAuthorize \u5219\u68c0\u67e5\u4e86\u7528\u6237\u7684\u5177\u4f53\u6743\u9650\uff0c\u4f5c\u4e86\u5b89\u5168\u7684\u6743\u9650\u5904\u7406\uff0c\u5982\u679c\u5b58\u5728\u95ee\u9898\u5219\u4f1a\u76f4\u63a5\u62e6\u622a\uff0c\u4e0d\u518d\u7ee7\u7eed\u65b9\u6cd5\uff0c\u8fd4\u56de\u7ed9\u524d\u7aef\u5bf9\u5e94\u7684\u9519\u8bef\u3002<\/p>\n\n\n\n<p>\u5728\u5177\u4f53\u7684\u65b9\u6cd5\u5b9a\u4e49\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u89c1\uff0c\u65b9\u6cd5 getSpuDetail \u7684\u8f93\u51fa\u662f CommonResult&lt;T>\uff0c\u8fd9\u91cc\u7684 T \u662f ProductSpuRespVO\uff0c\u662f\u4e00\u4e2a\u4e13\u95e8\u5b9a\u4e49\u8fc7\u7684\u7528\u4e8e\u524d\u7aef\u5c55\u793a\u7684<strong>\u89c6\u56fe\u5bf9\u8c61\uff08View Object\uff09<\/strong>\uff0c\u63a5\u53d7\u7684\u8f93\u5165\u5219\u662f\u7ecf\u8fc7\u6ce8\u89e3\u7684@RequestParam Long id\u3002<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>\u5173\u4e8e @RequestParam<\/summary>\n<p>\u5728\u4e00\u822c\u7684 java \u65b9\u6cd5\u83b7\u53d6\u8f93\u5165\u65f6\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5199\u8f93\u5165\u7684\u7c7b\u578b\u548c\u53d8\u91cf\u540d\u5c31\u597d\u3002\u4e3a\u4ec0\u4e48\u8fd9\u4e2a\u65b9\u6cd5\u8981\u5728\u8f93\u5165\u4e2d\u4f7f\u7528\u6ce8\u89e3\u5462\uff1f\u56e0\u4e3a\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u7684 Controller \u83b7\u5f97\u7684\u8bf7\u6c42\u5b9e\u9645\u4e0a\u662f\u4e00\u4e2a\u5b8c\u6574\u7684 HTTP \u8bf7\u6c42\uff0c\u800c\u5177\u4f53\u5230\u8bf7\u6c42\u7684\u8d44\u6e90\u8def\u5f84\uff0c\u4e5f\u662f\u4e00\u4e2a\u5f88\u957f\u7684 URL\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u5177\u4f53\u7684 java \u7c7b\u578b\u7684\u53d8\u91cf\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u6ce8\u89e3 @RequestParam \u5bf9\u8be5 URL \u8fdb\u884c\u4e86\u89e3\u6790\uff0c\u6839\u636e\u65b9\u6cd5\u5b9a\u4e49\u7684\u53d8\u91cf\u540d\u627e\u51fa\u5bf9\u5e94\u7684 key-value\uff08\u672c\u65b9\u6cd5\u4e2d\uff0c\u4e5f\u5c31\u662f id\uff09\uff0c\u5e76\u5bf9\u539f\u672c\u662f String \u7c7b\u578b\u7684 value \u8fdb\u884c\u8f6c\u6362\uff0c\u8f6c\u6362\u4e3a\u65b9\u6cd5\u5b9a\u4e49\u7684\u7c7b\u578b Long\u3002\u5982\u679c\u8f6c\u6362\u5931\u8d25\uff0c\u5219\u4f1a\u5728\u8fd9\u91cc\u8fdb\u884c return \u8fd4\u56de\uff0c\u800c\u4e0d\u662f\u7ee7\u7eed\u6267\u884c\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u4e8e\u662f\u505a\u5b8c\u6240\u6709\u7684\u5de5\u4f5c\u540e\uff0c\u65b9\u6cd5 getSpuDetail \u63a5\u6536\u5230\u7684\u8f93\u5165\u5c31\u662f\u4e00\u4e2a Long \u7c7b\u578b\u7684\u5177\u4f53\u6570\u503c\u4e86\u3002<\/p>\n<\/details>\n\n\n\n<p>\u901a\u8fc7\u8c03\u7528 Service \u5b9e\u4f8b\u7684 getSpu \u65b9\u6cd5\uff0c\u6211\u4eec\u83b7\u5f97\u4e86\u4e00\u4e2a ProductSpuDO \u7c7b\u578b\u7684 spu \u53d8\u91cf\u3002<em>\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u9700\u8981\u6709\u4e00\u4e2a\u4fe1\u5ff5\uff0c<strong>\u5373\u6211\u76f8\u4fe1\u8fd9\u4e2a\u65b9\u6cd5\u8fd4\u56de\u7ed9\u6211\u7684\u662f\u4e00\u4e2a\u6b63\u5e38\u6b63\u786e\u7684\u503c<\/strong>\uff0c\u8fd9\u4e5f\u662f\u5206\u5c42\u7684\u610f\u4e49\u6240\u5728\uff0c\u6bcf\u4e00\u5c42\u505a\u597d\u81ea\u5df1\u8d1f\u8d23\u7684\u5de5\u4f5c\u5185\u5bb9\uff0c\u4e3a\u5176\u4ed6\u5c42\u63d0\u4f9b\u5bf9\u5e94\u7684\u670d\u52a1\u5e76\u4fdd\u8bc1\u53ef\u9760\u7684\u4ea4\u4ed8\u6210\u679c\u3002<\/em><\/p>\n\n\n\n<p>\u968f\u540e\uff0c\u5982\u679c\u8be5 spu \u53d8\u91cf\u5b58\u50a8\u7684\u5bf9\u5e94\u6570\u636e\u4fe1\u606f\u662f\u4e0d\u4e3a\u7a7a\u7684\uff0c\u4e5f\u5c31\u662f\u6709\u6b63\u5e38\u5b58\u50a8\u5185\u5bb9\u7684\uff0c\u7ee7\u7eed\u6267\u884c\u8be5\u65b9\u6cd5\uff1b\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u76f4\u63a5\u8fd4\u56de\u4ee5 success \u65b9\u6cd5\u5904\u7406\u7a7a\u503c\u7684\u7ed3\u679c\uff0c\u56e0\u4e3a\u5728\u4e0e\u524d\u7aef\u7684\u4ea4\u4e92\u4e2d\uff0c\u6211\u4eec\u662f\u4ee5 Restful API \u7684\u5f62\u5f0f\u4ea4\u4e92\u7684\uff0c\u80af\u5b9a\u4e0d\u80fd\u53ea\u8fd4\u56de\u4e00\u4e2a null \u503c\u2014\u2014\u8fd9\u5728\u6211\u4eec\u7684\u65b9\u6cd5\u5b9a\u4e49\u4e2d\u4e5f\u6709\u8868\u73b0\uff0c\u8fd4\u56de\u7684\u662f\u4e00\u4e2a CommonResult&lt;T> \u7ed3\u679c\u3002<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>success \u51fd\u6570\u5177\u4f53\u5b9e\u73b0<\/summary>\n<pre class=\"wp-block-code\"><code>public static &lt;T> CommonResult&lt;T> success(T data) {<br>    CommonResult&lt;T> result = new CommonResult&lt;>();<br>    result.code = GlobalErrorCodeConstants.<em>SUCCESS<\/em>.getCode();<br>    result.data = data;<br>    result.msg = \"\";<br>    return result;<br>}<br><br><\/code><\/pre>\n<\/details>\n\n\n\n<p>\u63a5\u4e0b\u6765\u7684\u903b\u8f91\u4e5f\u5927\u4f53\u76f8\u540c\u3002\u521a\u624d\u6211\u4eec\u83b7\u5f97\u4e86 spu \u7684\u5177\u4f53\u5185\u5bb9\uff0c\u968f\u540e\u901a\u8fc7 Sku Service \u5b9e\u4f8b\u8c03\u7528\u5bf9\u5e94\u7684\u65b9\u6cd5\uff0c\u67e5\u8be2\u8be5 spu id \u5bf9\u5e94\u7684\u5177\u4f53\u660e\u7ec6\uff0c\u83b7\u5f97\u5bf9\u5e94\u6570\u636e\u7ed3\u6784\u7c7b\u578b List&lt;ProductSkuDO> \u7684\u5177\u4f53\u6570\u636e\u7ed3\u679c\uff0c\u5b58\u50a8\u5728 skus \u53d8\u91cf\u4e2d\uff0c\u5e76\u8c03\u7528 success \u65b9\u6cd5\u8fdb\u884c\u8fd4\u56de\u5177\u4f53\u83b7\u53d6\u7684 data \u5185\u5bb9\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    @GetMapping(\"\/get-detail\")\n    @Operation(summary = \"\u83b7\u5f97\u5546\u54c1 SPU \u660e\u7ec6\")\n    @Parameter(name = \"id\", description = \"\u7f16\u53f7\", required = true, example = \"1024\")\n    @PreAuthorize(\"@ss.hasPermission('product:spu:query')\")\n    public CommonResult&lt;ProductSpuRespVO> getSpuDetail(@RequestParam(\"id\") Long id) {\n        \/\/ \u83b7\u5f97\u5546\u54c1 SPU\n        ProductSpuDO spu = productSpuService.getSpu(id);\n        if (spu == null) {\n            return success(null);\n        }\n        \/\/ \u67e5\u8be2\u5546\u54c1 SKU\n        List&lt;ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId());\n        return success(ProductSpuConvert.INSTANCE.convert(spu, skus));\n    }<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Service \u90e8\u5206<\/h3>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u8c08\u8bba Service \u90e8\u5206\u3002\u4ee5 ProductSpuService \u4e3a\u4f8b\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u6211\u4eec\u6765\u5230\u6e90\u7801\u90e8\u5206\u3002<\/p>\n\n\n\n<p>\u5f53\u6211\u4eec\u8fdb\u5165 ProductSpuService.java \u6587\u4ef6\u7684\u65f6\u5019\uff0c\u4f1a\u53d1\u73b0\u5b83\u662f\u4e00\u4e2a\u5b9a\u4e49\u7684\u63a5\u53e3\u3002\u8fd9\u662f\u4e00\u79cd\u8bbe\u8ba1\u6a21\u5f0f\u2014\u2014<strong>\u9762\u5411\u63a5\u53e3\u7f16\u7a0b<\/strong>\u3002\u5728\u8be5\u63a5\u53e3\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u6211\u4eec\u6240\u9700\u7684\u6240\u6709\u65b9\u6cd5\u2014\u2014\u6211\u4eec<strong>\u76f8\u4fe1<\/strong>\u8fd9\u4e9b\u65b9\u6cd5\u662f\u4efb\u4f55\u5b9e\u73b0\u63a5\u53e3\u65f6\u5fc5\u987b\u5b9e\u73b0\u7684\u6838\u5fc3\u65b9\u6cd5\u2014\u2014\u6362\u53e5\u8bdd\u8bf4\uff0c\u6211\u4eec<strong>\u8ba4\u4e3a<\/strong>\uff0c\u5b9e\u73b0\u8fd9\u4e2a Service \u670d\u52a1\uff0c<strong>\u5fc5\u987b<\/strong>\u8981\u6709\u8fd9\u4e9b\u65b9\u6cd5\u7684\u5b9e\u73b0\u3002\u56e0\u6b64\u6211\u4eec\u9884\u5148\u505a\u4e86\u5b9a\u4e49\u3002\u8fd9\u662f\u4e00\u79cd\u975e\u5e38\u89c4\u8303\u7684\u67b6\u6784\u8bbe\u8ba1\u601d\u7ef4\u3002<\/p>\n\n\n\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0c\u5982\u679c\u5728\u50cf Java \u8fd9\u6837\u7684\u5f3a\u7c7b\u578b\u8bed\u8a00\u4e2d\uff0c\u63a5\u53e3\u5b9a\u4e49\u7684\u65b9\u6cd5\u6ca1\u6709\u88ab\u5b9e\u73b0\uff0c\u90a3\u4e48\u5728\u7f16\u8bd1\u9636\u6bb5\u7f16\u8bd1\u5668\u5c31\u4f1a\u51fa\u73b0\u62a5\u9519\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public interface ProductSpuService {\n    \/**\n     * \u83b7\u5f97\u5546\u54c1 SPU\n     *\n     * @param id \u7f16\u53f7\n     * @param includeDeleted \u662f\u5426\u5305\u542b\u5df2\u5220\u9664\u7684\n     * @return \u5546\u54c1 SPU\n     *\/\n    ProductSpuDO getSpu(Long id, boolean includeDeleted);\n}<\/code><\/pre>\n\n\n\n<p>\u5bf9\u5e94\u7684\u5177\u4f53\u5b9e\u73b0\uff0c\u5728 ProductSpuServiceImpl.java \u6587\u4ef6\u4e2d\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\uff0c\u8be5\u7c7b ProductSpuServiceImpl \u662f\u63a5\u53e3\uff08interface\uff09\u7684\u4e00\u4e2a\u5b9e\u73b0\uff08implement\uff09\u3002<\/p>\n\n\n\n<p>\u5728\u5177\u4f53\u7684\u5b9e\u73b0\u4e0a\uff0c\u9996\u5148\u8ba8\u8bba\u6ce8\u89e3\u3002@Service \u6ce8\u89e3\u544a\u8bc9 Spring Boot\uff0c\u8be5\u7c7b\u662f\u4e00\u4e2a Service\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Service\n@Validated\npublic class ProductSpuServiceImpl implements ProductSpuService {\n\n    @Resource\n    private ProductSpuMapper productSpuMapper;\n\n    @Resource\n    @Lazy \/\/ \u5faa\u73af\u4f9d\u8d56\uff0c\u907f\u514d\u62a5\u9519\n    private ProductSkuService productSkuService;\n\n...\n\n}<\/code><\/pre>\n\n\n\n<p>\u6211\u4eec\u8be6\u7ec6\u770b Controller \u4e2d\u5b9e\u4f8b\u8c03\u7528\u7684  getSpu()\u65b9\u6cd5\u7684\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u9996\u5148\uff0c@Override \u662f\u4e00\u4e2a\u8986\u5199\u6ce8\u89e3\u3002\u8bf4\u660e\u6211\u8981\u91cd\u5199\u8fd9\u4e2a\u65b9\u6cd5\u4e86\u3002\u8fd9\u91cc\u7684\u4e1a\u52a1\u903b\u8f91\u5f88\u7b80\u5355\uff0c\u8be5\u65b9\u6cd5\u6709\u4e24\u4e2a\u5177\u4f53\u7684\u4e1a\u52a1\u5b9e\u73b0\uff0c\u4e00\u4e2a\u662f\u7b80\u5355\u7684\u67e5\u8be2\u903b\u8f91\uff0c\u53e6\u4e00\u4e2a\u662f\u5305\u542b\u662f\u5426\u67e5\u8be2\u5df2\u5220\u9664\u7684\u903b\u8f91\u3002\u8fd9\u5e76\u4e0d\u662f\u591a\u6b64\u4e00\u4e3e\uff0c\u5728\u4e0d\u540c\u7684\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u952e\u5165\u4e0d\u540c\u7684\u53c2\u6570\u6765\u5b9e\u73b0\u4e0d\u540c\u7684\u67e5\u8be2\u903b\u8f91\u3002\u8fd4\u56de\u7684\u7ed3\u679c\u90fd\u662f ProductSpuDO \u7c7b\u578b\u7684\u6570\u636e\uff0c\u63a5\u6536 Long id \u7c7b\u578b\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u5177\u4f53\u662f\u5982\u4f55\u5b9e\u73b0\u67e5\u8be2\u7684\u5462\uff1f\u903b\u8f91\u4e0a\uff0c\u6211\u4eec\u53ea\u770b\u5230\u8be5\u65b9\u6cd5\u8c03\u7528\u4e86 productSpuMapper \u5b9e\u4f8b\u7684 selectById \u65b9\u6cd5\u3002\u6211\u4eec\u53ef\u4ee5\u6ce8\u610f\u5230\uff0c\u6570\u636e\u5e93\u7684\u5177\u4f53\u64cd\u4f5c\u88ab\u7ee7\u7eed\u9690\u85cf\u8d77\u6765\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    @Override\n    public ProductSpuDO getSpu(Long id) {\n        return productSpuMapper.selectById(id);\n    }\n\n    @Override\n    public ProductSpuDO getSpu(Long id, boolean includeDeleted) {\n        if (includeDeleted) {\n            return productSpuMapper.selectByIdIncludeDeleted(id);\n        }\n        return getSpu(id);\n    }<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Mapper<\/h2>\n\n\n\n<p>Mapper\u5c42\u662f\u4e0e\u6570\u636e\u5e93\u4ea4\u4e92\u7684\u6838\u5fc3\u5c42\u6b21\u3002\u7531\u5b83\u7684\u540d\u5b57\uff08\u6620\u5c04\uff09\uff0c\u5c31\u53ef\u4ee5\u5f88\u76f4\u89c2\u5730\u5f97\u77e5\u8fd9\u4e00\u70b9\u3002\u5728\u8fd9\u91cc\uff0c\u6211\u4eec\u4e3b\u8981\u4f7f\u7528\u4e86 MyBatis-Plus \u8fd9\u4e2a\u5305\u3002@Mapper \u6ce8\u89e3\u544a\u8bc9 Spring Boot\uff0c\u8fd9\u4e2a interface \u662f\u4e00\u4e2a Mapper\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Mapper\npublic interface ProductSpuMapper extends BaseMapperX&lt;ProductSpuDO> {\n...\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u6709\u4e00\u4e2a\u975e\u5e38\u6709\u8da3\u7684 MyBatis-plus \u5305\u7684\u7279\u6027\u3002\u5982\u679c\u6211\u4eec\u4ed4\u7ec6\u8bfb\u4e86 ProductSpuMapper \u7684\u6e90\u7801\uff0c\u6211\u4eec\u4f1a\u53d1\u73b0\uff0cServiceImpl \u4e2d\u8c03\u7528\u4e86\u975e\u5e38\u591a\u5728\u8be5 Mapper \u4e2d\u6ca1\u6709\u58f0\u660e\u7684\u65b9\u6cd5\u3002\u8fd9\u662f\u56e0\u4e3a Mapper \u7ee7\u627f\u4e86 BaseMapperX&lt;T>\uff0c\u5728\u7236\u7c7b\u4e2d\uff0c\u5df2\u7ecf\u6709\u4e86\u5bf9\u5e94\u7684\u57fa\u7840 CURD \u65b9\u6cd5\uff0c\u56e0\u6b64\u5b50\u7c7b\u4e2d\u5e76\u4e0d\u9700\u8981\u518d\u91cd\u5199\u8fd9\u4e9b\uff0c\u5982\u679c\u9700\u8981\u91cd\u5199\uff0c\u4f7f\u7528 @Override \u8fdb\u884c\u91cd\u5199\u65b9\u6cd5\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/p>\n\n\n\n<p>\u5230\u8fd9\u91cc\uff0c\u4eff\u4f5b\u4e00\u5207\u90fd\u7ed3\u675f\u4e86\u3002\u90a3\u4e48\uff0c\u6570\u636e\u5e93\u8fde\u63a5\u5462\uff1f\u6211\u4eec\u662f\u5982\u4f55\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u8fde\u63a5\u4ea4\u4e92\u7684\uff1f\u4e0d\u662f\u9700\u8981\u5199 jdbc \u548c\u5177\u4f53\u7684 SQL \u8bed\u53e5\u5417\uff1f\u6211\u4eec\u77e5\u9053\uff0c\u6ca1\u6709\u8fd9\u4e9b\uff0c\u7a0b\u5e8f\u662f\u4e0d\u77e5\u9053\u5982\u4f55\u627e\u5230\u6570\u636e\u5e93\uff0c\u66f4\u4e0d\u77e5\u9053\u5982\u4f55\u4e0e\u4e4b\u4ea4\u4e92\uff0c\u8fdb\u884c\u4ec0\u4e48\u6837\u7684\u4ea4\u4e92\u7684\u3002\u90a3\u4e48\u8fd9\u4e9b\u5177\u4f53\u7684\u4ee3\u7801\u90fd\u5728\u54ea\u91cc\uff1f<\/p>\n\n\n\n<p>\u5728\u8fd9\u91cc\uff0c\u4ee5\u4e0a\u7684\u884c\u4e3a\u662f\u7531 MyBatis-Plus \u5f15\u64ce\u81ea\u52a8\u5904\u7406\u7684\u3002\u9996\u5148\uff0c\u6211\u4eec\u7684\u914d\u7f6e\u6587\u4ef6 application.yaml \u4e2d\u4f1a\u5b9a\u4e49\u6570\u636e\u6e90\u7684 jdbc\uff0c\u5728\u7a0b\u5e8f\u542f\u52a8\u6267\u884c\u65f6\uff0c\u914d\u7f6e\u6587\u4ef6\u5c06\u4f1a\u88ab Spring Boot \u626b\u63cf\u548c\u8bfb\u53d6\uff0c\u7531\u6b64\u786e\u5b9a\u7684\u5bf9\u5e94\u7684\u6570\u636e\u6e90\u4f4d\u7f6e\u6765\u8fdb\u884c\u901a\u4fe1\u3002\u53c8\u662f\u5728\u4ec0\u4e48\u5730\u65b9\u751f\u6210\u90a3\u4e9b\u5e76\u4e0d\u9700\u8981\u6211\u4eec\u7f16\u5199\u7684\u5bf9\u5e94\u7684 SQL \u8bed\u53e5\u7684\u5462\uff1f\u6211\u4eec\u5c06\u628a\u89c6\u7ebf\u56de\u5230\u5148\u524d\u4e00\u76f4\u5728\u4f7f\u7528\u7684\u6cdb\u578b ProductSpuDO \u4e2d\uff0c\u5b83\u4f4d\u4e8e ProductSpuDO.java \u3002<\/p>\n\n\n\n<p>@TableName \u6ce8\u89e3\u5b9a\u4e49\u4e86\u8be5 java \u5bf9\u8c61\u4e0e\u6211\u4eec\u6240\u9700\u7684\u6570\u636e\u5e93\u8868\u7684\u5177\u4f53\u5bf9\u5e94\u5173\u7cfb\u3002\u672a\u6765\uff0c\u8be5\u6ce8\u89e3\u5c06\u4f1a\u8d1f\u8d23\u6620\u5c04\u7684\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\uff0c\u8fd9\u91cc ProductSpuDO \u662f\u7ee7\u627f\u4e86 BaseDO \u7684\u5b50\u7c7b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@TableName(value = \"product_spu\", autoResultMap = true)\n@Data\n@EqualsAndHashCode(callSuper = true)\n@ToString(callSuper = true)\n@Builder\n@NoArgsConstructor\n@AllArgsConstructor\npublic class ProductSpuDO extends BaseDO {\n\n    \/**\n     * \u5546\u54c1 SPU \u7f16\u53f7\uff0c\u81ea\u589e\n     *\/\n    @TableId\n    private Long id;\n    \/**\n     * \u5546\u54c1\u540d\u79f0\n     *\/\n    private String name;\n    \/**\n     * \u5173\u952e\u5b57\n     *\/\n    private String keyword;\n    \/**\n     * \u5546\u54c1\u7b80\u4ecb\n     *\/\n    private String introduction;\n    \/**\n     * \u5546\u54c1\u8be6\u60c5\n     *\/\n    private String description;\n...\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u6c5f\u7554\u4f55\u4eba\u521d\u89c1\u6708\uff1f\u6c5f\u6708\u4f55\u5e74\u521d\u7167\u4eba\uff1f \u4eba\u751f\u4ee3\u4ee3\u65e0\u7a77\u5df2\uff0c\u6c5f\u6708\u5e74\u5e74\u671b\u76f8\u4f3c\u3002 \u4e0d\u77e5\u6c5f\u6708\u5f85\u4f55\u4eba\uff0c\u4f46\u89c1\u957f\u6c5f\u9001\u6d41\u6c34\u3002 \u2014\u2014\u5510\u00b7 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=49"}],"version-history":[{"count":29,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":78,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=\/wp\/v2\/posts\/49\/revisions\/78"}],"wp:attachment":[{"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.higgus17.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}