liupeng 5 lat temu
rodzic
commit
a09d10f828

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

@@ -66,4 +66,20 @@ public class ApiController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
+	
+	/**
+	 * 根据id查询用户信息
+	 * @return
+	 */
+	@RequestMapping(value = "/getUserInfoByUserId", produces = "application/json;charset=utf-8")
+	@ResponseBody
+	public Object getUserInfoById() {
+		try {
+			String userId = getPageData().getString("userId");
+			return AppUtil.success(sapUserService.getDetailById(userId), null);
+		} catch (Exception e) {
+			LoggerUtil.error(e);
+			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
+		}
+	}
 }

+ 3 - 0
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapUser.java

@@ -2,6 +2,7 @@ package org.fouram.entity;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 import org.apache.ibatis.type.Alias;
 
@@ -48,6 +49,8 @@ public class SapUser implements Serializable {
 	private Boolean delFlag;
 	private Date createDate;
 	private Integer sortNumber;
+	
+	private List<List<SapOrg>> departList;
 
 	public String toCompareString() {
 		StringBuilder sBuilder = new StringBuilder();

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

@@ -41,7 +41,7 @@
 		update sap_user set result=#{result} where personId=#{personId}
 	</update>
 	
-	<select id="selectOne" resultType="SapUser">
+	<select id="selectByUserId" resultType="SapUser">
 		select * from sap_user where userId=#{userId}
 	</select>
 	
@@ -67,7 +67,7 @@
 	
 	<select id="selectListByName" resultType="SapUser">
 		select * from sap_user 
-		where result = 'SUCCESS' and name like CONCAT(CONCAT('%', #{name}),'%')
+		where result = 'SUCCESS' and isPrimary = 1 and name like CONCAT(CONCAT('%', #{name}),'%')
 		order by sortNumber ASC
 	</select>
 	

+ 3 - 1
code/sapparent/sapservice/src/main/java/org/fouram/service/SapOrgService.java

@@ -179,7 +179,9 @@ public class SapOrgService extends BaseService {
 	}
 	
 	public SapOrg toInfoDetail(SapOrg sapOrg) throws Exception {
-		sapOrg.setParentOrg(selectById(sapOrg.getParentId()));
+		if(sapOrg != null) {
+			sapOrg.setParentOrg(selectById(sapOrg.getParentId()));
+		}
 		return sapOrg;
 	}
 

+ 32 - 4
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -11,6 +11,7 @@ import org.fouram.core.base.service.RequestService;
 import org.fouram.core.plugin.weixin.cp.util.WXCpUserUtil;
 import org.fouram.core.util.Base64Util;
 import org.fouram.core.util.Tools;
+import org.fouram.entity.SapOrg;
 import org.fouram.entity.SapUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
@@ -158,8 +159,8 @@ public class SapUserService extends BaseService {
 		return null;
 	}
 
-	public SapUser selectOne(String userId) throws Exception {
-		return (SapUser) findObject("SapUserMapper.selectOne", userId);
+	public SapUser selectByUserId(String userId) throws Exception {
+		return (SapUser) findObject("SapUserMapper.selectByUserId", userId);
 	}
 
 	@SuppressWarnings("unchecked")
@@ -198,14 +199,41 @@ public class SapUserService extends BaseService {
 		return (List<SapUser>) findList("SapUserMapper.selectListByDepartId", departId);
 	}
 
-	public SapUser toInfoDetail(SapUser sapUser) {
+	public SapUser toInfoDetail(SapUser sapUser) throws Exception {
+		if(sapUser != null) {
+			List<SapUser> users = selectListByPersonId(sapUser.getPersonId());
+			List<List<SapOrg>> departList = Lists.newArrayList();
+			for (int i = 0; i < users.size(); i++) {
+				SapUser user = users.get(i);
+				List<SapOrg> orgs = Lists.newArrayList();
+				if (Tools.notEmpty(user.getFirstOrgId())) {
+					orgs.add(sapOrgService.selectById(user.getFirstOrgId()));
+				}
+				if (Tools.notEmpty(user.getSecondOrgId())) {
+					orgs.add(sapOrgService.selectById(user.getSecondOrgId()));
+				}
+				if (Tools.notEmpty(user.getThirdOrgId())) {
+					orgs.add(sapOrgService.selectById(user.getThirdOrgId()));
+				}
+				if (Tools.notEmpty(user.getFourthOrgId())) {
+					orgs.add(sapOrgService.selectById(user.getFourthOrgId()));
+				}
+				departList.add(orgs);
+			}
+			sapUser.setDepartList(departList);
+		}
 		return sapUser;
 	}
 
-	public List<SapUser> toInfoDetails(List<SapUser> sapUsers) {
+	public List<SapUser> toInfoDetails(List<SapUser> sapUsers) throws Exception {
 		for (SapUser sapUser : sapUsers) {
 			toInfoDetail(sapUser);
 		}
 		return sapUsers;
 	}
+
+	public SapUser getDetailById(String userId) throws Exception {
+		SapUser sapUser = selectByUserId(userId);
+		return toInfoDetail(sapUser);
+	}
 }