伙伴匹配系统踩坑日记2
伙伴匹配系统踩坑日记2
Time:2024.8.2
后端构建
复制一份之前的用户中心后端项目,改名,删去原来的.idea和.mvn,重启idea会提示 maven重构
往后写发现不需要用新的项目,直接在原来的用户中心里加功能就行
新建标签表
create table tag
(
id bigint auto_increment comment 'id'
primary key,
tagName varchar(256) null comment '标签',
userId bigint null comment '用户 id',
parentId bigint null comment '父标签id',
isParent tinyint null comment '0 -不是父标签,1 -是父标签',
createTime timestamp default CURRENT_TIMESTAMP null comment '创建时间',
updateTime timestamp default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP comment '更新时间',
isDelete tinyint default 0 not null comment '是否删除',
constraint uniIdx_tagName
unique (tagName)
)
comment '标签';
create index idx_userId
on tag (userId);
编写根据标签查询用户函数
@Override
public List<User> searchUsersByTags(List<String> tagNameList){
if(CollectionUtils.isEmpty(tagNameList)){
throw new BusinessException(ErrorCode.PARAMS_ERROR);
}
QueryWrapper<User> queryWrapper =new QueryWrapper<>();
for(String tagName:tagNameList){
queryWrapper=queryWrapper.like("tags",tagName);
}
List<User> userList=userMapper.selectList(queryWrapper);
return userList.stream().map(this::getSafetyUser).collect(Collectors.toList());
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具