liupeng 5 years ago
parent
commit
fb631322e3

+ 1 - 1
code/sapparent/sapcms/src/main/java/org/fouram/controller/ApiController.java

@@ -84,7 +84,7 @@ public class ApiController extends BaseController {
 			}
 			Map<String, Object> result = Maps.newHashMap();
 			result.put("departList", sapOrgService.selectListByParentId(departId));
-			result.put("userList", sapUserService.selectListByDepartId(departId));
+			result.put("userList", sapUserService.selectListByDepartIdAndLevel(departId));
 			return AppUtil.success(result, null);
 		} catch (Exception e) {
 			LoggerUtil.error(e);

+ 14 - 3
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapUserMapper.xml

@@ -81,10 +81,21 @@
 		order by sortNumber ASC
 	</select>
 	
-	<select id="selectListByDepartId" resultType="SapUser">
+	<select id="selectListByDepartIdAndLevel" resultType="SapUser">
 		select * from sap_user 
-		where result = 'SUCCESS' and isPrimary = 1 and delFlag = 0 and (
-			firstOrgId = #{departId} or secondOrgId = #{departId} or thirdOrgId = #{departId} or fourthOrgId = #{departId})
+		where result = 'SUCCESS' and isPrimary = 1 and delFlag = 0 
+		<if test="level == 1">
+			and firstOrgId = #{id} and secondOrgId is null
+		</if>
+		<if test="level == 2">
+			and secondOrgId = #{id} and thirdOrgId is null
+		</if>
+		<if test="level == 3">
+			and thirdOrgId = #{id} and fourthOrgId is null
+		</if>
+		<if test="level == 4">
+			and fourthOrgId = #{id}
+		</if>
 		order by sortNumber ASC
 	</select>
 </mapper>

+ 3 - 2
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -196,8 +196,9 @@ public class SapUserService extends BaseService {
 	}
 
 	@SuppressWarnings("unchecked")
-	public List<SapUser> selectListByDepartId(String departId) throws Exception {
-		return (List<SapUser>) findList("SapUserMapper.selectListByDepartId", departId);
+	public List<SapUser> selectListByDepartIdAndLevel(String departId) throws Exception {
+		SapOrg sapOrg = sapOrgService.selectById(departId);
+		return (List<SapUser>) findList("SapUserMapper.selectListByDepartIdAndLevel", sapOrg);
 	}
 
 	public SapUser toInfoDetail(SapUser sapUser) throws Exception {