|
|
@ -11,6 +11,7 @@ import cc.hiver.mall.ie.service.IeMatchService; |
|
|
import cc.hiver.mall.ie.service.IeRedisService; |
|
|
import cc.hiver.mall.ie.service.IeRedisService; |
|
|
import cc.hiver.mall.ie.service.IeSecurityAuditService; |
|
|
import cc.hiver.mall.ie.service.IeSecurityAuditService; |
|
|
import cc.hiver.mall.ie.vo.*; |
|
|
import cc.hiver.mall.ie.vo.*; |
|
|
|
|
|
import cc.hiver.mall.service.HomeReminderService; |
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import cn.hutool.json.JSONUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
@ -57,6 +58,9 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IeAliyunModerationService aliyunModerationService; |
|
|
private IeAliyunModerationService aliyunModerationService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private HomeReminderService homeReminderService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public IeHomeVO home(Long userId) { |
|
|
public IeHomeVO home(Long userId) { |
|
|
IeUserProfile profile = ensureProfile(userId); |
|
|
IeUserProfile profile = ensureProfile(userId); |
|
|
@ -70,7 +74,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
vo.setWaitingCount(redisService.waitingCount(profile.getCurrentMode(), currentMood, profile.getRegionId(), hasText(profile.getRegionId()))); |
|
|
vo.setWaitingCount(redisService.waitingCount(profile.getCurrentMode(), currentMood, profile.getRegionId(), hasText(profile.getRegionId()))); |
|
|
vo.setDailyQuota(effectiveDailyQuota(profile)); |
|
|
vo.setDailyQuota(effectiveDailyQuota(profile)); |
|
|
vo.setUsedQuota((int) redisService.todayUsedQuota(userId)); |
|
|
vo.setUsedQuota((int) redisService.todayUsedQuota(userId)); |
|
|
vo.setUnreadCount(totalUnreadCount(userId)); |
|
|
vo.setUnreadCount(cachedUnreadCount(userId)); |
|
|
vo.setCurrentMode(profile.getCurrentMode()); |
|
|
vo.setCurrentMode(profile.getCurrentMode()); |
|
|
vo.setCurrentMood(currentMood); |
|
|
vo.setCurrentMood(currentMood); |
|
|
vo.setTargetModePreference(profile.getTargetModePreference()); |
|
|
vo.setTargetModePreference(profile.getTargetModePreference()); |
|
|
@ -78,12 +82,18 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
vo.setProfileCompleted(profile.getProfileCompleted() == null ? 0 : profile.getProfileCompleted()); |
|
|
vo.setProfileCompleted(profile.getProfileCompleted() == null ? 0 : profile.getProfileCompleted()); |
|
|
vo.setProfile(toProfileVO(profile)); |
|
|
vo.setProfile(toProfileVO(profile)); |
|
|
vo.setHotStatuses(redisService.hotStatuses(8)); |
|
|
vo.setHotStatuses(redisService.hotStatuses(8)); |
|
|
|
|
|
vo.setCompanionIntents(latestCompanionIntents(userId, 50)); |
|
|
return vo; |
|
|
return vo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int unreadCount(Long userId) { |
|
|
public int unreadCount(Long userId) { |
|
|
return totalUnreadCount(userId); |
|
|
return cachedUnreadCount(userId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int cachedUnreadCount(Long userId) { |
|
|
|
|
|
Integer cached = homeReminderService.getIeUnreadCount(userId); |
|
|
|
|
|
return cached == null ? 0 : cached; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private int totalUnreadCount(Long userId) { |
|
|
private int totalUnreadCount(Long userId) { |
|
|
@ -141,6 +151,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
// 昵称/一句话介绍单独审(取过滤后的文案),头像字、兴趣标签、地区名合并成一次审核(只判拦截)
|
|
|
// 昵称/一句话介绍单独审(取过滤后的文案),头像字、兴趣标签、地区名合并成一次审核(只判拦截)
|
|
|
String anonymousName = auditProfileText("profile-name", userId, defaultText(dto.getAnonymousName(), profile.getAnonymousName())); |
|
|
String anonymousName = auditProfileText("profile-name", userId, defaultText(dto.getAnonymousName(), profile.getAnonymousName())); |
|
|
String intro = auditProfileText("profile-intro", userId, defaultText(dto.getIntro(), "")); |
|
|
String intro = auditProfileText("profile-intro", userId, defaultText(dto.getIntro(), "")); |
|
|
|
|
|
String companionIntent = auditCompanionIntent(userId, defaultText(dto.getCompanionIntent(), profile.getCompanionIntent())); |
|
|
String avatarText = defaultText(dto.getAvatarText(), "我"); |
|
|
String avatarText = defaultText(dto.getAvatarText(), "我"); |
|
|
StringBuilder extraText = new StringBuilder(avatarText); |
|
|
StringBuilder extraText = new StringBuilder(avatarText); |
|
|
if (dto.getInterestTags() != null) { |
|
|
if (dto.getInterestTags() != null) { |
|
|
@ -162,6 +173,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
} |
|
|
} |
|
|
profile.setGender(normalizeGender(dto.getGender(), "unknown")); |
|
|
profile.setGender(normalizeGender(dto.getGender(), "unknown")); |
|
|
profile.setIntro(intro); |
|
|
profile.setIntro(intro); |
|
|
|
|
|
profile.setCompanionIntent(companionIntent); |
|
|
profile.setInterestTags(tagsToJson(dto.getInterestTags())); |
|
|
profile.setInterestTags(tagsToJson(dto.getInterestTags())); |
|
|
// 人格卡片图片:只审本次新增的,已通过的旧图不重复送审
|
|
|
// 人格卡片图片:只审本次新增的,已通过的旧图不重复送审
|
|
|
if (dto.getPersonaImages() != null) { |
|
|
if (dto.getPersonaImages() != null) { |
|
|
@ -312,14 +324,20 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
} |
|
|
} |
|
|
statusDTO.setRegionId(regionId); |
|
|
statusDTO.setRegionId(regionId); |
|
|
statusDTO.setRegionName(regionName); |
|
|
statusDTO.setRegionName(regionName); |
|
|
|
|
|
auditAndSaveMatchCompanionIntent(userId, profile, dto == null ? null : dto.getCompanionIntent()); |
|
|
updateStatus(userId, statusDTO); |
|
|
updateStatus(userId, statusDTO); |
|
|
String mood = statusDTO.getMood() == null ? "quiet" : statusDTO.getMood(); |
|
|
String mood = statusDTO.getMood() == null ? "quiet" : statusDTO.getMood(); |
|
|
String intent = normalizeIntent(dto == null ? null : dto.getIntent()); |
|
|
String intent = normalizeIntent(dto == null ? null : dto.getIntent()); |
|
|
if (intent != null) { |
|
|
if (intent != null) { |
|
|
redisService.addToIntentPool(intent, userId); |
|
|
redisService.addToIntentPool(intent, userId); |
|
|
} |
|
|
} |
|
|
List<Long> candidates = candidateUsers(targetMode, mode, mood, regionId, regionScope); |
|
|
String fuzzyKeyword = normalizeFuzzyKeyword(dto == null ? null : dto.getFuzzyKeyword()); |
|
|
if (intent != null) { |
|
|
boolean fuzzySearch = hasText(fuzzyKeyword); |
|
|
|
|
|
List<Long> candidates = fuzzySearch ? fuzzyCandidates(userId, fuzzyKeyword, 80) : new ArrayList<>(); |
|
|
|
|
|
if (candidates.isEmpty()) { |
|
|
|
|
|
candidates = candidateUsers(targetMode, mode, mood, regionId, regionScope); |
|
|
|
|
|
} |
|
|
|
|
|
if (!fuzzySearch && intent != null) { |
|
|
// 同意图的人优先进入候选(去重交给 LinkedHashSet 逻辑前置)
|
|
|
// 同意图的人优先进入候选(去重交给 LinkedHashSet 逻辑前置)
|
|
|
List<Long> intentUsers = redisService.intentCandidates(intent, 50); |
|
|
List<Long> intentUsers = redisService.intentCandidates(intent, 50); |
|
|
intentUsers.removeAll(candidates); |
|
|
intentUsers.removeAll(candidates); |
|
|
@ -350,6 +368,9 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
if (intent != null && redisService.inIntentPool(intent, candidateUserId)) { |
|
|
if (intent != null && redisService.inIntentPool(intent, candidateUserId)) { |
|
|
score += 200; |
|
|
score += 200; |
|
|
} |
|
|
} |
|
|
|
|
|
if (fuzzySearch) { |
|
|
|
|
|
score += fuzzyFieldScore(candidateProfile, fuzzyKeyword); |
|
|
|
|
|
} |
|
|
matchedCandidates.add(new MatchCandidate(candidateUserId, score)); |
|
|
matchedCandidates.add(new MatchCandidate(candidateUserId, score)); |
|
|
} |
|
|
} |
|
|
for (MatchCandidate candidate : randomizeCandidates(matchedCandidates)) { |
|
|
for (MatchCandidate candidate : randomizeCandidates(matchedCandidates)) { |
|
|
@ -403,13 +424,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
} |
|
|
} |
|
|
vo.setRoomId(room.getId()); |
|
|
vo.setRoomId(room.getId()); |
|
|
vo.setRoomNo(room.getRoomNo()); |
|
|
vo.setRoomNo(room.getRoomNo()); |
|
|
vo.setAvatarUrl(targetProfile.getAvatarUrl()); |
|
|
fillMatchTargetProfile(vo, targetProfile); |
|
|
vo.setGender(targetProfile.getGender()); |
|
|
|
|
|
vo.setRegionId(targetProfile.getRegionId()); |
|
|
|
|
|
vo.setRegionName(targetProfile.getRegionName()); |
|
|
|
|
|
vo.setIntro(targetProfile.getIntro()); |
|
|
|
|
|
vo.setInterestTags(jsonToTags(targetProfile.getInterestTags())); |
|
|
|
|
|
vo.setPersonaImages(jsonToTags(targetProfile.getPersonaImages())); |
|
|
|
|
|
vo.setLastActiveText(lastActiveText(targetUserId, targetProfile, statusActiveMap.get(targetUserId))); |
|
|
vo.setLastActiveText(lastActiveText(targetUserId, targetProfile, statusActiveMap.get(targetUserId))); |
|
|
vo.setIntent(intent); |
|
|
vo.setIntent(intent); |
|
|
vo.setIntentMatched(intent != null && redisService.inIntentPool(intent, targetUserId)); |
|
|
vo.setIntentMatched(intent != null && redisService.inIntentPool(intent, targetUserId)); |
|
|
@ -444,7 +459,11 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
if (hasBlockRelation(userId, targetUserId)) { |
|
|
if (hasBlockRelation(userId, targetUserId)) { |
|
|
throw new RuntimeException("你们之间存在黑名单关系,无法发起陪伴"); |
|
|
throw new RuntimeException("你们之间存在黑名单关系,无法发起陪伴"); |
|
|
} |
|
|
} |
|
|
IeUserProfile targetProfile = ensureProfile(targetUserId); |
|
|
IeUserProfile targetProfile = findProfileByUserId(targetUserId); |
|
|
|
|
|
if (targetProfile == null || targetProfile.getProfileCompleted() == null || targetProfile.getProfileCompleted() != 1 |
|
|
|
|
|
|| Integer.valueOf(1).equals(targetProfile.getIsDeleted())) { |
|
|
|
|
|
throw new RuntimeException("对方资料不存在或暂不可匹配"); |
|
|
|
|
|
} |
|
|
IeRoom existing = findReusableRoom(userId, targetUserId); |
|
|
IeRoom existing = findReusableRoom(userId, targetUserId); |
|
|
boolean hasExistingRelation = existing != null || hasRoomRelation(userId, targetUserId); |
|
|
boolean hasExistingRelation = existing != null || hasRoomRelation(userId, targetUserId); |
|
|
long maxQuota = effectiveDailyQuota(profile); |
|
|
long maxQuota = effectiveDailyQuota(profile); |
|
|
@ -481,13 +500,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
IeMatchVO vo = toMatchVO(match); |
|
|
IeMatchVO vo = toMatchVO(match); |
|
|
vo.setRoomId(room.getId()); |
|
|
vo.setRoomId(room.getId()); |
|
|
vo.setRoomNo(room.getRoomNo()); |
|
|
vo.setRoomNo(room.getRoomNo()); |
|
|
vo.setAvatarUrl(targetProfile.getAvatarUrl()); |
|
|
fillMatchTargetProfile(vo, targetProfile); |
|
|
vo.setGender(targetProfile.getGender()); |
|
|
|
|
|
vo.setRegionId(targetProfile.getRegionId()); |
|
|
|
|
|
vo.setRegionName(targetProfile.getRegionName()); |
|
|
|
|
|
vo.setIntro(targetProfile.getIntro()); |
|
|
|
|
|
vo.setInterestTags(jsonToTags(targetProfile.getInterestTags())); |
|
|
|
|
|
vo.setPersonaImages(jsonToTags(targetProfile.getPersonaImages())); |
|
|
|
|
|
return vo; |
|
|
return vo; |
|
|
} catch (RuntimeException e) { |
|
|
} catch (RuntimeException e) { |
|
|
if (!hasExistingRelation) { |
|
|
if (!hasExistingRelation) { |
|
|
@ -557,13 +570,55 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
if (profile == null) { |
|
|
if (profile == null) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
fillMatchTargetProfile(vo, profile); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void fillMatchTargetProfile(IeMatchVO vo, IeUserProfile profile) { |
|
|
|
|
|
if (vo == null || profile == null) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
vo.setAnonymousName(defaultText(profile.getAnonymousName(), vo.getAnonymousName())); |
|
|
vo.setAnonymousName(defaultText(profile.getAnonymousName(), vo.getAnonymousName())); |
|
|
vo.setAvatarText(defaultText(profile.getAvatarText(), vo.getAvatarText())); |
|
|
vo.setAvatarText(defaultText(profile.getAvatarText(), vo.getAvatarText())); |
|
|
vo.setAvatarUrl(profile.getAvatarUrl()); |
|
|
vo.setAvatarUrl(profile.getAvatarUrl()); |
|
|
|
|
|
vo.setGender(profile.getGender()); |
|
|
vo.setRegionId(defaultText(profile.getRegionId(), vo.getRegionId())); |
|
|
vo.setRegionId(defaultText(profile.getRegionId(), vo.getRegionId())); |
|
|
vo.setRegionName(defaultText(profile.getRegionName(), vo.getRegionName())); |
|
|
vo.setRegionName(defaultText(profile.getRegionName(), vo.getRegionName())); |
|
|
vo.setMode(defaultText(profile.getCurrentMode(), vo.getMode())); |
|
|
vo.setMode(defaultText(profile.getCurrentMode(), vo.getMode())); |
|
|
|
|
|
vo.setIntro(profile.getIntro()); |
|
|
vo.setQuoteText(defaultText(profile.getIntro(), vo.getQuoteText())); |
|
|
vo.setQuoteText(defaultText(profile.getIntro(), vo.getQuoteText())); |
|
|
|
|
|
vo.setCompanionIntent(profile.getCompanionIntent()); |
|
|
|
|
|
vo.setInterestTags(jsonToTags(profile.getInterestTags())); |
|
|
|
|
|
vo.setPersonaImages(jsonToTags(profile.getPersonaImages())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<Map<String, Object>> latestCompanionIntents(Long currentUserId, Integer limit) { |
|
|
|
|
|
int safeLimit = limit == null ? 50 : Math.max(1, Math.min(limit, 50)); |
|
|
|
|
|
List<IeUserProfile> profiles = userProfileMapper.selectList(new LambdaQueryWrapper<IeUserProfile>() |
|
|
|
|
|
.eq(IeUserProfile::getProfileCompleted, 1) |
|
|
|
|
|
.eq(IeUserProfile::getIsDeleted, 0) |
|
|
|
|
|
.isNotNull(IeUserProfile::getCompanionIntent) |
|
|
|
|
|
.ne(IeUserProfile::getCompanionIntent, "") |
|
|
|
|
|
.orderByDesc(IeUserProfile::getUpdateTime) |
|
|
|
|
|
.last("limit " + safeLimit)); |
|
|
|
|
|
List<Map<String, Object>> items = new ArrayList<>(); |
|
|
|
|
|
for (IeUserProfile profile : profiles) { |
|
|
|
|
|
if (profile == null || !hasText(profile.getCompanionIntent())) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
Map<String, Object> item = new HashMap<>(); |
|
|
|
|
|
// 小程序端 JS Number 会丢失 Long 精度,定向匹配必须用字符串承载真实 userId。
|
|
|
|
|
|
item.put("userId", String.valueOf(profile.getUserId())); |
|
|
|
|
|
item.put("isSelf", Objects.equals(profile.getUserId(), currentUserId)); |
|
|
|
|
|
item.put("text", profile.getCompanionIntent()); |
|
|
|
|
|
item.put("type", normalizeMode(profile.getCurrentMode(), "i")); |
|
|
|
|
|
item.put("mood", "talk"); |
|
|
|
|
|
item.put("anonymousName", defaultText(profile.getAnonymousName(), "半匿名漂流者")); |
|
|
|
|
|
item.put("avatarText", defaultText(profile.getAvatarText(), "◌")); |
|
|
|
|
|
item.put("avatarUrl", profile.getAvatarUrl()); |
|
|
|
|
|
items.add(item); |
|
|
|
|
|
} |
|
|
|
|
|
return items; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private IeRoom createRoom(IeMatchAttempt match, Long userId, Long targetUserId, String mode, String mood) { |
|
|
private IeRoom createRoom(IeMatchAttempt match, Long userId, Long targetUserId, String mode, String mood) { |
|
|
@ -852,6 +907,31 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
return score; |
|
|
return score; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 模糊搜索只在命中的用户集合内挑最适合的人;字段优先级:昵称 > 一句话签名 > 找搭子内容。 |
|
|
|
|
|
*/ |
|
|
|
|
|
private int fuzzyFieldScore(IeUserProfile profile, String keyword) { |
|
|
|
|
|
if (profile == null || !hasText(keyword)) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
String key = keyword.trim(); |
|
|
|
|
|
int score = 0; |
|
|
|
|
|
if (containsText(profile.getAnonymousName(), key)) { |
|
|
|
|
|
score += 300; |
|
|
|
|
|
} |
|
|
|
|
|
if (containsText(profile.getIntro(), key)) { |
|
|
|
|
|
score += 200; |
|
|
|
|
|
} |
|
|
|
|
|
if (containsText(profile.getCompanionIntent(), key)) { |
|
|
|
|
|
score += 120; |
|
|
|
|
|
} |
|
|
|
|
|
return score; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean containsText(String value, String keyword) { |
|
|
|
|
|
return value != null && keyword != null && value.contains(keyword); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 随机化候选顺序:先打乱再按得分稳定排序(同分顺序随机), |
|
|
* 随机化候选顺序:先打乱再按得分稳定排序(同分顺序随机), |
|
|
* 然后在得分最高的一批里整体随机,避免每次都按固定顺序匹配到同一个人。 |
|
|
* 然后在得分最高的一批里整体随机,避免每次都按固定顺序匹配到同一个人。 |
|
|
@ -930,6 +1010,33 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
return users; |
|
|
return users; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Long> fuzzyCandidates(Long currentUserId, String keyword, int limit) { |
|
|
|
|
|
if (!hasText(keyword)) { |
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
} |
|
|
|
|
|
String like = "%" + keyword.trim() + "%"; |
|
|
|
|
|
LambdaQueryWrapper<IeUserProfile> query = new LambdaQueryWrapper<IeUserProfile>() |
|
|
|
|
|
.eq(IeUserProfile::getProfileCompleted, 1) |
|
|
|
|
|
.eq(IeUserProfile::getIsDeleted, 0) |
|
|
|
|
|
.ne(currentUserId != null, IeUserProfile::getUserId, currentUserId) |
|
|
|
|
|
.and(wrapper -> wrapper |
|
|
|
|
|
.like(IeUserProfile::getAnonymousName, like) |
|
|
|
|
|
.or() |
|
|
|
|
|
.like(IeUserProfile::getIntro, like) |
|
|
|
|
|
.or() |
|
|
|
|
|
.like(IeUserProfile::getCompanionIntent, like)) |
|
|
|
|
|
.orderByDesc(IeUserProfile::getLastActiveTime) |
|
|
|
|
|
.last("limit " + Math.max(1, Math.min(limit, 100))); |
|
|
|
|
|
List<IeUserProfile> profiles = userProfileMapper.selectList(query); |
|
|
|
|
|
List<Long> users = new ArrayList<>(); |
|
|
|
|
|
for (IeUserProfile profile : profiles) { |
|
|
|
|
|
if (profile.getUserId() != null) { |
|
|
|
|
|
users.add(profile.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return users; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private String auditProfileText(String bizType, Long userId, String content) { |
|
|
private String auditProfileText(String bizType, Long userId, String content) { |
|
|
IeAuditResult result = auditService.audit(bizType, userId, userId, content); |
|
|
IeAuditResult result = auditService.audit(bizType, userId, userId, content); |
|
|
if (Boolean.TRUE.equals(result.getBlocked())) { |
|
|
if (Boolean.TRUE.equals(result.getBlocked())) { |
|
|
@ -938,6 +1045,31 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
return result.getFilteredContent(); |
|
|
return result.getFilteredContent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String auditCompanionIntent(Long userId, String content) { |
|
|
|
|
|
if (!hasText(content)) { |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
String trimmed = content.trim(); |
|
|
|
|
|
if (trimmed.length() > 24) { |
|
|
|
|
|
throw new RuntimeException("找搭子内容不能超过 24 个字"); |
|
|
|
|
|
} |
|
|
|
|
|
return auditProfileText("profile-companion-intent", userId, trimmed); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String auditAndSaveMatchCompanionIntent(Long userId, IeUserProfile profile, String content) { |
|
|
|
|
|
if (!hasText(content)) { |
|
|
|
|
|
return profile == null ? "" : defaultText(profile.getCompanionIntent(), ""); |
|
|
|
|
|
} |
|
|
|
|
|
String audited = auditCompanionIntent(userId, content); |
|
|
|
|
|
if (profile != null && !Objects.equals(profile.getCompanionIntent(), audited)) { |
|
|
|
|
|
profile.setCompanionIntent(audited); |
|
|
|
|
|
profile.setUpdateTime(new Date()); |
|
|
|
|
|
profile.setLastActiveTime(new Date()); |
|
|
|
|
|
userProfileMapper.updateById(profile); |
|
|
|
|
|
} |
|
|
|
|
|
return audited; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void auditProfileImage(String imageUrl, String existingUrl) { |
|
|
private void auditProfileImage(String imageUrl, String existingUrl) { |
|
|
if (imageUrl == null || imageUrl.trim().isEmpty() || imageUrl.equals(existingUrl)) { |
|
|
if (imageUrl == null || imageUrl.trim().isEmpty() || imageUrl.equals(existingUrl)) { |
|
|
return; |
|
|
return; |
|
|
@ -959,6 +1091,7 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
vo.setAvatarUrl(profile.getAvatarUrl()); |
|
|
vo.setAvatarUrl(profile.getAvatarUrl()); |
|
|
vo.setGender(profile.getGender()); |
|
|
vo.setGender(profile.getGender()); |
|
|
vo.setIntro(profile.getIntro()); |
|
|
vo.setIntro(profile.getIntro()); |
|
|
|
|
|
vo.setCompanionIntent(profile.getCompanionIntent()); |
|
|
vo.setInterestTags(jsonToTags(profile.getInterestTags())); |
|
|
vo.setInterestTags(jsonToTags(profile.getInterestTags())); |
|
|
vo.setPersonaImages(jsonToTags(profile.getPersonaImages())); |
|
|
vo.setPersonaImages(jsonToTags(profile.getPersonaImages())); |
|
|
vo.setCurrentMode(profile.getCurrentMode()); |
|
|
vo.setCurrentMode(profile.getCurrentMode()); |
|
|
@ -1031,6 +1164,14 @@ public class IeMatchServiceImpl implements IeMatchService { |
|
|
return "school"; |
|
|
return "school"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String normalizeFuzzyKeyword(String value) { |
|
|
|
|
|
if (!hasText(value)) { |
|
|
|
|
|
return ""; |
|
|
|
|
|
} |
|
|
|
|
|
String keyword = value.trim(); |
|
|
|
|
|
return keyword.length() > 24 ? keyword.substring(0, 24) : keyword; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private boolean hasText(String value) { |
|
|
private boolean hasText(String value) { |
|
|
return value != null && !value.trim().isEmpty(); |
|
|
return value != null && !value.trim().isEmpty(); |
|
|
} |
|
|
} |
|
|
|