Sfoglia il codice sorgente

再次 补上 部门好友欢迎语查询的sql

sgw 3 settimane fa
parent
commit
939362d3d1

+ 64 - 18
fs-service/src/main/java/com/fs/qw/mapper/QwFriendWelcomeMapper.java

@@ -55,25 +55,71 @@ public interface QwFriendWelcomeMapper
      * @param qwFriendWelcomeParam 好友欢迎语
      * @return 好友欢迎语集合
      */
+//    @Select("<script> " +
+//            "select  qfw.*  from qw_friend_welcome qfw " +
+//            "left join qw_user qu  ON FIND_IN_SET(qu.id,REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
+//            "LEFT JOIN company_user cu on  cu.user_id =qu.company_user_id " +
+//            "        <where>  \n" +
+//            "            <if test=\"qwUserIds != null  and qwUserIds != ''\"> and  FIND_IN_SET(#{qwUserIds},REPLACE(REPLACE(REPLACE(qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 </if>\n" +
+//            "            <if test=\"isSendMsg != null \"> and qfw.is_send_msg = #{isSendMsg}</if>\n" +
+//            "            <if test=\"welcomeText != null  and welcomeText != ''\"> and qfw.welcome_text = #{welcomeText}</if>\n" +
+//            "            <if test=\"isDayparting != null \"> and qfw.is_dayparting = #{isDayparting}</if>\n" +
+//            "            <if test=\"companyId != null \"> and qfw.company_id = #{companyId}</if>\n" +
+//            "            <if test=\"createTime != null \"> and qfw.create_time = #{createTime}</if>\n" +
+//            "            <if test=\"updateTime != null \"> and qfw.update_time = #{updateTime}</if>\n" +
+//            "            <if test=\"companyUserId != null \"> and qu.company_user_id = #{companyUserId}</if>\n" +
+//            "            <if test=\"cuDeptIdList != null and !cuDeptIdList.isEmpty() and  userType != '00' \">" +
+//            "               AND cu.dept_id IN " +
+//            "                   <foreach collection='cuDeptIdList' item='item' open='(' separator=',' close=')'> " +
+//            "                       #{item} " +
+//            "                   </foreach> " +
+//            "            </if>" +
+//            "        </where>" +
+//            "</script>")
+//    public List<QwFriendWelcome> selectQwFriendWelcomeListMyVO(QwFriendWelcomeParam qwFriendWelcomeParam);
     @Select("<script> " +
-            "select  qfw.*  from qw_friend_welcome qfw " +
-            "left join qw_user qu  ON FIND_IN_SET(qu.id,REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
-            "        <where>  \n" +
-            "            <if test=\"qwUserIds != null  and qwUserIds != ''\"> and  FIND_IN_SET(#{qwUserIds},REPLACE(REPLACE(REPLACE(qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 </if>\n" +
-            "            <if test=\"isSendMsg != null \"> and qfw.is_send_msg = #{isSendMsg}</if>\n" +
-            "            <if test=\"welcomeText != null  and welcomeText != ''\"> and qfw.welcome_text = #{welcomeText}</if>\n" +
-            "            <if test=\"isDayparting != null \"> and qfw.is_dayparting = #{isDayparting}</if>\n" +
-            "            <if test=\"companyId != null \"> and qfw.company_id = #{companyId}</if>\n" +
-            "            <if test=\"createTime != null \"> and qfw.create_time = #{createTime}</if>\n" +
-            "            <if test=\"updateTime != null \"> and qfw.update_time = #{updateTime}</if>\n" +
-            "            <if test=\"companyUserId != null \"> and qu.company_user_id = #{companyUserId}</if>\n" +
-            "            <if test=\"cuDeptIdList != null and !cuDeptIdList.isEmpty() and  userType != '00' \">" +
-            "               AND cu.dept_id IN " +
-            "                   <foreach collection='cuDeptIdList' item='item' open='(' separator=',' close=')'> " +
-            "                       #{item} " +
-            "                   </foreach> " +
-            "            </if>" +
-            "        </where>" +
+            "SELECT qfw.* FROM qw_friend_welcome qfw " +
+            "WHERE " +
+            "   <if test=\"qwUserIds != null and qwUserIds != ''\"> " +
+            "       EXISTS ( " +
+            "           SELECT 1 FROM qw_user qu " +
+            "           JOIN company_user cu ON cu.user_id = qu.company_user_id " +
+            "           WHERE FIND_IN_SET(qu.id, REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
+            "           AND qu.id = #{qwUserIds} " +
+            "       ) AND " +
+            "   </if>" +
+            "   <if test=\"isSendMsg != null\"> qfw.is_send_msg = #{isSendMsg} AND </if>" +
+            "   <if test=\"welcomeText != null and welcomeText != ''\"> qfw.welcome_text = #{welcomeText} AND </if>" +
+            "   <if test=\"isDayparting != null\"> qfw.is_dayparting = #{isDayparting} AND </if>" +
+            "   <if test=\"companyId != null\"> qfw.company_id = #{companyId} AND </if>" +
+            "   <if test=\"corpId != null\"> " +
+            "       EXISTS ( " +
+            "           SELECT 1 FROM qw_user qu " +
+            "           JOIN company_user cu ON cu.user_id = qu.company_user_id " +
+            "           WHERE FIND_IN_SET(qu.id, REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
+            "           AND qu.corp_id = #{corpId} " +
+            "       ) AND " +
+            "   </if>" +
+            "   <if test=\"companyUserId != null\"> " +
+            "       EXISTS ( " +
+            "           SELECT 1 FROM qw_user qu " +
+            "           JOIN company_user cu ON cu.user_id = qu.company_user_id " +
+            "           WHERE FIND_IN_SET(qu.id, REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
+            "           AND qu.company_user_id = #{companyUserId} " +
+            "       ) AND " +
+            "   </if>" +
+            "   <if test=\"cuDeptIdList != null and !cuDeptIdList.isEmpty() and userType != '00'\"> " +
+            "       EXISTS ( " +
+            "           SELECT 1 FROM qw_user qu " +
+            "           JOIN company_user cu ON cu.user_id = qu.company_user_id " +
+            "           WHERE FIND_IN_SET(qu.id, REPLACE(REPLACE(REPLACE(qfw.qw_user_ids, '[', ''), ']', ''), ' ', '')) > 0 " +
+            "           AND cu.dept_id IN " +
+            "               <foreach collection='cuDeptIdList' item='item' open='(' separator=',' close=')'> " +
+            "                   #{item} " +
+            "               </foreach> " +
+            "       ) AND " +
+            "   </if>" +
+            "   1=1 "+
             "</script>")
     public List<QwFriendWelcome> selectQwFriendWelcomeListMyVO(QwFriendWelcomeParam qwFriendWelcomeParam);