{"id":692,"date":"2023-02-26T14:56:29","date_gmt":"2023-02-26T06:56:29","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=692"},"modified":"2023-04-29T17:55:49","modified_gmt":"2023-04-29T09:55:49","slug":"mybatis-batch-query-list-results-sorting-problem-based-on-list","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/mybatis-batch-query-list-results-sorting-problem-based-on-list\/","title":{"rendered":"MyBatis\u6839\u636eList\u6279\u91cf\u67e5\u8be2List\u7ed3\u679c\u6392\u5e8f\u95ee\u9898"},"content":{"rendered":"<h2>MyBatis\u914d\u7f6e<\/h2>\n<pre><code class=\"language-java\">public interface RouteServiceMapper {\n    List&lt;RouteService&gt; selectRouteServiceList(@Param(&quot;routeServiceList&quot;) List&lt;Map&lt;String, String&gt;&gt; routeServiceList);\n}<\/code><\/pre>\n<p>\u67e5\u8be2\u51fa\u6765\u7684RouteServiceList\u987a\u5e8f\u4e0e\u4f20\u5165\u7684List\u4fe1\u606f\u987a\u5e8f\u4e0d\u4e00\u81f4\uff1a<\/p>\n<p><!-- more --><\/p>\n<pre><code class=\"language-sql\">&lt;select id=&quot;selectRouteServiceList&quot; parameterType=&quot;java.util.List&quot; resultMap=&quot;BaseResultMap&quot;&gt;\n    select\n    &lt;include refid=&quot;Base_Column_List&quot;\/&gt;\n    from route_service rs\n    where\n    rs.route_code in\n    &lt;foreach item=&quot;routeService&quot; index=&quot;index&quot; collection=&quot;routeServiceList&quot;\n             open=&quot;(&quot; separator=&quot;,&quot; close=&quot;)&quot;&gt;\n        #{routeService.route_code}\n    &lt;\/foreach&gt;\n    and rs.service_code in\n    &lt;foreach item=&quot;routeService&quot; index=&quot;index&quot; collection=&quot;routeServiceList&quot;\n            open=&quot;(&quot; separator=&quot;,&quot; close=&quot;)&quot;&gt;\n        #{routeService.service_code}\n    &lt;\/foreach&gt;\n    and rs.status = &#039;ENABLE&#039;\n&lt;\/select&gt;<\/code><\/pre>\n<p>\u89e3\u51b3\u65b9\u5f0f\uff1a<\/p>\n<pre><code class=\"language-sql\">&lt;select id=&quot;selectRouteServiceList&quot; parameterType=&quot;java.util.List&quot; resultMap=&quot;BaseResultMap&quot;&gt;\n    select * from\n    &lt;foreach item=&quot;routeService&quot; index=&quot;index&quot; collection=&quot;routeServiceList&quot;\n             open=&quot;(&quot; separator=&quot;union all&quot; close=&quot;)&quot;&gt;\n        select &lt;include refid=&quot;Base_Column_List&quot;\/&gt;\n        from route_service rs where\n        rs.route_code=#{routeService.route_code,jdbcType=VARCHAR} and\n        rs.service_code=#{routeService.service_code,jdbcType=VARCHAR} and\n        rs.status = &#039;ENABLE&#039;\n    &lt;\/foreach&gt; as rs\n&lt;\/select&gt;<\/code><\/pre>\n<h2>SQL\u6d4b\u8bd5<\/h2>\n<ul>\n<li>\u5f85\u67e5\u8be2\u6570\u7ec4\u987a\u5e8f<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">[{&quot;service_code&quot;:&quot;ALIPAY_QR&quot;,&quot;route_code&quot;:&quot;alipay&quot;},\n {&quot;service_code&quot;:&quot;WECHATPAY_QR&quot;,&quot;route_code&quot;:&quot;wechatpay&quot;}]<\/code><\/pre>\n<ul>\n<li>\u987a\u5e8f\u4e0d\u4e00\u81f4\u67e5\u8be2\u8f6c\u4e49<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">select id, route_code, service_code, service_app_name, pay_outer, status, creation_time, modification_time \nfrom tp_channel_service cs \nwhere cs.route_code in ( &#039;alipay&#039;,&#039;wechatpay&#039; ) \n  and cs.service_code in ( &#039;ALIPAY_QR&#039;,&#039;WECHATPAY_QR&#039; ) \n  and cs.status = &#039;ENABLE&#039;<\/code><\/pre>\n<ul>\n<li>\u987a\u5e8f\u4e00\u81f4\u67e5\u8be2\u8f6c\u4e49<\/li>\n<\/ul>\n<pre><code class=\"language-sql\">select id, route_code, service_code, service_app_name, pay_outer, status, creation_time, modification_time from\n    (\n    select id, route_code, service_code, service_app_name, pay_outer, status, creation_time, modification_time from tp_channel_service cs where\n        cs.route_code=&#039;alipay&#039; and cs.service_code=&#039;ALIPAY_QR&#039; and cs.status = &#039;ENABLE&#039;\n    UNION ALL\n    select id, route_code, service_code, service_app_name, pay_outer, status, creation_time, modification_time from tp_channel_service cs where\n        cs.route_code=&#039;wechatpay&#039; and cs.service_code=&#039;WECHATPAY_QR&#039; and cs.status = &#039;ENABLE&#039;\n    )\nas cs<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>MyBatis\u914d\u7f6e public interface RouteServiceMapper { List&#038;lt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[111],"class_list":["post-692","post","type-post","status-publish","format-standard","hentry","category-mybatis","tag-mybatis"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/692","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=692"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/692\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}