albertshaw пре 8 година
родитељ
комит
7279df5210

+ 4 - 0
schema/20170816-appconfig.sql

@@ -34,3 +34,7 @@ INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('mytech', 'dea
 INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('myexpert', 'date', '邀约', '1');
 INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('myexpert', 'intention', '意向', '1');
 INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('myexpert', 'deal', '成交', '1');
+INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('mydemand', 'match', '匹配', '1');
+INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('mydemand', 'intention', '意向', '1');
+INSERT INTO `app_config` (`cate`, `key`, `name`, `value`) VALUES ('mydemand', 'deal', '成交', '1');
+

+ 9 - 1
src/main/java/com/goafanti/app/controller/MyAppApiController.java

@@ -6,6 +6,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.goafanti.app.service.AppConfigService;
+import com.goafanti.app.service.MyAppService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.controller.BaseApiController;
 import com.goafanti.common.utils.StringUtils;
@@ -15,7 +16,9 @@ import com.goafanti.common.utils.StringUtils;
 public class MyAppApiController extends BaseApiController {
 
 	@Autowired
-	AppConfigService appConfigService;
+	AppConfigService	appConfigService;
+	@Autowired
+	MyAppService		myAppService;
 
 	@RequestMapping(value = "/config", method = RequestMethod.GET)
 	public Result config(String noCache) {
@@ -24,4 +27,9 @@ public class MyAppApiController extends BaseApiController {
 		}
 		return res().data(appConfigService.findPortalAppConfigs());
 	}
+
+	@RequestMapping(value = "/count", method = RequestMethod.GET)
+	public Result count(String cate) {
+		return res().data(myAppService.countByCate(cate));
+	}
 }

+ 48 - 0
src/main/java/com/goafanti/app/enums/MyAppCountCategory.java

@@ -0,0 +1,48 @@
+package com.goafanti.app.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public enum MyAppCountCategory {
+	COLLECTIONS("collections", "收藏"),
+	ORDERS("orders", "订单"),
+	MYDEMAND("mydemand", "我的需求"),
+	MYTECH("mytech", "我的技术"),
+	MYEXPERT("myexpert", "我的专家"),
+	UNKNOWN("", "未知");
+
+	private MyAppCountCategory(String code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<String, MyAppCountCategory> status = new HashMap<String, MyAppCountCategory>();
+
+	static {
+		for (MyAppCountCategory value : MyAppCountCategory.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static MyAppCountCategory getStatus(String code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return UNKNOWN;
+	}
+
+	public static boolean containsType(String code) {
+		return status.containsKey(code);
+	}
+
+	private String	code;
+	private String	desc;
+
+	public String getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+}

+ 40 - 0
src/main/java/com/goafanti/app/service/MyAppService.java

@@ -0,0 +1,40 @@
+package com.goafanti.app.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+
+import com.goafanti.app.enums.MyAppCountCategory;
+import com.goafanti.common.dao.MyAppMapper;
+import com.goafanti.core.shiro.token.TokenManager;
+
+@Service
+public class MyAppService {
+	@Autowired
+	MyAppMapper myAppMapper;
+
+	public ModelMap countByCate(String cate) {
+		ModelMap res = null;
+		switch (MyAppCountCategory.getStatus(cate)) {
+		case COLLECTIONS:
+			res = myAppMapper.countCollections(TokenManager.getUserId());
+			break;
+		case MYDEMAND:
+			res = myAppMapper.countMyDemand(TokenManager.getUserId());
+			break;
+//		case MYEXPERT:
+//			res = myAppMapper.countMyExpert(TokenManager.getUserId());
+//			break;
+		case MYTECH:
+			res = myAppMapper.countMyTech(TokenManager.getUserId());
+			break;
+		case ORDERS:
+			res = myAppMapper.countOrders(TokenManager.getUserId());
+			break;
+		default:
+			res = new ModelMap();
+			break;
+		}
+		return res;
+	}
+}

+ 16 - 0
src/main/java/com/goafanti/common/dao/MyAppMapper.java

@@ -0,0 +1,16 @@
+package com.goafanti.common.dao;
+
+import org.apache.ibatis.annotations.Param;
+import org.springframework.ui.ModelMap;
+
+public interface MyAppMapper {
+	ModelMap countCollections(@Param("uid") String uid);
+
+	ModelMap countOrders(@Param("uid") String uid);
+
+	ModelMap countMyTech(@Param("uid") String uid);
+
+	ModelMap countMyDemand(@Param("uid") String uid);
+
+	ModelMap countMyExpert(@Param("uid") String uid);
+}

+ 36 - 0
src/main/java/com/goafanti/common/mapper/MyAppMapper.xml

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.goafanti.common.dao.MyAppMapper">
+  <select id="countCollections" parameterType="String" resultType="org.springframework.ui.ModelMap">
+  	select 
+	(select count(1) from achievement_interest ai where ai.uid=#{uid,jdbcType=VARCHAR}) as achievement,
+	(select count(1) from demand_interest di where di.uid=#{uid,jdbcType=VARCHAR}) as demand,
+	(SELECT count(1) FROM user_interest uin left join user u on uin.to_uid=u.id where u.type=0 and uin.from_uid=#{uid,jdbcType=VARCHAR}) as expert,
+	(SELECT count(1) FROM user_interest uin left join organization_info oi on uin.to_uid=oi.uid where oi.identity_type='企业' and uin.from_uid=#{uid,jdbcType=VARCHAR}) as company,
+	(SELECT count(1) FROM user_interest uin left join organization_info oi on uin.to_uid=oi.uid where oi.identity_type='院校' and uin.from_uid=#{uid,jdbcType=VARCHAR}) as school,
+	(SELECT count(1) FROM user_interest uin left join organization_info oi on uin.to_uid=oi.uid where oi.identity_type='研究机构' and uin.from_uid=#{uid,jdbcType=VARCHAR}) as institute
+  </select>
+  <select id="countOrders" parameterType="String" resultType="org.springframework.ui.ModelMap">
+  	select 
+	(select count(1) from org_cognizance where uid=#{uid,jdbcType=VARCHAR} and deleted_sign=0) as hightech,
+	(select count(1) from tech_project where uid=#{uid,jdbcType=VARCHAR} and deleted_sign=0) as program,
+	(SELECT count(1) FROM patent_info where uid=#{uid,jdbcType=VARCHAR} and deleted_sign=0) as patent,
+	(SELECT count(1) FROM value_evaluation where uid=#{uid,jdbcType=VARCHAR}) as evalution,
+	(SELECT count(1) FROM activity_user where uid=#{uid,jdbcType=VARCHAR}) as activity,
+	(SELECT count(1) FROM achievement_order where uid=#{uid,jdbcType=VARCHAR} and deleted_sign=0) as achievement,
+	(SELECT count(1) FROM demand_order where uid=#{uid,jdbcType=VARCHAR} and deleted_sign=0) as demand,
+	(SELECT count(1) FROM copyright_info where uid=#{uid,jdbcType=VARCHAR} and delete_sign=0) as copyright
+  </select>
+  <select id="countMyTech" parameterType="String" resultType="org.springframework.ui.ModelMap">
+  	select 
+	(select count(1) from achievement a left join achievement_demand ad on a.id=ad.achievement_id where a.owner_id=#{uid,jdbcType=VARCHAR}) as `match`,
+	(select count(1) from achievement a left join achievement_order ao on a.id=ao.achievement_id where a.owner_id=#{uid,jdbcType=VARCHAR} and ao.status>5 and (ao.service_money>0 or ao.commission>0 or ao.intention_money>0)) as `deal`,
+	(select count(1) from achievement a left join achievement_interest ai on a.id=ai.achievement_id where a.owner_id=#{uid,jdbcType=VARCHAR}) as `intention`
+  </select>
+  <select id="countMyDemand" parameterType="String" resultType="org.springframework.ui.ModelMap">
+	select 
+	(select count(1) from demand d left join achievement_demand ad on d.id=ad.demand_id where d.employer_id=#{uid,jdbcType=VARCHAR}) as `match`,
+	(select count(1) from demand d left join demand_order `do` on d.id=`do`.demand_id where d.employer_id=#{uid,jdbcType=VARCHAR} and `do`.status>5 and (`do`.service_money>0 or `do`.commission>0 or `do`.intention_money>0)) as `deal`,
+	(select count(1) from demand d left join demand_interest di on d.id=di.demand_id where d.employer_id=#{uid,jdbcType=VARCHAR}) as `intention`
+  </select>
+</mapper>