SpringBoot+Vue古建筑文化宣传交流系统 附带详细运行指导视频

文章目录

一、项目演示

项目演示地址: 视频地址

二、项目介绍

项目描述:这是一个基于SpringBoot+Vue框架 开发的古建筑文化宣传交流系统。首先,这是一个前后端分离的项目,代码简洁规范,注释说明详细,易于理解和学习。其次,这项目功能丰富,具有一个古建筑文化宣传交流系统该有的所有功能。

项目功能:此项目分为两个 角色:普通用户管理员普通用户 有登录注册、浏览古建筑信息、点赞收藏和评论古建筑、发布动态、查看动态、点赞收藏和评论动态、查看公告信息、修改个人信息、管理个人收藏点赞的古建筑信息、管理个人收藏点赞的动态信息等等功能。管理员有登录、查看数据统计信息、管理所有用户信息、管理所有话题信息、管理所有评论信息、管理所有古建筑信息、管理所有帖子信息、管理所有公告信息等等功能。

应用技术:SpringBoot + Vue3.0 + MySQL + MyBatis + Redis + ElementUI-Plus + Vite

运行环境:IntelliJ IDEA2019.3.5 + MySQL5.7 + Redis5.0.5 + JDK1.8 + Maven3.6.3 + Node14.16.1 + Visual Studio Code(以上工具在项目压缩包中都自带)

三、运行截图

























四、主要代码

1.保存古建筑信息

java 复制代码
    /**
     * 保存古建筑信息
     * @param buildingDTO
     * @return
     */
    @Override
    public ResponseDTO<Boolean> saveBuilding(BuildingDTO buildingDTO) {
        // 进行统一表单验证
        CodeMsg validate = ValidateEntityUtil.validate(buildingDTO);
        if (!validate.getCode().equals(CodeMsg.SUCCESS.getCode())) {
            return ResponseDTO.errorByMsg(validate);
        }
        Building building = CopyUtil.copy(buildingDTO, Building.class);
        if(CommonUtil.isEmpty(building.getId())) {
            // 添加操作
            building.setId(UuidUtil.getShortUuid());
            batchInsertPicture(buildingDTO.getPhotoList(), building.getId());
            if(buildingMapper.insertSelective(building) == 0) {
                return ResponseDTO.errorByMsg(CodeMsg.BUILDING_ADD_ERROR);
            }
        } else {
            // 修改操作
            PictureExample pictureExample = new PictureExample();
            pictureExample.createCriteria().andRefIdEqualTo(buildingDTO.getId());
            pictureMapper.deleteByExample(pictureExample);
            batchInsertPicture(buildingDTO.getPhotoList(), buildingDTO.getId());
            if(buildingMapper.updateByPrimaryKeySelective(building) == 0) {
                return ResponseDTO.errorByMsg(CodeMsg.BUILDING_EDIT_ERROR);
            }
        }
        return ResponseDTO.successByMsg(true, "保存成功!");
    }

2.用户登录

java 复制代码
    /**
     * 前台用户登录操作
     * @param userDTO
     * @return
     */
    @Override
    public ResponseDTO<UserDTO> homeLogin(UserDTO userDTO) {
        // 进行是否为空判断
        if(CommonUtil.isEmpty(userDTO.getPhone())){
            return ResponseDTO.errorByMsg(CodeMsg.PHONE_EMPTY);
        }
        if(CommonUtil.isEmpty(userDTO.getPassword())){
            return ResponseDTO.errorByMsg(CodeMsg.PASSWORD_EMPTY);
        }
        // 对比昵称和密码是否正确
        UserExample userExample = new UserExample();
        userExample.createCriteria()
                .andPhoneEqualTo(userDTO.getPhone())
                .andPasswordEqualTo(userDTO.getPassword());
        List<User> userList = userMapper.selectByExample(userExample);
        if(userList == null || userList.size() != 1){
            return ResponseDTO.errorByMsg(CodeMsg.PHONE_PASSWORD_ERROR);
        }
        // 生成登录token并存入Redis中
        UserDTO selectedUserDTO = CopyUtil.copy(userList.get(0), UserDTO.class);
        String token = UuidUtil.getShortUuid();
        selectedUserDTO.setToken(token);
        //把token存入redis中 有效期1小时
        stringRedisTemplate.opsForValue().set("USER_" + token, JSON.toJSONString(selectedUserDTO), 3600, TimeUnit.SECONDS);
        return ResponseDTO.successByMsg(selectedUserDTO, "登录成功!");
    }

3.查询帖子信息

java 复制代码
    /**
     * 获取帖子数据
     * @param postDTO
     * @return
     */
    @Override
    public ResponseDTO<List<PostDTO>> getPostList(PostDTO postDTO) {
        PostExample postExample = new PostExample();
        PostExample.Criteria criteria = postExample.createCriteria();
        if(!CommonUtil.isEmpty(postDTO.getUserId())) {
            criteria.andUserIdEqualTo(postDTO.getUserId());
        }
        if(!CommonUtil.isEmpty(postDTO.getId())) {
            criteria.andIdEqualTo(postDTO.getId());
        }
        if(!CommonUtil.isEmpty(postDTO.getTopicId())) {
           TopicItemExample topicItemExample = new TopicItemExample();
           topicItemExample.createCriteria().andTopicIdEqualTo(postDTO.getTopicId());
           List<String> postIdList = topicItemMapper.selectByExample(topicItemExample).stream().map(TopicItem::getPostId).collect(Collectors.toList());
           if(postIdList.size() > 0) {
               criteria.andIdIn(postIdList);
           } else {
               criteria.andIdEqualTo("-");
           }
        }
        if(postDTO.getIdList() != null ) {
            if(postDTO.getIdList().size() > 0) {
                criteria.andIdIn(postDTO.getIdList());
            } else {
                criteria.andIdEqualTo("-");
            }
        }
        postExample.setOrderByClause("create_time desc");
        List<Post> postList = postMapper.selectByExample(postExample);
        // 将domain类型数据  转成 DTO类型数据
        List<PostDTO> postDTOList = CopyUtil.copyList(postList, PostDTO.class);
        for(PostDTO post : postDTOList) {
            // 获取关联图集信息
            PictureExample pictureExample = new PictureExample();
            pictureExample.createCriteria().andRefIdEqualTo(post.getId());
            pictureExample.setOrderByClause("sort asc, id asc");
            List<Picture> pictureList = pictureMapper.selectByExample(pictureExample);
            List<String> photoList = pictureList.stream().map(Picture::getPhoto).collect(Collectors.toList());
            post.setPhotoList(photoList);
            // 获取关联话题数据
            TopicItemExample topicItemExample = new TopicItemExample();
            topicItemExample.createCriteria().andPostIdEqualTo(post.getId());
            List<String> topicIdList = topicItemMapper.selectByExample(topicItemExample).stream().map(TopicItem::getTopicId).collect(Collectors.toList());
            if(topicIdList.size() > 0) {
                TopicExample topicExample = new TopicExample();
                topicExample.createCriteria().andIdIn(topicIdList);
                List<Topic> topicList = topicMapper.selectByExample(topicExample);
                post.setTopicDTOList(CopyUtil.copyList(topicList, TopicDTO.class));
            }
            // 获取帖子关联用户信息
            User user = userMapper.selectByPrimaryKey(post.getUserId());
            post.setUserDTO(CopyUtil.copy(Optional.ofNullable(user).orElse(new User()), UserDTO.class));
            // 判断用户是否收藏和点赞
            if(!CommonUtil.isEmpty(postDTO.getToken())) {
                ResponseDTO<UserDTO> loginUser = userService.getLoginUser(postDTO.getToken());
                if(loginUser.getCode() == 0) {
                    UserDTO userDTO = loginUser.getData();
                    CollectExample collectExample = new CollectExample();
                    collectExample.createCriteria().andUserIdEqualTo(userDTO.getId()).andRefIdEqualTo(post.getId());
                    post.setCollect(collectMapper.countByExample(collectExample) != 0);
                    LikeExample likeExample = new LikeExample();
                    likeExample.createCriteria().andUserIdEqualTo(userDTO.getId()).andRefIdEqualTo(post.getId());
                    post.setLike(likeMapper.countByExample(likeExample) != 0);
                }
            }
        }
        return ResponseDTO.success(postDTOList);
    }
相关推荐
Hi_kenyon1 小时前
Ref和Reactive都是什么时候使用?
前端·javascript·vue.js
小王不爱笑1321 小时前
SpringBoot 整合 Ollama + 本地 DeepSeek 模型
java·spring boot·后端
人道领域2 小时前
SSM框架从入门到入土(SpringFrameWork)
java·spring boot·tomcat
键盘帽子2 小时前
多线程情况下长连接中的session并发问题
java·开发语言·spring boot·spring·spring cloud
zhougl9963 小时前
Vue 中使用 WebSocket
前端·vue.js·websocket
半梅芒果干3 小时前
vue3 实现无缝循环滚动
前端·javascript·vue.js
雯0609~4 小时前
hiprint-官网vue完整版本+实现客户端配置+可实现直接打印(在html版本增加了条形码、二维码拖拽等)
前端·javascript·vue.js
tb_first4 小时前
万字超详细苍穹外卖学习笔记5
java·数据库·spring boot·笔记·学习·spring
Hx_Ma164 小时前
SpringBoot消息转换器扩展fastjson
java·spring boot·spring
Coder_preston4 小时前
Spring/Spring Boot实战:从入门到项目部署
java·spring boot·spring