Java项目:准妈妈孕期交流平台(java+SpringBoot+Mybatis+Vue+ELementUI+mysql)

源码获取:俺的博客首页 "资源" 里下载!

项目介绍

基于Springboot Vue准妈妈孕期交流平台

角色:管理员、用户两种种角色,分为前后台;

用户:用户通过用户登录页面可以填写用户名和密码等信息进行登录操作,用户登录成功后,进入首页可以查看早教知识、待产经验分享、怀孕常识、月子食谱、好物推荐、圈子交流、个人中心、专家交流等功能模块,进行相对应操作;

管理员:管理员登录进入准妈妈孕期交流平台可以查看首页、个人中心、用户管理、早教知识管理、待产经验分享管理、怀孕常识管理、月子食谱管理、好物推荐管理、好物类型管理、圈子交流、系统管理等信息。


环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7/8.0版本均可;
5.是否Maven项目:是;


技术栈

后端:SpringBoot+Mybaits

前端:Vue+ElementUI+Layui+HTML+CSS+JS


使用说明

项目运行:
1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4.运行项目,在浏览器中输入地址:
前台地址:http://localhost:8080/springboottof36/front/index.html
普通用户:用户1/123456
后台地址:http://localhost:8080/springboottof36/admin/dist/index.html#/login
管理员:abo/abo
普通用户:用户1/123456

系统结构图:

 首页展示:

 早教知识展示:

 

用户登录展示:

 

个人中心信息展示:

 后台管理专家交流:

用户信息管理:

后台个人中心展示:

好物推荐展示:

 

用户管理详情控制层:

@Controller
public class UserController {


    @Autowired
    private UserService userService;

    @RequestMapping("/userUi")
    public String userUI() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/user/userList";
    }

    @ResponseBody
    @RequestMapping("/admin/user/tableList")
    public ServerLayResult userList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                    @RequestParam(value = "limit", defaultValue = "10") Integer limit,
                                    @RequestParam(value = "keyword", defaultValue = "") String keyword) {
        if (keyword == null || keyword.equals("")) {
            //封装Json数据对象
            ServerLayResult result = new ServerLayResult(0, "", userService.count(), userService.selectAll(page, limit));
            return result;
        } else if (keyword != null) {
            ServerLayResult result = new ServerLayResult(0, "", userService.selectByUsername(keyword, page, limit).size(),
                    userService.selectByUsername(keyword, page, limit));
            return result;
        }
        return null;
    }

    @ResponseBody
    @RequestMapping("/admin/user/del")
    public Map<String, Object> del(@RequestParam("id") Integer id) {
        Map<String, Object> dataMap = new HashMap<>();
        Boolean isSuccess = false;
        if (id != null && id != 0) {
            int del = userService.deleteByPrimaryKey(id);
            if (del > 0) {
                isSuccess = true;
                dataMap.put("success", isSuccess);
                return dataMap;
            }
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }

    /**
     * 更新用户信息
     *
     * @param user
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/admin/user/update", method = RequestMethod.POST)
    public Map<String, Object> updateUser(@RequestBody User user) {
        Map<String, Object> dataMap = new HashMap<>();
        Boolean isSuccess = false;
        if (user != null) {
            //根据用户对象的id 查询用户的密码,防止密码丢失
            User user1 = userService.selectByPrimaryKey(user.getId());
            //再次封装进对象中
            if (user1 != null) {
                user.setPassword(user1.getPassword());
                //更新对象
                int update = userService.updateByPrimaryKey(user);
                if (update > 0) {
                    isSuccess = true;
                    dataMap.put("success", isSuccess);
                    return dataMap;
                }
            }
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }


    /**
     * 重置用户密码
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/user/resetPwd")
    public Map<String, Object> restPwd(@RequestParam("id") Integer id) {
        Map<String, Object> dataMap = new HashMap<>();
        Boolean isSuccess = false;
        if (id != null && id > 0) {
            //根据id查询出用户
            User user = userService.selectByPrimaryKey(id);
            //开始重置密码,重置密码使用的Spring提供的工具类进行对密码123456进行加密
            user.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
            //调用更新方法
            int restPwd = userService.updateByPrimaryKey(user);
            if (restPwd > 0) {
                isSuccess = true;
                dataMap.put("success", isSuccess);
                return dataMap;
            }
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }

}

后台文章管理控制层: 

@Controller
public class ArticleController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private ArticleService articleService;

    @Autowired
    private LabelService labelService;

    @RequestMapping("/articleUi")
    public String articleListUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/article/list";
    }

    @RequestMapping("/articleUiAdd")
    public String articleAddUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/article/listform";
    }

    /**
     * 后台文章列表
     *
     * @param page     当前页
     * @param limit    每页多少条
     * @param keyword1 关键字查询
     * @param keyword2
     * @param keyword3
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/article/list")
    public ServerLayResult<Article> list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                         @RequestParam(value = "limit", defaultValue = "10") Integer limit,
                                         String keyword1, String keyword2, String keyword3) {
        if (keyword1 != null && keyword2 != "" || keyword2 != null && keyword2 != "" || keyword3 != null && keyword3 != "") {
            List<Article> articles = articleService.selectByKeyWord(page, limit, keyword1, keyword2, keyword3);
            ServerLayResult result = new ServerLayResult(0, "", articles.size(), articles);
            return result;
        }
        //封装数据
        ServerLayResult result = new ServerLayResult(0, "", articleService.count(), articleService.selectAll(page, limit));
        return result;
    }


    /**
     * 根据ID删除
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/article/del")
    public Map<String, Object> delArticle(@RequestParam("id") int id) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = articleService.deleteByPrimaryKey(id);
        dataMap.put("success", isSuccess);
        return dataMap;
    }


    /**
     * 前台响应json数据
     * 解析保存
     *
     * @param article
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/article/add")
    public Map<String, Object> addArticle(@RequestBody JSONObject article) {
        JSONObject json = JSON.parseObject(article.toJSONString());
        String author = json.getString("author");
        Integer label = json.getInteger("label");
        String title = json.getString("title");
        String content = json.getString("content");
        String status = json.getString("status");
        int temp = 0;
        if (status != null) {
            if (status.equals("on")) {
                temp = 1;
            }
        }
        Label label1 = new Label();
        label1.setId(label);
        Article articles = new Article();
        articles.setAuthor(author);
        articles.setContent(content);
        articles.setTitle(title);
        articles.setStatus(temp);
        articles.setCreateTime(new Date());
        articles.setLabel(label1);
        logger.info(article + "");
        boolean isSuccess = articleService.insert(articles);
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("success", isSuccess);
        return dataMap;
    }

    /**
     * 根据前台响应的json对象封装后通过业务方法保存到数据库
     *
     * @param article
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/article/update")
    public Map<String, Object> updateArticle(@RequestBody JSONObject article) {
        JSONObject json = JSON.parseObject(article.toJSONString());
        String author = json.getString("author");
        Integer label = json.getInteger("label");
        Integer id = json.getInteger("id");
        String title = json.getString("title");
        String content = json.getString("content");
        String status = json.getString("status");
        int temp = 0;
        if (status != null) {
            if (status.equals("on")) {
                temp = 1;
            }
        }
        Label label1 = new Label();
        label1.setId(label);
        Article articles = new Article();
        articles.setId(id);
        articles.setAuthor(author);
        articles.setContent(content);
        articles.setTitle(title);
        articles.setStatus(temp);
        articles.setCreateTime(new Date());
        articles.setLabel(label1);
        logger.info(article + "");
        boolean isSuccess = articleService.updateByPrimaryKey(articles);
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("success", isSuccess);
        return dataMap;
    }

}


 后台留言详情控制器:

/**
 * 后台留言控制器
 */
@Controller
public class LeacotController {

    @Autowired
    private LeacotService leacotService;

    @Autowired
    private ReplyService replyService;


    @RequestMapping("/leacotsView")
    public String leacotUi() {
        if (!LoginSession.getCurrentUser().getUsername().equals("admin")) {
            return "client/html/index";
        }
        return "admin/leacots/leacotsList";
    }


    /**
     * 用户留言列表
     *
     * @param page
     * @param limit
     * @param keyword1
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/list")
    public ServerLayResult leacotsList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                       @RequestParam(value = "limit", defaultValue = "10") Integer limit, String keyword1) {
        if (keyword1 != null) {
            List<Leacot> leacots = leacotService.selectByKeyWord(page, limit, keyword1);
            ServerLayResult result = new ServerLayResult(0, "", leacots.size(), leacots);
            return result;
        }
        ServerLayResult result = new ServerLayResult(0, "", leacotService
                .count(), leacotService.selectAll(page, limit));
        return result;
    }

    /**
     * 根据ID删除 并且删除关联
     *
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/del")
    public Map<String, Object> del(@RequestParam("id") int id) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = false;
        Leacot leacot = leacotService.selectByPrimaryKey(id);
        //删除关联
        if (leacot != null) {
            boolean delReply = replyService.deleteByPrimaryKey(leacot.getId());
            if (delReply) {
                boolean delete = leacotService.deleteByPrimaryKey(id);
                isSuccess = true;
                dataMap.put("success", isSuccess);
                return dataMap;
            }
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }


    /**
     * {id: "4", leacotsUser: "test", content: "测试留言内容", replyContent: "fsafsf", status: "on"}
     *
     * @param json
     * @return
     */
    @ResponseBody
    @RequestMapping("/admin/leacots/update")
    public Map<String, Object> update(@RequestBody JSONObject json) {
        Map<String, Object> dataMap = new HashMap<>();
        boolean isSuccess = false;
        JSONObject data = JSON.parseObject(json.toJSONString());
        Integer id = data.getInteger("id");
        String leacotsUser = data.getString("leacotsUser");
        String content = data.getString("content");
        //回复内容
        String replyContent = data.getString("replyContent");
        //回复状态
        String status = data.getString("status");
        int temp = 0;
        if (status != null) {
            if (status.equals("on")) {
                temp = 1;
            }
        }
        //默认从session获得replyUser
        Reply reply = new Reply(id, replyContent, new Date(), "admin");
        //更新回复表
        boolean updateReply = replyService.updateByPrimaryKey(reply);
        Leacot leacot = new Leacot(id, content, new Date(), leacotsUser, reply, temp);
        //更新留言表
        boolean updateLeacot = leacotService.updateByPrimaryKey(leacot);
        if (updateLeacot && updateReply) {
            isSuccess = true;
            dataMap.put("success", isSuccess);
            return dataMap;
        }
        dataMap.put("success", isSuccess);
        return dataMap;
    }

}

源码获取:俺的博客首页 "资源" 里下载!

  • 21
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: Java是一种编程语言,Vue是一种前端框架,Spring Boot是一种后端框架,Maven是一种构建工具,MyBatis是一种ORM框架,MySQL是一种关系型数据库。这些技术可以一起使用来开发Web应用程序。 ### 回答2: JavaVueSpringBoot、Maven、MyBatisMySQL 是现代软件开发中常见的工具和技术。Java 是一门强大的编程语言,非常适合构建企业级应用程序。Vue 是一种现代的 JavaScript 框架,用于构建可交互的单页应用程序。SpringBoot 是一种基于 Spring 框架的服务端开发解决方案,可用于构建 RESTful Web 服务或基于微服务体系结构的应用程序。Maven 是一个构建工具,可用于自动化构建和管理软件项目的依赖项。MyBatis 是一个数据持久化框架,可以方便地将 Java 应用程序连接到各种关系型数据库中。MySQL 是一个流行的、开源的关系型数据库管理系统,是许多 Web 应用程序的默认选择。 在软件开发中,JavaVueSpringBoot、Maven、MyBatisMySQL 可以相互配合使用,以构建跨平台、云端部署、高效稳定的应用程序。JavaSpringBoot 可用于构建 Web 服务和 RESTful API,而 VueSpringBoot 可用于构建面向用户的 Web 应用程序。Maven 可用于管理项目依赖项和自动化构建过程,而 MyBatis 可以方便地将数据从数据库中提取并转换为对象。MySQL 可用于存储应用程序生成的数据。 总之,在软件开发中,选择适合您团队和项目需求的工具和技术非常重要。JavaVueSpringBoot、Maven、MyBatisMySQL 已经得到了广泛的应用和实践验证,并且可以帮助您轻松地构建高效、可靠和安全的应用程序。 ### 回答3: Java是一种面向对象的高级编程语言,被广泛使用于开发各种应用程序,从桌面应用程序到企业级应用程序。它具有强大的编程能力、跨平台兼容性和开源社区的支持。Java中有很多库、框架和工具,可以简化编程任务并提高应用程序的性能和稳定性。 Vue是一个流行的JavaScript前端框架,用于构建用户界面。它被设计为轻量级、高效和灵活,可以用来建立单页应用程序和大型复杂应用程序。Vue提供了许多有用的工具和组件,可以帮助开发人员快速建立优秀的用户界面。 Spring Boot是一个基于Spring框架的轻量级应用程序开发框架,目的是简化企业级应用程序的开发过程。Spring Boot具有自动配置、快速启动、简单的部署和许多其他特性,可以快速构建高性能应用程序。它还具有用于构建RESTful API和微服务的功能。 Maven是一个强大的项目管理和构建工具,用于构建Java应用程序。Maven可以帮助开发人员自动化项目构建过程,并可以帮助组织项目结构和管理库依赖。Maven具有许多插件和工具,可以帮助开发人员编译、测试和打包应用程序。 MyBatis是一个流行的Java持久层框架,用于简化与关系型数据库的交互。它使用SQL映射文件将Java对象映射到数据库表中,提供了一种简单而强大的方式来处理数据库操作。MyBatis还提供了许多有用的特性,如动态SQL、事务管理和缓存。 MySQL是一个开源的关系型数据库管理系统,被广泛使用于Web应用程序和企业级应用程序。MySQL具有可靠的性能、高度可扩展性和广泛的API支持,可以处理大型数据集和高并发访问。它还拥有丰富的特性和工具,支持多种编程语言和操作系统。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

beyondwild

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值