Ver Fonte

新增通过用户ID查询所有职位拼接字符串的SQL

王苗苗 há 7 meses atrás
pai
commit
e4a21cb36c

+ 4 - 2
slibra-framework/src/main/java/com/slibra/framework/web/service/UserDetailsServiceImpl.java

@@ -1,6 +1,7 @@
 package com.slibra.framework.web.service;
 
 import com.slibra.system.mapper.SysPostMapper;
+import com.slibra.system.mapper.SysUserPostMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -60,10 +61,11 @@ public class UserDetailsServiceImpl implements UserDetailsService
             throw new ServiceException(MessageUtils.message("user.blocked"));
         }
         //2024年08月16日10:21:30  额外再处理一下用户的职位信息(前端接口使用)
-        Long[] postIds = user.getPostIds();
+        /*Long[] postIds = user.getPostIds();
         if (StringUtils.isNotEmpty(postIds)){
             user.setPosition(this.sysPostMapper.getPostNamesByIds(postIds));
-        }
+        }*/
+        user.setPosition(this.sysPostMapper.getPostNamesByUserId(user.getUserId()));
 
         passwordService.validate(user);
 

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

@@ -98,4 +98,6 @@ public interface SysPostMapper
     public SysPost checkPostCodeUnique(String postCode);
 
     String getPostNamesByIds(Long[] postIds);
+
+    String getPostNamesByUserId(Long userId);
 }

+ 8 - 0
slibra-system/src/main/resources/mapper/system/SysPostMapper.xml

@@ -129,4 +129,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 					#{postId}
 				</foreach> ) temp
 	</select>
+
+
+	<select id="getPostNamesByUserId" resultType="string" parameterType="Long">
+		SELECT
+			GROUP_CONCAT( post_name SEPARATOR ', ' )
+		FROM
+			( SELECT DISTINCT post_name FROM sys_post WHERE post_id IN (SELECT post_id FROM sys_user_post WHERE user_id = #{userId}) ) temp
+	</select>
 </mapper>