Browse Source

用户关注列表

Antiloveg 8 years ago
parent
commit
51f404bbc0

+ 71 - 0
src/main/java/com/goafanti/common/mapper/UserInterestMapper.xml

@@ -87,4 +87,75 @@
     where from_uid = #{fromUid,jdbcType=VARCHAR}
     and to_uid =  #{toUid,jdbcType=VARCHAR}
   </select>
+  
+  <select id="findInterestUserListByPage" parameterType="java.lang.String" resultType="com.goafanti.user.bo.InterestUserListBo">
+	  	SELECT
+		x.interestId,
+		x.uid,
+	    x.userProvince,
+	    x.orgProvince,
+		x.username,
+		x.unitName,
+		x.type,
+		x.createTime, 
+		count(a.id) AS achievementNum,
+		count(d.id) AS demandNum
+	FROM
+		(
+			SELECT
+				uii.username,
+				oi.unit_name AS unitName,
+				u.type,
+				u.id AS uid,
+				ui.id AS interestId,
+				ui.create_time AS createTime,
+	      uii.province as userProvince,
+	      oi.licence_province as orgProvince,
+	      uinfo.person_portrait_url as personPortraitUrl,
+	      oinfo.logo_url as logoUrl
+			FROM
+				user_interest ui
+			LEFT JOIN user_identity uii ON uii.uid = ui.to_uid
+			LEFT JOIN organization_identity oi ON oi.uid = ui.to_uid
+			LEFT JOIN user u ON u.id = ui.to_uid
+			LEFT JOIN user_info uinfo on uinfo.uid = ui.to_uid
+			LEFT JOIN organization_info oinfo on oinfo.uid = ui.to_uid 
+			WHERE
+				ui.from_uid = #{fromUid,jdbcType=VARCHAR}
+		) x
+	LEFT JOIN achievement a ON a.owner_id = x.uid
+	LEFT JOIN demand d ON d.employer_id = x.uid
+	AND d.deleted_sign = 0
+	AND d.audit_status = 3
+	AND d.release_status = 1
+	AND a.deleted_sign = 0
+	AND a.audit_status = 3
+	AND a.release_status = 1
+	GROUP BY
+		x.uid
+	ORDER BY x.createTime
+  </select>
+  
+  <select id="findInterestUserCount" resultType="java.lang.Integer" parameterType="java.lang.String">
+  		SELECT
+		count(distinct(x.uid))
+	FROM
+		(
+			SELECT
+				u.id AS uid
+			FROM
+				user_interest ui
+			LEFT JOIN user u ON u.id = ui.to_uid
+			WHERE
+				ui.from_uid = #{fromUid,jdbcType=VARCHAR}
+		) x
+	LEFT JOIN achievement a ON a.owner_id = x.uid
+	LEFT JOIN demand d ON d.employer_id = x.uid
+	AND d.deleted_sign = 0
+	AND d.audit_status = 3
+	AND d.release_status = 1
+	AND a.deleted_sign = 0
+	AND a.audit_status = 3
+	AND a.release_status = 1
+  </select>
 </mapper>

+ 4 - 4
src/main/java/com/goafanti/patent/service/impl/PatentInfoServiceImpl.java

@@ -124,7 +124,7 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 			pageNo = 1;
 		}
 
-		if (pageSize == null || pageSize < 0) {
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
 		return (Pagination<PatentInfo>) findPage("findClientApplyListByPage", "findClentApplyCount", params, pageNo,
@@ -229,7 +229,7 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 			pageNo = 1;
 		}
 
-		if (pageSize == null || pageSize < 0) {
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
 		return (Pagination<PatentManageListBo>) findPage("findManagePatentListByPage", "findManagePatentCount", params,
@@ -254,7 +254,7 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 			pageNo = 1;
 		}
 
-		if (pageSize == null || pageSize < 0) {
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
 		return (Pagination<PatentPendingBo>) findPage("findManagePendingPaymentListByPage",
@@ -316,7 +316,7 @@ public class PatentInfoServiceImpl extends BaseMybatisDao<PatentInfoMapper> impl
 			pageNo = 1;
 		}
 
-		if (pageSize == null || pageSize < 0) {
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
 		return (Pagination<PatentNoticeOfCorrectionBo>) findPage("findNoticeOfCorrectionListByPage",

+ 142 - 0
src/main/java/com/goafanti/user/bo/InterestUserListBo.java

@@ -0,0 +1,142 @@
+package com.goafanti.user.bo;
+
+import java.util.Date;
+
+import org.apache.commons.lang3.time.DateFormatUtils;
+
+import com.goafanti.common.constant.AFTConstants;
+
+public class InterestUserListBo {
+	private String	interestId;
+
+	private String	uid;
+
+	private String	username;
+
+	private String	unitName;
+
+	private String	userProvince;
+
+	private String	orgProvince;
+
+	private Date	createTime;
+
+	private Integer	type;
+
+	private Integer	demandNum;
+
+	private Integer	achievementNum;
+
+	private String	personPortraitUrl;
+
+	private String	logoUrl;
+
+	public String getUid() {
+		return uid;
+	}
+
+	public void setUid(String uid) {
+		this.uid = uid;
+	}
+
+	public Integer getDemandNum() {
+		return demandNum;
+	}
+
+	public void setDemandNum(Integer demandNum) {
+		this.demandNum = demandNum;
+	}
+
+	public Integer getAchievementNum() {
+		return achievementNum;
+	}
+
+	public void setAchievementNum(Integer achievementNum) {
+		this.achievementNum = achievementNum;
+	}
+
+	public String getInterestId() {
+		return interestId;
+	}
+
+	public void setInterestId(String interestId) {
+		this.interestId = interestId;
+	}
+
+	public Date getCreateTime() {
+		return createTime;
+	}
+
+	public void setCreateTime(Date createTime) {
+		this.createTime = createTime;
+	}
+
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getUnitName() {
+		return unitName;
+	}
+
+	public void setUnitName(String unitName) {
+		this.unitName = unitName;
+	}
+
+	public String getUserProvince() {
+		return userProvince;
+	}
+
+	public void setUserProvince(String userProvince) {
+		this.userProvince = userProvince;
+	}
+
+	public String getOrgProvince() {
+		return orgProvince;
+	}
+
+	public void setOrgProvince(String orgProvince) {
+		this.orgProvince = orgProvince;
+	}
+
+	public String getPersonPortraitUrl() {
+		return personPortraitUrl;
+	}
+
+	public void setPersonPortraitUrl(String personPortraitUrl) {
+		this.personPortraitUrl = personPortraitUrl;
+	}
+
+	public String getLogoUrl() {
+		return logoUrl;
+	}
+
+	public void setLogoUrl(String logoUrl) {
+		this.logoUrl = logoUrl;
+	}
+
+	public String getCreateTimeFormattedDate() {
+		if (this.createTime == null) {
+			return null;
+		} else {
+			return DateFormatUtils.format(this.getCreateTime(), AFTConstants.YYYYMMDDHHMMSS);
+		}
+	}
+
+	public void setCreateTimeFormattedDate(String createTimeFormattedDate) {
+
+	}
+
+}

+ 11 - 1
src/main/java/com/goafanti/user/controller/UserInterestApiController.java

@@ -1,5 +1,6 @@
 package com.goafanti.user.controller;
 
+
 import javax.annotation.Resource;
 
 import org.apache.commons.lang3.StringUtils;
@@ -24,8 +25,17 @@ public class UserInterestApiController extends CertifyApiController{
 	 * 关注用户列表
 	 */
 	@RequestMapping(value = "/interestUserList", method = RequestMethod.GET)
-	public Result interestUserList(){
+	public Result interestUserList(String pageNo, String pageSize){
 		Result res = new Result();
+		Integer pNo = 1;
+		Integer pSize = 10;
+		if (StringUtils.isNumeric(pageSize)) {
+			pSize = Integer.parseInt(pageSize);
+		}
+		if (StringUtils.isNumeric(pageNo)) {
+			pNo = Integer.parseInt(pageNo);
+		}
+		res.setData(userInterestService.listInterestUser(pNo, pSize));
 		return res;
 	}
 	

+ 4 - 0
src/main/java/com/goafanti/user/service/UserInterestService.java

@@ -1,6 +1,8 @@
 package com.goafanti.user.service;
 
 import com.goafanti.common.model.UserInterest;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.user.bo.InterestUserListBo;
 
 public interface UserInterestService {
 
@@ -12,4 +14,6 @@ public interface UserInterestService {
 
 	int deleteByPrimaryKey(String interestId);
 
+	Pagination<InterestUserListBo> listInterestUser(Integer pNo, Integer pSize);
+
 }

+ 22 - 1
src/main/java/com/goafanti/user/service/impl/UserInterestServiceImpl.java

@@ -1,6 +1,8 @@
 package com.goafanti.user.service.impl;
 
 import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -8,10 +10,13 @@ import org.springframework.stereotype.Service;
 
 import com.goafanti.common.dao.UserInterestMapper;
 import com.goafanti.common.model.UserInterest;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.user.bo.InterestUserListBo;
 import com.goafanti.user.service.UserInterestService;
 @Service
-public class UserInterestServiceImpl implements UserInterestService {
+public class UserInterestServiceImpl extends BaseMybatisDao<UserInterestMapper> implements UserInterestService {
 	@Autowired
 	private UserInterestMapper userInterestMapper;
 
@@ -41,4 +46,20 @@ public class UserInterestServiceImpl implements UserInterestService {
 	public int deleteByPrimaryKey(String id) {
 		return userInterestMapper.deleteByPrimaryKey(id);
 	}
+
+	@SuppressWarnings("unchecked")
+	@Override
+	public Pagination<InterestUserListBo> listInterestUser(Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<>();
+		if (pageNo == null || pageNo < 0) {
+			pageNo = 1;
+		}
+
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
+			pageSize = 10;
+		}
+		params.put("fromUid", TokenManager.getUserId());
+		return (Pagination<InterestUserListBo>) findPage("findInterestUserListByPage",
+				"findInterestUserCount", params, pageNo, pageSize);
+	}
 }