Procházet zdrojové kódy

全局搜索后台开发

anderx před 7 roky
rodič
revize
855d6561b7

+ 7 - 0
src/main/java/com/goafanti/app/bo/ExpertsListBo.java

@@ -21,6 +21,7 @@ public class ExpertsListBo {
 	private  CommentDetailResult	commentDetailResult;
 	private Integer consultantType;
 	private String consultantTypeName;
+	private String keyword;
 	public String getUid() {
 		return uid;
 	}
@@ -129,6 +130,12 @@ public class ExpertsListBo {
 	public void setConsultantTypeName(String consultantTypeName) {
 		this.consultantTypeName = consultantTypeName;
 	}
+	public String getKeyword() {
+		return keyword;
+	}
+	public void setKeyword(String keyword) {
+		this.keyword = keyword;
+	}
 	
 
 }

+ 17 - 2
src/main/java/com/goafanti/common/controller/WebpageController.java

@@ -38,6 +38,7 @@ import com.goafanti.common.model.JtBusinessProject;
 import com.goafanti.common.model.News;
 import com.goafanti.common.model.Policy;
 import com.goafanti.common.model.User;
+import com.goafanti.common.service.GlobalSearchService;
 import com.goafanti.common.utils.LimitLengthUtil;
 import com.goafanti.common.utils.StringUtils;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -91,10 +92,13 @@ public class WebpageController extends BaseController {
 	private AchievementInterestService achievementInterestService;
 
 	@Resource
-	private DemandInterestService demandInterestService;
+	private DemandInterestService demandInterestService;
+	@Resource
+	private GlobalSearchService globalSearchService;
 
 	@Resource
-	private ProjectInterestMapper projectInterestMapper;
+	private ProjectInterestMapper projectInterestMapper;
+	
 
 	@RequestMapping(value = "/user/account/index", method = RequestMethod.GET)
 	public ModelAndView index(HttpServletRequest request, ModelAndView modelview) {
@@ -1275,6 +1279,17 @@ public class WebpageController extends BaseController {
 		res.setData(policyService.searchPolicy(keyword, 2, null, null, null, pNo, pSize, provinceId));
 		return res;
 	}
+
+	/**
+	 * 全局搜索
+	 */
+	@RequestMapping(value = "/portal/globalSearch", method = RequestMethod.GET)
+	@ResponseBody
+	public Result globalSearch(String  name,String keyword,Integer pageSize,Integer pageNo) {
+		Result res = new Result();
+		res.setData(globalSearchService.globalSearchList(name,pageNo,pageSize));
+		return res;
+	}
 	
 	/**
 	 * 知识产权维权

+ 3 - 1
src/main/java/com/goafanti/common/dao/UserIdentityMapper.java

@@ -108,11 +108,13 @@ public interface UserIdentityMapper {
 	
 	List<UserIdentityBo>getExperts(Integer size);
 
-	ExpertsListBo selectAppExpertsDetail(@Param("id")String id, @Param("uid")String uid);
 
+	ExpertsListBo selectAppExpertsDetail(@Param("id")String id, @Param("uid")String uid);
 	CommentDetailResult expertsCommentByUid(String id);
     
 	UserIdentity getUserIdentityByUid(String uid);
 	
 	Integer updateAuditing(UserIdentity identity);
+
+	ExpertsListBo selectByIdentityId(String id);
 }

+ 64 - 0
src/main/java/com/goafanti/common/enums/SocietyTagStatus.java

@@ -0,0 +1,64 @@
+package com.goafanti.common.enums;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+
+public enum SocietyTagStatus {
+	
+	SHQY(0, "社会企业"),
+	KYDW(1, "科研单位"),
+	GDYX(2, "高等院校"),
+	KYZJ(3, "科研专家"),
+	KJDR(4, "科技达人"),
+	FWJG(5, "服务机构"),
+	ZFBM(6, "政府部门"),
+	SH(7, "商会"),
+	XH(8, "协会"),
+	QTZZ(9, "其他组织"),
+	OTHER(10, "其他个人");
+
+	private SocietyTagStatus(Integer code, String desc) {
+		this.code = code;
+		this.desc = desc;
+	}
+
+	private static Map<Integer, SocietyTagStatus> status = new HashMap<Integer, SocietyTagStatus>();
+
+	static {
+		for (SocietyTagStatus value : SocietyTagStatus.values()) {
+			status.put(value.getCode(), value);
+		}
+	}
+
+	public static SocietyTagStatus getStatus(Integer code) {
+		if (containsType(code)) {
+			return status.get(code);
+		}
+		return OTHER;
+	}
+
+	public static SocietyTagStatus getStatus(String code) {
+		if (StringUtils.isNumeric(code)) {
+			return getStatus(Integer.parseInt(code));
+		}
+		return OTHER;
+	}
+
+	public static boolean containsType(Integer code) {
+		return status.containsKey(code);
+	}
+
+	private Integer	code;
+	private String	desc;
+
+	public Integer getCode() {
+		return code;
+	}
+
+	public String getDesc() {
+		return desc;
+	}
+
+}

+ 2 - 2
src/main/java/com/goafanti/common/mapper/JtBusinessProjectMapper.xml

@@ -545,7 +545,7 @@
         advertisement = #{advertisement,jdbcType=VARCHAR},
       </if>
       <if test="keyword != null">
-      	keyword = #{keyword,jbdcType=VARHCAR},
+      	keyword = #{keyword,jdbcType=VARCHAR},
       </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
@@ -585,7 +585,7 @@
   <select id="selectByPrimaryKeyWithModule" resultType="com.goafanti.business.bo.JtBusinessProjectResult">
     select 
         jtbp.id, jtbp.name, jtbp.category_id as categoryId, jtbp.number, jtbp.price, jtbp.activity_price as activityPrice, jtbp.member_price as memberPrice, jtbp.offset, 
-        jtbp.activity_flag as activityFlag, u.nickname as ownerName,ifnull(p.count,0) as interestCount,if(isnull(x.project_id),0,1) as interested,
+        jtbp.activity_flag as activityFlag, u.nickname as ownerName,ifnull(p.count,0) as interestCount,if(isnull(x.project_id),0,1) as interested,jtbp.keyword,
     jtbp.introduce, jtbp.province, jtbp.city, jtbp.create_time as createTime, jtbp.min_img_url as minImgUrl, jtbp.max_img_url as maxImgUrl, jtbp.value, jtbp.apply_conditions as applyConditions, 
     jtbp.owner_id as ownerId, jtbp.is_hot as isHot, jtbp.audit_status as auditStatus, jtbp.audit_info as auditInfo, jtbp.release_date as releaseDate,jtbc.module as module,jtbp.advertisement
     from jt_business_project jtbp left join `user` u on jtbp.owner_id=u.id

+ 26 - 0
src/main/java/com/goafanti/common/mapper/JtCollectSearchMapper.xml

@@ -287,4 +287,30 @@
     delete from jt_collect_search
     where row_id = #{id,jdbcType=VARCHAR}
   </delete>
+  <select id="globalSearchList" parameterType="String" resultType="com.goafanti.common.model.JtCollectSearch">
+  	  select id,from_table as fromTable,row_id as rowId,title,keyword from jt_collect_search
+  	  <if test="name !=null">
+    where title like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+    </if>
+    union 
+    select id,from_table,row_id,title,keyword from jt_collect_search
+    <if test="name !=null">
+    where keyword like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+    </if>
+    <if test="page_sql!=null">
+		${page_sql}
+	</if>
+  </select>
+  <select id="globalSearchCount" parameterType="String" resultType="java.lang.Integer">
+  select count(*) from ( select id,from_table,row_id,title,keyword from jt_collect_search
+  <if test="name !=null">
+    where title like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+    </if>
+    union 
+    select id,from_table,row_id,title,keyword from jt_collect_search
+    <if test="name !=null">
+    where keyword like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+    </if>
+    ) a
+  </select>
 </mapper>

+ 2 - 1
src/main/java/com/goafanti/common/mapper/NewsMapper.xml

@@ -46,7 +46,8 @@
     n.release_status as releaseStatus,
     n.top_number as topNumber,
     n.hotspot,
-    n.release_date as releaseDate
+    n.release_date as releaseDate,
+    n.keyword
     from news n
     where n.id = #{id,jdbcType=BIGINT}
   </select>

+ 1 - 1
src/main/java/com/goafanti/common/mapper/PolicyMapper.xml

@@ -318,7 +318,7 @@
         #{content,jdbcType=LONGVARCHAR},
       </if>
       <if test="keyword != null">
-        #{keyword,jdbcType=VARHCAR},
+        #{keyword,jdbcType=VARCHAR},
       </if>
     </trim>
   </insert>

+ 7 - 0
src/main/java/com/goafanti/common/mapper/UserIdentityMapper.xml

@@ -1462,4 +1462,11 @@ select a.create_time as createTime,
 	</if>
 	where id = #{id,jdbcType=VARCHAR}
 </update>
+
+
+<select id="selectByIdentityId" resultType="com.goafanti.app.bo.ExpertsListBo">
+	select a.id,a.uid as uid,b.nickname as username,b.society_tag as keyword from user_identity a 
+    left join user b on a.uid=b.id
+    where a.id=#{id,jdbcType=VARCHAR}
+</select>
 </mapper>

+ 28 - 0
src/main/java/com/goafanti/common/service/GlobalSearchService.java

@@ -0,0 +1,28 @@
+package com.goafanti.common.service;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.stereotype.Service;
+
+import com.goafanti.common.dao.JtCollectSearchMapper;
+import com.goafanti.common.model.JtCollectSearch;
+import com.goafanti.common.utils.StringUtils;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+@Service
+public class GlobalSearchService  extends BaseMybatisDao<JtCollectSearchMapper> {
+
+	@SuppressWarnings("unchecked")
+	public Pagination<JtCollectSearch> globalSearchList(String name, Integer pageNo, Integer pageSize) {
+		Map<String, Object> params = new HashMap<>();
+		if(StringUtils.isNotBlank(name))params.put("name", name);
+		if(pageNo==null||pageNo<1)pageNo=1;
+		if(pageSize==null||pageSize<1)pageSize=10;
+		return (Pagination<JtCollectSearch>) findPage("globalSearchList", "globalSearchCount", params, pageNo,
+				pageSize);
+		
+	}
+
+}

+ 0 - 1
src/main/java/com/goafanti/demand/controller/AdminDemandApiController.java

@@ -164,7 +164,6 @@ public class AdminDemandApiController extends CertifyApiController {
 		if(AFTConstants.YES == auditResult){
 			d.setAuditStatus(DemandAuditStatus.AUDITED.getCode());
 			d.setReleaseDate(new Date());
-			demandService.addJtCollectSearch(d);
 		}else if(AFTConstants.NO == auditResult){
 			d.setAuditStatus(DemandAuditStatus.UNAUDITED.getCode());
 		}

+ 13 - 1
src/main/java/com/goafanti/demand/service/impl/DemandServiceImpl.java

@@ -594,7 +594,19 @@ public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements D
 	@Override
 	public int updateByPrimaryKeySelective(Demand d) {
 		int i=demandMapper.updateByPrimaryKeySelective(d);
-		
+		if(collectFlag){
+			if (d.getAuditStatus()==2) {
+				JtCollectSearch r=new JtCollectSearch();
+				r.setFromTable(collectType.DMAND.getDesc());
+				r.setKeyword(d.getKeyword());
+				r.setTitle(d.getName());
+				r.setRowId(d.getId());
+				jtCollectSearchMapper.insertSelective(r);				
+			}
+			if (d.getAuditStatus()==4) {
+				if(collectFlag)jtCollectSearchMapper.deleteByrowId(d.getId());
+			}
+		}
 		return i; 
 	}
 	

+ 10 - 0
src/main/java/com/goafanti/news/bo/InputNews.java

@@ -70,6 +70,8 @@ public class InputNews {
 	 */
 	private Integer hotspot;
 	
+	private String keyword;
+	
 	
 
 	public Date getReleaseDate() {
@@ -216,4 +218,12 @@ public class InputNews {
 		this.hotspot = hotspot;
 	}
 
+	public String getKeyword() {
+		return keyword;
+	}
+
+	public void setKeyword(String keyword) {
+		this.keyword = keyword;
+	}
+
 }

+ 1 - 0
src/main/java/com/goafanti/news/controller/AdminNewsApiController.java

@@ -170,6 +170,7 @@ public Result apply(InputNews news,BindingResult bindingResult,String[] publishP
 				news.setAuditStatus(auditStatus); 
 			if(auditStatus ==2){
 				news.setReleaseDate(new Date());
+				
 				newsService.addJtCollectSearch(news);
 				}
 			if(auditStatus ==4){

+ 7 - 0
src/main/java/com/goafanti/news/service/NewsService.java

@@ -108,6 +108,9 @@ public class NewsService extends BaseMybatisDao<NewsMapper> {
 	}
 	
 	public News save(News news,List<String>webPages,List<String>appPages) {
+		if (null!=news &&news.getAuditStatus()!=null&& news.getAuditStatus()==2) {
+			addJtCollectSearch( news);
+		}
 		newsMapper.insert(news);
 		NewsPublish newsPublish=null;
 		if(webPages!=null && webPages.size()>0)
@@ -155,6 +158,10 @@ public class NewsService extends BaseMybatisDao<NewsMapper> {
 		return newsMapper.updateByPrimaryKeySelective(news);
 	}
 	public int updateSelectively(News news,List<String>webPages,List<String>appPages) {
+		if(collectFlag){
+			if(news!=null&&news.getAuditStatus()==2)addJtCollectSearch(news);
+			if(news!=null&&news.getAuditStatus()==4)updateJtCollectSearch(news);
+		}
 		newsPublishMapper.deleteByNewsId(news.getId());
 		NewsPublish newsPublish=null;
 		if(webPages!=null && webPages.size()>0)

+ 3 - 0
src/main/java/com/goafanti/news/service/PolicyService.java

@@ -36,6 +36,9 @@ JtCollectSearchMapper	jtCollectSearchMapper;
 private Boolean collectFlag ;
 
 public Policy saveNewPolicy(Policy policy,List<String>webPages,List<String>appPages) {
+	if (null!=policy&&policy.getAuditStatus()!=null&&policy.getAuditStatus()==2) {
+		addJtCollectSearch(policy);
+	}
 policyMapper.insertSelective(policy);
 PolicyPublish pp=null;
 if(webPages!=null)

+ 26 - 0
src/main/java/com/goafanti/user/service/impl/UserIdentityServiceImpl.java

@@ -12,6 +12,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.stereotype.Service;
 
@@ -23,6 +24,7 @@ import com.goafanti.common.bo.fieldGlossoryBo;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.DistrictGlossoryMapper;
 import com.goafanti.common.dao.IndustryCategoryMapper;
+import com.goafanti.common.dao.JtCollectSearchMapper;
 import com.goafanti.common.dao.NoticeMapper;
 import com.goafanti.common.dao.UserIdentityMapper;
 import com.goafanti.common.dao.UserInterestMapper;
@@ -33,7 +35,10 @@ import com.goafanti.common.enums.CertifySubmitType;
 import com.goafanti.common.enums.IdentityAuditStatus;
 import com.goafanti.common.enums.NoticeReadStatus;
 import com.goafanti.common.enums.NoticeStatus;
+import com.goafanti.common.enums.SocietyTagStatus;
 import com.goafanti.common.enums.UserLevel;
+import com.goafanti.common.enums.collectType;
+import com.goafanti.common.model.JtCollectSearch;
 import com.goafanti.common.model.Notice;
 import com.goafanti.common.model.User;
 import com.goafanti.common.model.UserIdentity;
@@ -67,6 +72,11 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 	IndustryCategoryMapper industryCategoryMapper;
 	@Autowired
 	UserInterestMapper	userInterestMapper;
+	@Autowired
+	JtCollectSearchMapper	jtCollectSearchMapper;
+	@Value(value="${collect_flag}")
+	private Boolean collectFlag ;
+	
 
 	private static final Logger	logger	= LoggerFactory.getLogger(UserIdentityServiceImpl.class);
 
@@ -582,8 +592,24 @@ public class UserIdentityServiceImpl extends BaseMybatisDao<UserIdentityMapper>
 		}
 		else auditStatus=AchievementAuditStatus.AUDITED.getCode().intValue();
 		identity.setAuditStatus(auditStatus);*/
+		if(collectFlag){
+		ExpertsListBo u=userIdentityMapper.selectByIdentityId(identity.getId());
+		if (identity.getAuditStatus()==2) {
+				JtCollectSearch r=new JtCollectSearch();
+				r.setFromTable(collectType.EXPERT.getDesc());
+				r.setKeyword(SocietyTagStatus.getStatus(u.getKeyword()).getDesc());
+				r.setTitle(u.getUsername());
+				r.setRowId(u.getUid());
+				jtCollectSearchMapper.insertSelective(r);
+			}
+		
+		if (identity.getAuditStatus()==4) {
+			if(collectFlag)jtCollectSearchMapper.deleteByrowId(u.getUid());
+			}
+		}
 		return userIdentityMapper.updateAuditing(identity);
 	}
+	
 
 	@Override
 	public Integer updateUserIdentityDetail(InputUserIdentity identity) {

+ 3 - 0
src/main/webapp/WEB-INF/views/portal/adviser/adviserList.html

@@ -24,6 +24,9 @@
                 </div>
             </div>
         </div>
+        <div class="sort">
+            <a class="relTime">发布时间</a><a class="colNumber">关注量</a>
+        </div>
         <div class="adviserList">
             <ul>