liupeng 5 years ago
parent
commit
88e6ddd2f3

+ 1 - 0
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapOrg.java

@@ -26,4 +26,5 @@ public class SapOrg implements Serializable {
 	private Long wxDepartId;
 	
 	private List<SapOrg> children;
+	private SapOrg parentOrg;
 }

+ 4 - 0
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapOrgMapper.xml

@@ -26,6 +26,10 @@
 		select * from sap_org where sapName like CONCAT(CONCAT('%', #{pd.name}),'%')
 	</select>
 	
+	<select id="selectById" resultType="SapOrg">
+		select * from sap_org where id = #{id}
+	</select>
+	
 	<update id="updateWxDepartId">
 		update sap_org set wxDepartId=#{wxDepartId} where id=#{id}
 	</update>

+ 9 - 4
code/sapparent/sapservice/src/main/java/org/fouram/service/SapOrgService.java

@@ -162,7 +162,7 @@ public class SapOrgService extends BaseService {
 	@SuppressWarnings("unchecked")
 	public List<SapOrg> selectListByParentId(String parentId) throws Exception {
 		SapOrg org = SapOrg.builder().parentId(parentId).build();
-		return (List<SapOrg>) findList("SapOrgMapper.selectListByParentId", org);
+		return toInfoDetails((List<SapOrg>) findList("SapOrgMapper.selectListByParentId", org));
 	}
 	
 	public void updateWxDepartId(SapOrg org) throws Exception {
@@ -171,14 +171,19 @@ public class SapOrgService extends BaseService {
 
 	@SuppressWarnings("unchecked")
 	public List<SapOrg> selectListByName(String name) throws Exception {
-		return (List<SapOrg>) findList("SapOrgMapper.selectListByName", name);
+		return toInfoDetails((List<SapOrg>) findList("SapOrgMapper.selectListByName", name));
 	}
 	
-	public SapOrg toInfoDetail(SapOrg sapOrg) {
+	public SapOrg selectById(String id) throws Exception {
+		return (SapOrg) findObject("SapOrgMapper.selectById", id);
+	}
+	
+	public SapOrg toInfoDetail(SapOrg sapOrg) throws Exception {
+		sapOrg.setParentOrg(selectById(sapOrg.getParentId()));
 		return sapOrg;
 	}
 
-	public List<SapOrg> toInfoDetails(List<SapOrg> sapOrgs) {
+	public List<SapOrg> toInfoDetails(List<SapOrg> sapOrgs) throws Exception {
 		for (SapOrg sapOrg : sapOrgs) {
 			toInfoDetail(sapOrg);
 		}