分区隔离-搜索
This commit is contained in:
@@ -55,10 +55,6 @@ public class UserCancelRecord {
|
||||
|
||||
private String userDesc;
|
||||
|
||||
private String alipayAccount;
|
||||
|
||||
private String alipayAccountName;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
@@ -69,10 +65,6 @@ public class UserCancelRecord {
|
||||
|
||||
private Byte shareChannel;
|
||||
|
||||
private String wxPubFansOpenid;
|
||||
|
||||
private Byte wxPubFansGender;
|
||||
|
||||
private String os;
|
||||
|
||||
private String osversion;
|
||||
@@ -133,14 +125,6 @@ public class UserCancelRecord {
|
||||
|
||||
private String registerIp;
|
||||
|
||||
private String weixinOpenid;
|
||||
|
||||
private String weixinUnionid;
|
||||
|
||||
private String qqOpenid;
|
||||
|
||||
private String qqUnionid;
|
||||
|
||||
private String appleUid;
|
||||
|
||||
private String cancelPhone;
|
||||
@@ -329,22 +313,6 @@ public class UserCancelRecord {
|
||||
this.userDesc = userDesc == null ? null : userDesc.trim();
|
||||
}
|
||||
|
||||
public String getAlipayAccount() {
|
||||
return alipayAccount;
|
||||
}
|
||||
|
||||
public void setAlipayAccount(String alipayAccount) {
|
||||
this.alipayAccount = alipayAccount == null ? null : alipayAccount.trim();
|
||||
}
|
||||
|
||||
public String getAlipayAccountName() {
|
||||
return alipayAccountName;
|
||||
}
|
||||
|
||||
public void setAlipayAccountName(String alipayAccountName) {
|
||||
this.alipayAccountName = alipayAccountName == null ? null : alipayAccountName.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
@@ -385,22 +353,6 @@ public class UserCancelRecord {
|
||||
this.shareChannel = shareChannel;
|
||||
}
|
||||
|
||||
public String getWxPubFansOpenid() {
|
||||
return wxPubFansOpenid;
|
||||
}
|
||||
|
||||
public void setWxPubFansOpenid(String wxPubFansOpenid) {
|
||||
this.wxPubFansOpenid = wxPubFansOpenid == null ? null : wxPubFansOpenid.trim();
|
||||
}
|
||||
|
||||
public Byte getWxPubFansGender() {
|
||||
return wxPubFansGender;
|
||||
}
|
||||
|
||||
public void setWxPubFansGender(Byte wxPubFansGender) {
|
||||
this.wxPubFansGender = wxPubFansGender;
|
||||
}
|
||||
|
||||
public String getOs() {
|
||||
return os;
|
||||
}
|
||||
@@ -641,38 +593,6 @@ public class UserCancelRecord {
|
||||
this.registerIp = registerIp == null ? null : registerIp.trim();
|
||||
}
|
||||
|
||||
public String getWeixinOpenid() {
|
||||
return weixinOpenid;
|
||||
}
|
||||
|
||||
public void setWeixinOpenid(String weixinOpenid) {
|
||||
this.weixinOpenid = weixinOpenid == null ? null : weixinOpenid.trim();
|
||||
}
|
||||
|
||||
public String getWeixinUnionid() {
|
||||
return weixinUnionid;
|
||||
}
|
||||
|
||||
public void setWeixinUnionid(String weixinUnionid) {
|
||||
this.weixinUnionid = weixinUnionid == null ? null : weixinUnionid.trim();
|
||||
}
|
||||
|
||||
public String getQqOpenid() {
|
||||
return qqOpenid;
|
||||
}
|
||||
|
||||
public void setQqOpenid(String qqOpenid) {
|
||||
this.qqOpenid = qqOpenid == null ? null : qqOpenid.trim();
|
||||
}
|
||||
|
||||
public String getQqUnionid() {
|
||||
return qqUnionid;
|
||||
}
|
||||
|
||||
public void setQqUnionid(String qqUnionid) {
|
||||
this.qqUnionid = qqUnionid == null ? null : qqUnionid.trim();
|
||||
}
|
||||
|
||||
public String getAppleUid() {
|
||||
return appleUid;
|
||||
}
|
||||
|
@@ -11,8 +11,6 @@
|
||||
<result column="nick" property="nick" jdbcType="VARCHAR" />
|
||||
<result column="email" property="email" jdbcType="VARCHAR" />
|
||||
<result column="signture" property="signture" jdbcType="VARCHAR" />
|
||||
<result column="user_voice" property="userVoice" jdbcType="VARCHAR" />
|
||||
<result column="voice_dura" property="voiceDura" jdbcType="INTEGER" />
|
||||
<result column="follow_num" property="followNum" jdbcType="INTEGER" />
|
||||
<result column="fans_num" property="fansNum" jdbcType="INTEGER" />
|
||||
<result column="def_user" property="defUser" jdbcType="TINYINT" />
|
||||
@@ -24,15 +22,11 @@
|
||||
<result column="avatar" property="avatar" jdbcType="VARCHAR" />
|
||||
<result column="region" property="region" jdbcType="VARCHAR" />
|
||||
<result column="user_desc" property="userDesc" jdbcType="VARCHAR" />
|
||||
<result column="alipay_account" property="alipayAccount" jdbcType="VARCHAR" />
|
||||
<result column="alipay_account_name" property="alipayAccountName" jdbcType="VARCHAR" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
||||
<result column="room_uid" property="roomUid" jdbcType="BIGINT" />
|
||||
<result column="share_uid" property="shareUid" jdbcType="BIGINT" />
|
||||
<result column="share_channel" property="shareChannel" jdbcType="TINYINT" />
|
||||
<result column="wx_pub_fans_openid" property="wxPubFansOpenid" jdbcType="VARCHAR" />
|
||||
<result column="wx_pub_fans_gender" property="wxPubFansGender" jdbcType="TINYINT" />
|
||||
<result column="os" property="os" jdbcType="VARCHAR" />
|
||||
<result column="osVersion" property="osversion" jdbcType="VARCHAR" />
|
||||
<result column="app" property="app" jdbcType="VARCHAR" />
|
||||
@@ -49,8 +43,6 @@
|
||||
<result column="acc_block_end_time" property="accBlockEndTime" jdbcType="TIMESTAMP" />
|
||||
<result column="device_block_start_time" property="deviceBlockStartTime" jdbcType="TIMESTAMP" />
|
||||
<result column="device_block_end_time" property="deviceBlockEndTime" jdbcType="TIMESTAMP" />
|
||||
<result column="noble_id" property="nobleId" jdbcType="INTEGER" />
|
||||
<result column="noble_name" property="nobleName" jdbcType="VARCHAR" />
|
||||
<result column="payment_pwd" property="paymentPwd" jdbcType="VARCHAR" />
|
||||
<result column="real_name" property="realName" jdbcType="VARCHAR" />
|
||||
<result column="id_card_num" property="idCardNum" jdbcType="VARCHAR" />
|
||||
@@ -63,10 +55,6 @@
|
||||
<result column="netease_token" property="neteaseToken" jdbcType="VARCHAR" />
|
||||
<result column="state" property="state" jdbcType="VARCHAR" />
|
||||
<result column="register_ip" property="registerIp" jdbcType="VARCHAR" />
|
||||
<result column="weixin_openid" property="weixinOpenid" jdbcType="VARCHAR" />
|
||||
<result column="weixin_unionid" property="weixinUnionid" jdbcType="VARCHAR" />
|
||||
<result column="qq_openid" property="qqOpenid" jdbcType="VARCHAR" />
|
||||
<result column="qq_unionid" property="qqUnionid" jdbcType="VARCHAR" />
|
||||
<result column="apple_uid" property="appleUid" jdbcType="VARCHAR" />
|
||||
<result column="cancel_phone" property="cancelPhone" jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
|
@@ -5,20 +5,12 @@ import com.accompany.core.vo.user.SearchVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface RoomMapperExpand {
|
||||
|
||||
List<SearchVo> searchRoomByKey(@Param("partitionId") Integer partitionId, @Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
List<SearchVo> searchRoomByKey(@Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
List<SearchVo> searchUserByKey(@Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
List<Room> selectNewRooms(Map<String, Object> param);
|
||||
|
||||
List<Room> selectRadioRooms(Map<String, Object> param);
|
||||
|
||||
List<Room> selectPoolRooms();
|
||||
List<SearchVo> searchUserByKey(@Param("partitionId") Integer partitionId, @Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
Long countValidRooms();
|
||||
|
||||
@@ -28,12 +20,6 @@ public interface RoomMapperExpand {
|
||||
|
||||
List<Room> listValidRoomsExcludePlayroom(@Param("roomId")Long roomId, @Param("index") Integer index, @Param("size") Integer size);
|
||||
|
||||
List<Room> selectPoolRoomsV2(@Param("uid") Long uid);
|
||||
|
||||
List<Room> listValidRoomsByTag(@Param("index") Integer index, @Param("size") Integer size, @Param("roomTag") String roomTag);
|
||||
|
||||
List<SearchVo> searchRoomByKeyV2(@Param("uidList") List<Long> uidList, @Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
List<SearchVo> searchUserByKeyV2(@Param("uidList") List<Long> uidList, @Param("key") String key, @Param("start") Integer start, @Param("limit") Integer limit);
|
||||
|
||||
}
|
@@ -12,10 +12,6 @@
|
||||
<result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
|
||||
<result column="last_login_ip" jdbcType="VARCHAR" property="lastLoginIp"/>
|
||||
<result column="register_ip" jdbcType="VARCHAR" property="registerIp"/>
|
||||
<result column="weixin_openid" jdbcType="VARCHAR" property="weixinOpenid"/>
|
||||
<result column="weixin_unionid" jdbcType="VARCHAR" property="weixinUnionid"/>
|
||||
<result column="qq_openid" jdbcType="VARCHAR" property="qqOpenid"/>
|
||||
<result column="qq_unionid" jdbcType="VARCHAR" property="qqUnionid"/>
|
||||
<result column="apple_uid" jdbcType="VARCHAR" property="appleUid"/>
|
||||
<result column="apple_full_name" jdbcType="VARCHAR" property="appleFullName"/>
|
||||
<result column="os" jdbcType="VARCHAR" property="os"/>
|
||||
@@ -44,8 +40,7 @@
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
uid, phone,erban_no,password,netease_token,state,last_login_time,phone_area_code,
|
||||
last_login_ip,register_ip,weixin_openid,weixin_unionid,qq_openid,
|
||||
qq_unionid,apple_uid,apple_full_name,os,osVersion,app,imei,channel,
|
||||
last_login_ip,register_ip,apple_uid,apple_full_name,os,osVersion,app,imei,channel,
|
||||
linkedme_channel,isp_type,net_type,model,device_id,app_version,acc_block_start_time,
|
||||
acc_block_end_time,device_block_start_time,device_block_end_time,sign_time,update_time,signup_app,
|
||||
prefill_invite_code,prefill_invite_uid,device_info
|
||||
|
@@ -54,7 +54,7 @@
|
||||
|
||||
<select id="searchRoomByKey" resultType="com.accompany.core.vo.user.SearchVo">
|
||||
select u.uid,r.room_id,r.title,r.type,u.avatar,u.gender,u.nick,u.fans_num,u.erban_no,u.def_user, r.online_num, r.valid,u.parent_mode
|
||||
from room r inner join users u on r.uid = u.uid
|
||||
from room r inner join users u on r.uid = u.uid and u.partition_id = #{partitionId}
|
||||
where (r.title like concat(#{key},'%') or u.erban_no like concat(#{key},'%'))
|
||||
and r.valid = 1 and u.def_user <> 3
|
||||
order by u.erban_no
|
||||
@@ -66,40 +66,11 @@
|
||||
from users u
|
||||
where (u.erban_no like concat(#{key},'%') or u.nick like concat(#{key},'%'))
|
||||
and u.def_user <> 3
|
||||
and u.partition_id = #{partitionId}
|
||||
order by erban_no
|
||||
limit #{start},#{limit}
|
||||
</select>
|
||||
|
||||
<select id="selectNewRooms" resultMap="RoomResultMap">
|
||||
select uid, room_id,room_pwd,tag_id,tag_pict, room_tag,badge,meeting_name,title,valid,type,official_room,ab_channel_type,operator_status,room_desc,back_pic,open_time,is_permit_room,online_num,create_time,recom_seq,(select t1.avatar from users t1 where t1.uid=r1.uid) as avatar,
|
||||
def_backpic, has_animation_effect, audio_quality
|
||||
from room r1 where DATE_SUB(CURDATE(),INTERVAL #{day} day) <= DATE(create_time) AND online_num>0 AND valid=1 AND is_permit_room>0 AND r1.can_show=1,
|
||||
<if test="hideUids != null and hideUids.size> 0" >
|
||||
AND uid NOT IN
|
||||
<foreach item="item" index="index" collection="hideUids" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by create_time desc limit #{skip},#{size}
|
||||
</select>
|
||||
|
||||
<select id="selectRadioRooms" resultMap="RoomResultMap">
|
||||
select uid, room_id,room_pwd,tag_id,tag_pict, room_tag,badge,meeting_name,title,valid,type,official_room,ab_channel_type,operator_status,room_desc,back_pic,open_time,is_permit_room,online_num,create_time,recom_seq,(select t1.avatar from users t1 where t1.uid=r1.uid) as avatar,
|
||||
def_backpic, has_animation_effect, audio_quality
|
||||
from room r1 where type=2 AND online_num>0 AND valid=1 AND is_permit_room>0 AND r1.can_show=1
|
||||
<if test="hideUids != null and hideUids.size> 0" >
|
||||
AND uid NOT IN
|
||||
<foreach item="item" index="index" collection="hideUids" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by create_time desc limit #{skip},#{size}
|
||||
</select>
|
||||
|
||||
<select id="selectPoolRooms" resultMap="RoomResultMap">
|
||||
select * from room where uid in (select uid from room_recom_pool)
|
||||
</select>
|
||||
|
||||
<select id="countValidRooms" resultType="java.lang.Long">
|
||||
select count(1) from room where valid = 1 and online_num > 0
|
||||
</select>
|
||||
@@ -114,51 +85,7 @@
|
||||
select * from room where valid = 1 and online_num > 0 and room_id != #{roomId} limit #{index}, #{size}
|
||||
</select>
|
||||
|
||||
<select id="selectPoolRoomsV2" resultMap="RoomResultMap">
|
||||
select * from room where uid in
|
||||
(
|
||||
select uid from room_recom_pool
|
||||
<where>
|
||||
<if test="uid != null">
|
||||
uid = #{uid}
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="listValidRoomsByTag" resultMap = "RoomResultMap">
|
||||
select * from room where valid = 1 and online_num > 0 and room_tag = #{roomTag} limit #{index}, #{size}
|
||||
</select>
|
||||
|
||||
<select id="searchRoomByKeyV2" resultType="com.accompany.core.vo.user.SearchVo">
|
||||
select u.uid,r.room_id,r.title,r.type,u.avatar,u.gender,u.nick,u.fans_num,u.erban_no,u.def_user, r.online_num, r.valid,u.parent_mode, u.birth
|
||||
from (
|
||||
select * from room where uid in
|
||||
<foreach item="item" index="index" collection="uidList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
) r
|
||||
join users u on u.uid=r.uid
|
||||
where r.valid = 1 and u.def_user <> 3
|
||||
and u.erban_no like concat(#{key},'%') or r.title like concat(#{key},'%')
|
||||
order by u.erban_no
|
||||
limit #{start},#{limit}
|
||||
</select>
|
||||
|
||||
<select id="searchUserByKeyV2" resultType="com.accompany.core.vo.user.SearchVo">
|
||||
select u.uid,u.avatar,u.gender,u.nick,u.fans_num,u.erban_no,u.def_user,u.has_pretty_erban_no,u.parent_mode,u.birth
|
||||
from users u
|
||||
where
|
||||
u.uid in
|
||||
<foreach item="item" index="index" collection="uidList" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
and (
|
||||
u.def_user <> 3
|
||||
and u.erban_no like concat(#{key},'%')
|
||||
or u.nick like concat(#{key},'%')
|
||||
)
|
||||
order by erban_no
|
||||
limit #{start},#{limit}
|
||||
</select>
|
||||
</mapper>
|
@@ -27,15 +27,11 @@
|
||||
<result property="avatar" column="avatar"/>
|
||||
<result property="region" column="region"/>
|
||||
<result property="userDesc" column="user_desc"/>
|
||||
<result property="alipayAccount" column="alipay_account"/>
|
||||
<result property="alipayAccountName" column="alipay_account_name"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="roomUid" column="room_uid"/>
|
||||
<result property="shareUid" column="share_uid"/>
|
||||
<result property="shareChannel" column="share_channel"/>
|
||||
<result property="wxPubFansOpenid" column="wx_pub_fans_openid"/>
|
||||
<result property="wxPubFansGender" column="wx_pub_fans_gender"/>
|
||||
<result property="os" column="os"/>
|
||||
<result property="osversion" column="osVersion"/>
|
||||
<result property="app" column="app"/>
|
||||
@@ -52,8 +48,6 @@
|
||||
<result property="accBlockEndTime" column="acc_block_end_time"/>
|
||||
<result property="deviceBlockStartTime" column="device_block_start_time"/>
|
||||
<result property="deviceBlockEndTime" column="device_block_end_time"/>
|
||||
<result property="nobleId" column="noble_id"/>
|
||||
<result property="nobleName" column="noble_name"/>
|
||||
<result property="paymentPwd" column="payment_pwd"/>
|
||||
<result property="realName" column="real_name"/>
|
||||
<result property="idCardNum" column="id_card_num"/>
|
||||
@@ -66,10 +60,6 @@
|
||||
<result property="neteaseToken" column="netease_token"/>
|
||||
<result property="state" column="state"/>
|
||||
<result property="registerIp" column="register_ip"/>
|
||||
<result property="weixinOpenid" column="weixin_openid"/>
|
||||
<result property="weixinUnionid" column="weixin_unionid"/>
|
||||
<result property="qqOpenid" column="qq_openid"/>
|
||||
<result property="qqUnionid" column="qq_unionid"/>
|
||||
<result property="appleUid" column="apple_uid"/>
|
||||
<result property="cancelPhone" column="cancel_phone"/>
|
||||
</resultMap>
|
||||
|
@@ -39,7 +39,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
@@ -122,8 +121,13 @@ public class RoomSearchService extends BaseService {
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
public List<SearchVo> search(Long uid, String searchText, Integer searchType, Integer page, Integer pageSize) throws Exception {
|
||||
Users u = usersService.getUsersByUid(uid);
|
||||
if (null == u) {
|
||||
throw new ServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
|
||||
// 检查是否命中缓存
|
||||
String searchTextKey = String.join("_", searchText, searchType.toString());
|
||||
String searchTextKey = String.join("_", u.getPartitionId().toString(), searchText, searchType.toString());
|
||||
String cacheKey = RedisKey.search_text_cache.getKey(searchTextKey);
|
||||
String result = jedisService.get(cacheKey);
|
||||
|
||||
@@ -148,7 +152,7 @@ public class RoomSearchService extends BaseService {
|
||||
}
|
||||
|
||||
Integer pageStart = (page - 1) * pageSize;
|
||||
List<SearchVo> searchVos = searchByKey(searchText, searchType, pageStart, pageSize);
|
||||
List<SearchVo> searchVos = searchByKey(u.getPartitionId(), searchText, searchType, pageStart, pageSize);
|
||||
|
||||
// 缓存结果默认5秒
|
||||
jedisService.set(cacheKey, gson.toJson(searchVos));
|
||||
@@ -165,10 +169,10 @@ public class RoomSearchService extends BaseService {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private List<SearchVo> searchByKey(String searchText, Integer searchType, Integer pageStart, Integer pageSize) {
|
||||
private List<SearchVo> searchByKey(Integer partitionId, String searchText, Integer searchType, Integer pageStart, Integer pageSize) {
|
||||
List<SearchVo> searchVos = (searchType == 1 ?
|
||||
searchRoomByKey(searchText, pageStart, pageSize) :
|
||||
searchUserByKey(searchText, pageStart, pageSize));
|
||||
searchRoomByKey(partitionId, searchText, pageStart, pageSize) :
|
||||
searchUserByKey(partitionId, searchText, pageStart, pageSize));
|
||||
|
||||
if (CollectionUtils.isEmpty(searchVos)) {
|
||||
return Collections.emptyList();
|
||||
@@ -240,12 +244,12 @@ public class RoomSearchService extends BaseService {
|
||||
return searchVos.stream().filter(vo -> !blockedUids.contains(vo.getErbanNo())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SearchVo> searchRoomByKey(String searchText, Integer start, Integer limit) {
|
||||
return roomMapperExpand.searchRoomByKey(searchText, start, limit);
|
||||
public List<SearchVo> searchRoomByKey(Integer partitionId, String searchText, Integer start, Integer limit) {
|
||||
return roomMapperExpand.searchRoomByKey(partitionId, searchText, start, limit);
|
||||
}
|
||||
|
||||
public List<SearchVo> searchUserByKey(String searchText, Integer start, Integer limit) {
|
||||
return roomMapperExpand.searchUserByKey(searchText, start, limit);
|
||||
public List<SearchVo> searchUserByKey(Integer partitionId, String searchText, Integer start, Integer limit) {
|
||||
return roomMapperExpand.searchUserByKey(partitionId, searchText, start, limit);
|
||||
}
|
||||
|
||||
|
||||
@@ -439,15 +443,20 @@ public class RoomSearchService extends BaseService {
|
||||
}
|
||||
|
||||
public List<SearchVo> searchByEs(Long uid, String searchText, Integer searchType, Integer page, Integer pageSize, DeviceInfo deviceInfo) throws Exception {
|
||||
Users u = usersService.getUsersByUid(uid);
|
||||
if (null == u){
|
||||
throw new ServiceException(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
|
||||
List<Long> validUidList = new ArrayList<>();
|
||||
QueryBuilder queryBuilder;
|
||||
String index = null;
|
||||
if (SEARCH_TYPE_ROOM.equals(searchType)) {
|
||||
queryBuilder = genRoomSearchQueryCondition(validUidList, searchText);
|
||||
queryBuilder = genRoomSearchQueryCondition(u.getPartitionId(), validUidList, searchText);
|
||||
index = elasticsearchConfig.getRoomIndex();
|
||||
} else {
|
||||
queryBuilder =
|
||||
genUserSearchQueryCondition(validUidList, searchText);
|
||||
genUserSearchQueryCondition(u.getPartitionId(), validUidList, searchText);
|
||||
index = elasticsearchConfig.getUserIndex();
|
||||
}
|
||||
|
||||
@@ -462,9 +471,10 @@ public class RoomSearchService extends BaseService {
|
||||
return searchVos;
|
||||
}
|
||||
|
||||
private QueryBuilder genUserSearchQueryCondition(List<Long> validUidList, String searchText) {
|
||||
private QueryBuilder genUserSearchQueryCondition(Integer partitionId, List<Long> validUidList, String searchText) {
|
||||
BoolQueryBuilder queryConditionBuilder = QueryBuilders.boolQuery()
|
||||
.mustNot(QueryBuilders.matchPhraseQuery("defUser", Constant.DefUser.ROBOT))
|
||||
.must(QueryBuilders.termQuery("partitionId", partitionId))
|
||||
.filter(
|
||||
QueryBuilders.boolQuery().should(QueryBuilders.matchPhraseQuery("nick", searchText))
|
||||
.should(QueryBuilders.matchPhraseQuery("erbanNo", searchText))
|
||||
@@ -479,10 +489,11 @@ public class RoomSearchService extends BaseService {
|
||||
return queryConditionBuilder;
|
||||
}
|
||||
|
||||
private QueryBuilder genRoomSearchQueryCondition(List<Long> validUidList, String searchText) {
|
||||
private QueryBuilder genRoomSearchQueryCondition(Integer partitionId, List<Long> validUidList, String searchText) {
|
||||
BoolQueryBuilder queryConditionBuilder = QueryBuilders.boolQuery()
|
||||
.mustNot(QueryBuilders.matchPhraseQuery("defUser", Constant.DefUser.ROBOT))
|
||||
.must(QueryBuilders.termQuery("valid", Constant.StatusV2.valid))
|
||||
.must(QueryBuilders.termQuery("partitionId", partitionId))
|
||||
.filter(
|
||||
QueryBuilders.boolQuery().should(QueryBuilders.matchPhraseQuery("title", searchText))
|
||||
.should(QueryBuilders.matchPhraseQuery("erbanNo", searchText))
|
||||
|
@@ -20,59 +20,10 @@ import java.util.concurrent.TimeUnit;
|
||||
@Component
|
||||
public class HomeTask extends BaseTask {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomeTask.class);
|
||||
public static volatile boolean isDoHomeDataJob = false;
|
||||
|
||||
@Autowired
|
||||
private RoomMapperExpand roomMapperExpand;
|
||||
@Autowired
|
||||
private FaceJsonService faceJsonService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 定时刷新首页数据, 2min
|
||||
*/
|
||||
// @Scheduled(cron = "0 */2 * * * ?")
|
||||
// public void doHomeDataJob(){
|
||||
// try {
|
||||
// isDoHomeDataJob = true;
|
||||
// logger.info("HomeDataJob doHomeDataJob start.....");
|
||||
// homeService.doHomeDataJob();
|
||||
// logger.info("HomeDataJob doHomeDataJob finish.....");
|
||||
// } catch (Exception e) {
|
||||
// logger.error("doHomeDataJob error,", e);
|
||||
// }finally {
|
||||
// isDoHomeDataJob = false;
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 从配置池中获取房间列表,随机排序后保存到缓存;
|
||||
* 首页加载时从缓存中获取,分页返回
|
||||
*/
|
||||
//@Scheduled(cron = "0 */2 * * * ?")
|
||||
public void cacheRandomRoom(){
|
||||
try {
|
||||
List<Room> list = roomMapperExpand.selectPoolRooms();
|
||||
if (BlankUtil.isBlank(list)) {
|
||||
jedisService.set(RedisKey.home_room_random.getKey(), "[]");
|
||||
return;
|
||||
}
|
||||
// 打乱列表的排序
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
int pos = random.nextInt(list.size());
|
||||
Room curRoom = list.get(i);
|
||||
// 当前位置的元素换成随机位置上的元素
|
||||
list.set(i, list.get(pos));
|
||||
list.set(pos, curRoom);
|
||||
}
|
||||
jedisService.set(RedisKey.home_room_random.getKey(), gson.toJson(list));
|
||||
} catch (Exception e) {
|
||||
logger.error("cacheRandomRoom error", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存当前有效的表情JSON
|
||||
*/
|
||||
|
Reference in New Issue
Block a user