伙伴匹配系统踩坑日记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());
}

浙公网安备 33010602011771号