伙伴匹配系统踩坑日记2

伙伴匹配系统踩坑日记2

Time:2024.8.2

后端构建

复制一份之前的用户中心后端项目,改名,删去原来的.idea和.mvn,重启idea会提示 maven重构

image-20240731173428787

往后写发现不需要用新的项目,直接在原来的用户中心里加功能就行

新建标签表

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());

    }
posted @   vast_joy  阅读(28)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示