{"id":7444,"date":"2024-11-14T10:44:39","date_gmt":"2024-11-14T02:44:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7444\/"},"modified":"2024-11-14T10:44:39","modified_gmt":"2024-11-14T02:44:39","slug":"mybatis-plus-%e5%a6%82%e4%bd%95%e7%b2%be%e5%87%86%e5%8c%b9%e9%85%8d-json-%e6%95%b0%e6%8d%ae%e4%b8%ad%e7%9a%84%e7%ba%af%e6%95%b0%e7%bb%84%e5%92%8c%e5%af%b9%e8%b1%a1%e6%95%b0%e7%bb%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7444\/","title":{"rendered":"MyBatis Plus \u5982\u4f55\u7cbe\u51c6\u5339\u914d JSON \u6570\u636e\u4e2d\u7684\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173086277493430.jpg\" class=\"aligncenter\" title=\"MyBatis Plus \u5982\u4f55\u7cbe\u51c6\u5339\u914d JSON \u6570\u636e\u4e2d\u7684\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff1f\u63d2\u56fe\" alt=\"MyBatis Plus \u5982\u4f55\u7cbe\u51c6\u5339\u914d JSON \u6570\u636e\u4e2d\u7684\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728 mybatis plus \u4e2d\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4<\/strong><\/p>\n<p>mybatis plus \u662f\u4e00\u6b3e\u4f18\u79c0\u7684 orm \u6846\u67b6\uff0c\u4f46\u5728\u5339\u914d json \u6570\u636e\u65f6\uff0c\u5176\u9ed8\u8ba4\u7684 like \u65b9\u6cd5\u53ef\u80fd\u5b58\u5728\u8bef\u5339\u914d\u7684\u60c5\u51b5\uff0c\u7279\u522b\u662f\u5f53\u9700\u8981\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u6216\u5bf9\u8c61\u6570\u7ec4\u65f6\u3002<\/p>\n<p><strong>\u7eaf\u6570\u7ec4\u5339\u914d<\/strong><\/p>\n<p>\u5bf9\u4e8e\u7eaf\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528  5.7.8 \u53ca\u4ee5\u4e0a\u7248\u672c\u63d0\u4f9b\u7684 json_contns \u51fd\u6570\uff1a<\/p>\n<pre>wrapper.and(new consumer&lt;querywrapper&lt;object&gt;&gt;() {\n    @override\n    public void accept(querywrapper&lt;object&gt; wrapper) {\n        wrapper.last(\"json_contains(goods_tips_id_list, '\"\" + tipid + \"\")\");\n    }\n});<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u5bf9\u8c61\u6570\u7ec4\u5339\u914d<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5bf9\u8c61\u6570\u7ec4\uff0c\u9700\u8981\u5c06 json \u6570\u636e\u89e3\u6790\u4e3a java \u5bf9\u8c61\u6570\u7ec4\uff0c\u7136\u540e\u4f7f\u7528 in \u65b9\u6cd5\u8fdb\u884c\u5339\u914d\uff1a<\/p>\n<pre>List&lt;Long&gt; idList = Arrays.asList(1615226392250040321L, 1617784249885577217L, 1617784414117744641L);\nwrapper.in(\"goods_tips_id_list\", idList);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff0c\u907f\u514d\u8bef\u5339\u914d\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMyBatis Plus \u5982\u4f55\u7cbe\u51c6\u5339\u914d JSON \u6570\u636e\u4e2d\u7684\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 mybatis plus \u4e2d\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4 mybatis plus \u662f\u4e00\u6b3e\u4f18\u79c0\u7684 orm \u6846\u67b6\uff0c\u4f46\u5728\u5339\u914d json \u6570\u636e\u65f6\uff0c\u5176\u9ed8\u8ba4\u7684 like \u65b9\u6cd5\u53ef\u80fd\u5b58\u5728\u8bef\u5339\u914d\u7684\u60c5\u51b5\uff0c\u7279\u522b\u662f\u5f53\u9700\u8981\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u6216\u5bf9\u8c61\u6570\u7ec4\u65f6\u3002 \u7eaf\u6570\u7ec4\u5339\u914d \u5bf9\u4e8e\u7eaf\u6570\u7ec4\uff0c\u53ef\u4ee5\u4f7f\u7528 5.7.8 \u53ca\u4ee5\u4e0a\u7248\u672c\u63d0\u4f9b\u7684 json_contns \u51fd\u6570\uff1a wrapper.and(new consumer&lt;querywrapper&lt;object&gt;&gt;() { @override public void accept(querywrapper&lt;object&gt; wrapper) { wrapper.last(&#8220;json_contains(goods_tips_id_list, &#8216;&#8221;&#8221; + tipid + &#8220;&#8221;)&#8221;); } }); \u767b\u5f55\u540e\u590d\u5236 \u5bf9\u8c61\u6570\u7ec4\u5339\u914d \u5bf9\u4e8e\u5bf9\u8c61\u6570\u7ec4\uff0c\u9700\u8981\u5c06 json \u6570\u636e\u89e3\u6790\u4e3a java \u5bf9\u8c61\u6570\u7ec4\uff0c\u7136\u540e\u4f7f\u7528 in \u65b9\u6cd5\u8fdb\u884c\u5339\u914d\uff1a List&lt;Long&gt; idList = Arrays.asList(1615226392250040321L, 1617784249885577217L, 1617784414117744641L); wrapper.in(&#8220;goods_tips_id_list&#8221;, idList); \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u53ef\u4ee5\u7cbe\u51c6\u5339\u914d\u7eaf\u6570\u7ec4\u548c\u5bf9\u8c61\u6570\u7ec4\uff0c\u907f\u514d\u8bef\u5339\u914d\u7684\u60c5\u51b5\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7444","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7444"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7444\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}