Commit 255883aa authored by 刘基明's avatar 刘基明

用户搜索

parent 914d0c9f
package com.tanpu.community.api.beans.resp;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.qo.ThemeQo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@ApiModel(value = "主题搜索")
public class ThemeAndUserSearchResp {
public List<ThemeQo> themes;
public List<FollowQo> users;
public ThemeAndUserSearchResp() {
this.themes = new ArrayList<>();
this.users = new ArrayList<>();
}
}
package com.tanpu.community.api.beans.resp;
import com.tanpu.community.api.beans.qo.FollowQo;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@ApiModel(value = "主题搜索")
public class UserSearchResp {
public List<FollowQo> users;
public UserSearchResp() {
this.users = new ArrayList<>();
}
}
......@@ -2,16 +2,21 @@ package com.tanpu.community.controller;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.auth.UserHolder;
import com.tanpu.common.auth.UserInfoHelper;
import com.tanpu.community.api.beans.qo.ThemeQo;
import com.tanpu.community.api.beans.qo.TopicDetailQo;
import com.tanpu.community.api.beans.qo.FollowQo;
import com.tanpu.community.api.beans.req.search.ThemeFullSearchReq;
import com.tanpu.community.api.beans.resp.ThemeAndUserSearchResp;
import com.tanpu.community.api.beans.resp.ThemeFullSearchResp;
import com.tanpu.community.api.beans.resp.UserSearchResp;
import com.tanpu.community.manager.HomePageManager;
import com.tanpu.community.manager.ThemeManager;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
......@@ -27,6 +32,9 @@ public class SearchController {
@Autowired
private ThemeManager themeManager;
@Autowired
private HomePageManager homePageManager;
// 内容全文搜索
@ApiOperation("全文搜索主题")
@PostMapping(value = "/themeFullText")
......@@ -36,4 +44,24 @@ public class SearchController {
return CommonResp.success(resp);
}
// 用户+内容全文搜索
@ApiOperation("全文搜索主题")
@PostMapping(value = "/themeFullTextAndUser")
@ResponseBody
public CommonResp<ThemeAndUserSearchResp> themeFullTextAndUserSearch(@RequestBody ThemeFullSearchReq req) {
ThemeFullSearchResp themeFullSearch = themeManager.themeFullSearch(req.keyword, req.page.pageNumber, req.page.pageSize, req.ident, userHolder.getUserId());
List<FollowQo> users = homePageManager.userNameSerach(req.keyword, 1, 2, req.ident, userHolder.getUserId());
return CommonResp.success(ThemeAndUserSearchResp.builder().themes(themeFullSearch.getThemes()).users(users).build());
}
// 用户搜索
@ApiOperation("用户姓名模糊查询")
@PostMapping(value = "/userNameFuzzy")
@ResponseBody
public CommonResp<UserSearchResp> userNameSerach(@RequestBody ThemeFullSearchReq req) {
List<FollowQo> users = homePageManager.userNameSerach(req.keyword, req.page.pageNumber, req.page.pageSize, req.ident, userHolder.getUserId());
return CommonResp.success(UserSearchResp.builder().users(users).build());
}
}
......@@ -10,8 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "${tanpu.jifen.svc:http://tp-jifen-svc}", path = "/jifen")
// @FeignClient(value = "service-jifen", contextId = "jifen", fallbackFactory = FeignBackClientForActivity.class, url = "http://127.0.0.1:8202/community")
@FeignClient(value = "service-jifen", contextId = "jifen", url = "${tanpu.jifen.svc:http://tp-jifen-svc}", path = "/jifen")
public interface FeignClientForActivity {
......
......@@ -6,7 +6,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@FeignClient(value = "service-community", contextId = "community", fallbackFactory = FeignBackClientForCommunity.class, url = "http://tp-tamp-community-svc", path = "/community")
@FeignClient(value = "service-community", url = "${tanpu.community.svc:}", path = "/community")
// @FeignClient(value = "service-community", contextId = "community", fallbackFactory = FeignBackClientForCommunity.class, url = "http://127.0.0.1:8202/community")
public interface FeignClientForCommunity {
......
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://tp-course-svc", path = "/course")
@FeignClient(value = "service-course", contextId = "course", url = "${tanpu.course.svc:}", path = "/course")
//@FeignClient(value = "service-course", contextId = "course", fallbackFactory = FeignBackClientForCourse.class, url = "http://172.20.1.249:8060/course")
public interface FeignClientForCourse {
......
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, url = "http://tp-diagnose-svc", path = "/diagnose")
@FeignClient(value = "service-diagnose", url = "${tanpu.diagnose.svc:}", path = "/diagnose")
//@FeignClient(value = "service-diagnose", contextId = "diagnose", fallbackFactory = FeignBackClientForDiagnose.class, path = "http://172.20.1.249:8201/diagnose")
public interface FeignClientForDiagnose {
......
......@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
@FeignClient(value = "fatools", contextId = "fatools", fallbackFactory = FeignbackForFatools.class, url = "${tanpu.fatools.svc:http://tp-fatools-svc}", path = "/fatools")
@FeignClient(value = "fatools", contextId = "fatools", url = "${tanpu.fatools.svc:}", path = "/fatools")
//@FeignClient(value = "fatools", contextId = "fatoolsUser", fallbackFactory = FeignbackForFatools.class, path = "/fatools")
public interface FeignClientForFatools {
......@@ -56,4 +56,9 @@ public interface FeignClientForFatools {
@GetMapping(value = "/queryChiefFinancialAdviserList")
CommonResp<Page<UserInfoNewChief>> queryChiefFinancialAdviserList(@RequestParam("pageNumber") Integer pageNumber,@RequestParam("pageSize") Integer pageSize);
@ApiOperation(value = "根据昵称模糊查询目标用户")
@GetMapping(value = "/queryByUserNameMp")
List<UserInfoResp> queryByUserNameMp(@RequestParam("keyword") String keyword,
@RequestParam("pageSize") Integer pageSize,
@RequestParam("pageNumber") Integer pageNumber);
}
......@@ -71,6 +71,12 @@ public class FeignbackForFatools implements FallbackFactory<FeignClientForFatool
log.info("FeignbackForFatools.queryChiefFinancialAdviserList", throwable);
return CommonResp.error();
}
@Override
public List<UserInfoResp> queryByUserNameMp(String keyword, Integer pageSize, Integer pageNumber) {
log.info("FeignbackForFatools.queryByUserNameMp", throwable);
return null;
}
};
}
......
......@@ -3,7 +3,6 @@ package com.tanpu.community.feign.product;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.fund.FundCompanySimpleVO;
import com.tanpu.community.api.beans.vo.feign.product.ProductInfoVO;
import com.tanpu.community.feign.fatools.FeignbackForFatools;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -12,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://tp-product-svc", path = "/product")
@FeignClient(value = "service-product", url = "${tanpu.product.svc:}", path = "/product")
//@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://172.20.0.68:8194/product")
public interface FeignClientForProducts {
......
......@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
//@FeignClient(value = "service-fund", url = "http://127.0.0.1:8194/fund")
@FeignClient(value = "service-fund", contextId = "fund", fallbackFactory = FeignbackForFund.class, url = "http://tp-fund-svc", path = "/fund")
@FeignClient(value = "service-fund", url = "${tanpu.fund.svc:}", path = "/fund")
//@FeignClient(value = "service-fund", path = "/fund")
public interface FeignForFund {
......
......@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-fundpublic", contextId = "fundpublic", fallbackFactory = FeignbackForPublicFund.class, url = "http://tp-fundpublic-svc", path = "/fundpublic")
@FeignClient(value = "service-fundpublic", contextId = "fundpublic", url = "${tanpu.fundpublic.svc:}", path = "/fundpublic")
//@FeignClient(value = "service-fundpublic",path = "/fundpublic")
public interface FeignForPublicFund {
......
......@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://tp-tanpuroom-svc", path = "/tanpuroom")
@FeignClient(value = "service-tanpuroom", url = "${tanpu.tanpuroom.svc:}", path = "/tanpuroom")
//@FeignClient(value = "service-tanpuroom", contextId = "tanpuroom", fallbackFactory = FeignBackClientForTanpuroom.class, url = "http://172.20.0.183:8086/tanpuroom")
public interface FeignClientForTanpuroom {
......
......@@ -3,7 +3,6 @@ package com.tanpu.community.feign.zhibo;
import com.tanpu.common.api.CommonResp;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboDetailVO;
import com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp;
import com.tanpu.community.feign.tanpuroom.FeignBackClientForTanpuroom;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -14,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
//@FeignClient(value = "service-zhibo", url = "${tanpu.feo-zhibo.svc:}", fallbackFactory = FeignbackForZhibo.class, path = "/zhibo")
@FeignClient(value = "service-zhibo", contextId = "zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://tp-zhibo-svc", path = "/zhibo")
@FeignClient(value = "service-zhibo", url = "${tanpu.feo-zhibo.svc:}", path = "/zhibo")
//@FeignClient(value = "service-zhibo", fallbackFactory = FeignbackForZhibo.class, url = "http://172.20.0.169:8183/zhibo")
public interface FeignClientForZhibo {
......
......@@ -48,14 +48,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.constraints.NotEmpty;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -301,4 +294,15 @@ public class HomePageManager {
return userInfoNewCommonResp.getData();
}
public List<FollowQo> userNameSerach(String keyword, Integer pageNumber, Integer pageSize, String ident, String userId) {
if (StringUtils.isBlank(keyword)){
return Collections.emptyList();
}
List<UserInfoResp> userInfoResps = feignClientForFatools.queryByUserNameMp(keyword,pageSize,pageNumber);
List<FollowQo> followQos = userInfoResps.stream().map(ConvertUtil::userInfoNew2FollowQo).collect(Collectors.toList());
if (StringUtils.isNotEmpty(userId)) {
judgeFollowed(followQos, userId);
}
return followQos;
}
}
apollo.bootstrap.enabled: true
apollo.bootstrap.enabled: false
#app.id: tanpu-community
#apollo:
......@@ -15,15 +15,7 @@ server:
spring.datasource:
community:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: tamp_admin
password: '@imeng123'
maxActive: 2
minIdle: 2
initialSize: 2
user:
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmkao.mysql.rds.aliyuncs.com:3306/tamp_user?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
jdbc-url: jdbc:mysql://rm-uf6r22t3d798q4kmk.mysql.rds.aliyuncs.com:3306/tamp_community?useUnicode=true&characterEncoding=utf-8&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
username: tamp_admin
password: '@imeng123'
maxActive: 2
......@@ -103,7 +95,22 @@ tmpfile:
tanpu:
fatools:
svc: 127.0.0.1:8189
product:
svc: https://testtamper.tanpuyun.com
jifen:
svc: https://testtamper.tanpuyun.com
fund:
svc: https://testtamper.tanpuyun.com
course:
svc: https://testtamper.tanpuyun.com
community:
svc: https://testtamper.tanpuyun.com
order:
svc: https://testtamper.tanpuyun.com
tanpuroom:
svc: https://testtamper.tanpuyun.com
zhibo:
svc: https://testtamper.tanpuyun.com
diagnose:
svc: https://testtamper.tanpuyun.com
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment