瀏覽代碼

批量查询部门

wangxx 3 周之前
父節點
當前提交
5277b52e21

+ 7 - 5
airport-ledger/src/main/java/com/sundot/airport/ledger/service/impl/DeptPortraitServiceImpl.java

@@ -230,12 +230,14 @@ public class DeptPortraitServiceImpl implements IDeptPortraitService {
230 230
                 .distinct()
231 231
                 .collect(Collectors.toList());
232 232
         
233
-        // 4. 批量查询岗位信息(一次SQL)
233
+        // 4. 批量查询岗位信息
234 234
         Map<Long, String> postIdToNameMap = new HashMap<>();
235
-        for (Long postId : postIds) {
236
-            SysPost post = sysPostMapper.selectPostById(postId);
237
-            if (post != null && post.getPostName() != null) {
238
-                postIdToNameMap.put(postId, post.getPostName());
235
+        if (!postIds.isEmpty()) {
236
+            List<SysPost> posts = sysPostMapper.selectPostsByIds(postIds);
237
+            for (SysPost post : posts) {
238
+                if (post != null && post.getPostName() != null) {
239
+                    postIdToNameMap.put(post.getPostId(), post.getPostName());
240
+                }
239 241
             }
240 242
         }
241 243
         

+ 2 - 0
airport-system/src/main/java/com/sundot/airport/system/mapper/SysPostMapper.java

@@ -129,4 +129,6 @@ public interface SysPostMapper {
129 129
      * @return 选中岗位ID列表
130 130
      */
131 131
     public List<SysPost> selectPostListsByUserId(Long userId);
132
+
133
+    List<SysPost> selectPostsByIds(List<Long> postIds);
132 134
 }

+ 10 - 0
airport-system/src/main/resources/mapper/system/SysPostMapper.xml

@@ -188,4 +188,14 @@
188 188
         where u.user_id = #{userId}
189 189
     </select>
190 190
 
191
+    <select id="selectPostsByIds" parameterType="java.util.List" resultMap="SysPostResult">
192
+        <include refid="selectPostVo"/>
193
+        where status='0'
194
+        and post_id in
195
+        <foreach item="item" index="index" collection="list"
196
+                 separator="," close=")" open="(">
197
+            #{item}
198
+        </foreach>
199
+    </select>
200
+
191 201
 </mapper>