Java项目:学生读书笔记共享(java+SpringBoot+Mybaits+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


使用说明

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

注意项目文件路径中不能含有中文、空格、特殊字符等,否则图片会上传不成功。

 文档结构展示:

 个人中心展示页面:

 笔记分享:

 公告信息展示页面:

登录展示页面:

交流互动展示页面:

后台登录入口:

 后台交流互动管理展示页面:

 首页展示页面:

 后台用户管理页面:

用户管理控制层:

@Controller
@RequestMapping("UsersServlet")
public class UsersController {
    private UsersDao usersDao = new UsersDao();

    @Autowired
    private HttpServletRequest request;


    @RequestMapping("/loginadmin")
    public String loginadmin() {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        Users users = usersDao.login(username, password);

        if (users != null) {
            request.getSession().setAttribute("loginUsers", users);
            return "admin_index";

        } else {
            request.setAttribute("msg", "登录失败,账号密码不匹配");
            return "admin_login";

        }

    }

    @RequestMapping("/userlogin")
    public String userlogin() {
        String userName = request.getParameter("username");
        String password = request.getParameter("password");
        String clientCheckcode = request.getParameter("validateCode");
        String serverCheckcode = (String) request.getSession().getAttribute("checkcode");
        if (clientCheckcode.equals(serverCheckcode)) {
            // 2. 去访问dao , 看看是否满足登录。

            Users Users = usersDao.userlogin(userName, password);

            // 3. 针对dao的返回结果,做出响应
            if (Users != null) {


                request.getSession().setAttribute("usersLogin", Users);
                CategoryDao categoryDao = new CategoryDao();
                List<Category> categoryList = categoryDao.queryAll();
                request.setAttribute("categoryList", categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));
                return "index";


            } else {
                request.setAttribute("error", "用户名或密码错误!");
                return "login";


            }
        } else {
            request.setAttribute("error", "登录失败,验证码不正确!");
            return "login";

        }
    }

    @RequestMapping("/userreg")
    public String userreg() {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String account = request.getParameter("account");
        String email = request.getParameter("email");
        String password2 = request.getParameter("password2");
        if (!password.equals(password2)) {
            request.setAttribute("error", "注册失败,密码与确认密码不一致!");
            return "reg";
        } else {

            boolean isSuccess = usersDao.isReg(account);

            if (!isSuccess) {

                request.setAttribute("error", "注册失败,该用户名已存在!");
                return "reg";

            } else {
                usersDao.reg(username, account, password, email);
                request.setAttribute("error", "注册成功!");

                return "reg";
            }
        }

    }

    @RequestMapping("/listforadmin")
    public String listforadmin() {


            List<Users> list = usersDao.getUsers();
            request.setAttribute("list", list);
            return "listusers";

    }
    @RequestMapping("/del")
    public String del(Integer id) {

        usersDao.del(id);

        List<Users> list = usersDao.getUsers();
        request.setAttribute("list", list);
        return "listusers";

    }
}

新闻管理控制层: 

@Controller
@RequestMapping("NewsServlet")
public class NewsController {
    @Autowired
    private HttpServletRequest request;
    private NewsDao newsDao = new NewsDao();
    private CategoryDao categoryDao = new CategoryDao();
    private CommentsDao commentsDao = new CommentsDao();
    @RequestMapping("/publish")
    public String publish(){
        String title = request.getParameter("title");
        String content = request.getParameter("content");
        String categoryid = request.getParameter("categoryid");

        Users users = (Users) request.getSession().getAttribute("loginUsers");
        Integer usersId = users.getId();

        Integer deptid = users.getDeptid();

        News news = new News();
        news.setCategoryid(Integer.parseInt(categoryid));
        news.setClicks(0);
        news.setContent(content);
        news.setPbdate(new Date());
        news.setPbdeptid(deptid);
        news.setPublisher(usersId);
        news.setCategoryid(Integer.parseInt(categoryid));
        news.setTitle(title);
        newsDao.save(news);
        return "redirect:listforadmin";
    }


    @RequestMapping("/listforadmin")
    public String listforadmin(){
        List<News> newsList = newsDao.queryAll();
        request.setAttribute("list", newsList);
        return "listnews";
    }





    @RequestMapping("/toaddnews")
    public String toaddnews(){
        List<News> newsList = newsDao.queryAll();
        request.setAttribute("list", newsList);
        List<Category> categoryList = categoryDao.queryAll();
        request.setAttribute("categoryList", categoryList);
        return "addnews";
    }


    @RequestMapping("/edit")
    public String edit(){
        String title = request.getParameter("title");
        String content = request.getParameter("content");
        String categoryid = request.getParameter("categoryid");

        News news = new News();
        news.setCategoryid(Integer.parseInt(categoryid));
        news.setContent(content);
        news.setPbdate(new Date());
        news.setId(Integer.parseInt(request.getParameter("id")));

        news.setTitle(title);
        newsDao.edit(news);
        return "redirect:listforadmin";
    }



    @RequestMapping("/del")
    public String del(){
        newsDao.deleteById(Integer.parseInt(request.getParameter("id")));
        List<News> newsList = newsDao.queryAll();
        request.setAttribute("list", newsList);
        return "listnews";

    }


    @RequestMapping("/toeditnews")
    public String toeditnews(){
        News news = newsDao.queryByid(Integer.parseInt(request.getParameter("id")));
        request.setAttribute("v", news);
        List<Category> categoryList = categoryDao.queryAll();
        request.setAttribute("categoryList", categoryList);
        return "editnews";
    }


    @RequestMapping("/queryByType")
    public String queryByType(){
        String categoryid = request.getParameter("categoryid");

        List<News> newsList = newsDao.queryAll();
        request.setAttribute("list", newsList.stream()
                .filter(x -> x.getCategoryid().equals(Integer.parseInt(categoryid))).collect(Collectors.toList()));
        List<Category> categoryList = categoryDao.queryAll();
        request.setAttribute("categoryList",
                categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));

        return "typenews";
    }


    @RequestMapping("/detail")
    public String detail(){
        //测试
        String id =  request.getParameter("id");
        if(id.contains(".jsp"))
        {
           id= request.getParameter("id").replaceAll(".jsp","");

        }

        News news = newsDao.queryByid(Integer.parseInt(id));

        news.setClicks(news.getClicks() + 1);

        newsDao.setClicksIncrement(news);

        NewsDetail detail = new NewsDetail();
        detail.setNews(news);

        Category category = categoryDao.queryById(news.getCategoryid());

        detail.setCategory(category);

        String content = news.getContent();
        int length = content.length();

        length = length / 60;

        length = length * 27 + 10;

        request.setAttribute("length", length);

        request.setAttribute("v", detail);

        List<Category> categoryList = categoryDao.queryAll();

        List<Comments> commentsList = commentsDao.getByNewsId(news.getId());
        request.setAttribute("commentsList", commentsList);

        request.setAttribute("contentstr", content);

        request.setAttribute("categoryList",
                categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));

        return "detailnews";
    }

    @RequestMapping("/search")
    public String search(){
        String search = request.getParameter("search");

        request.setAttribute("searchStr", search);

        List<News> newsList = newsDao.queryAll();
        newsList=newsList.stream().filter(x -> x.getTitle().contains(search)).collect(Collectors.toList());

        newsList=	newsList.stream().map(x->{

            String title = x.getTitle();

            /*			String[] split = title.split(search);
             */
			/*if(split.length>=2){
				for(int i=0;i<split.length-1;i++){
			title=split[i]+"<font color='red'>"+search+"</font>"+split[i+1];

				}
			}else{
				title=split[0]+"<font color='red'>"+search+"</font>";
			}*/
            title=title.replace(search, "<font color='red'>"+search+"</font>");


            System.out.println(title);

            x.setTitle(title);

            return x;
        }).collect(Collectors.toList());

        request.setAttribute("list",newsList
        );
        List<Category> categoryList = categoryDao.queryAll();
        request.setAttribute("categoryList",
                categoryList.stream().filter(x -> x.getState().equals("1")).collect(Collectors.toList()));

        return "searchnews";
    }

}

公告管理控制层:

@Controller
@RequestMapping("CategoryServlet")
public class CategoryController {
    @Autowired
    private HttpServletRequest request;
    private CategoryDao categoryDao=new CategoryDao();

    @RequestMapping("/listforadmin")
    public String listforadmin(){
        List<Category> categoryList = categoryDao.queryAll();
        request.setAttribute("list", categoryList);
        return "listcategory";
    }
    @RequestMapping("/show")
    public String show(){
        List<Category> categoryList = categoryDao.queryAll();
        categoryList=categoryList.stream().filter(x->x.getState().equals("1")).collect(Collectors.toList());

        if(categoryList.size()>=5)
        {

            request.setAttribute("list", categoryDao.queryAll());
            request.setAttribute("msg","设置栏目显示失败,前台栏目最多显示5个");
            return "listcategory";
        }else {
            categoryDao.show(Integer.parseInt(request.getParameter("id")));
            return "redirect:listforadmin";
        }
    }
    @RequestMapping("/hidden")
    public String hidden(){

        categoryDao.hidden(Integer.parseInt(request.getParameter("id")));
        return "redirect:listforadmin";
    }
    @RequestMapping("/add")
    public String add(){
        String name=request.getParameter("name");
        String state=request.getParameter("state");
        Category category=new Category();
        category.setName(name);
        category.setState(state);
        categoryDao.save(category);
        return "redirect:listforadmin";
    }



}

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

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
您好!对于使用Spring Boot 2.x和MyBatis集成MySQL,并实现微信授权登录的问题,我可以给您一些指导。 首先,您可以按照以下步骤进行操作: 1. 配置MySQL数据库:在`application.properties`或`application.yml`文件中设置MySQL数据库的连接信息,包括数据库URL、用户名和密码等。 2. 引入依赖:在您的项目的`pom.xml`文件中添加Spring Boot、MyBatis和MySQL的相关依赖。例如: ```xml <dependencies> <!-- Spring Boot --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- MyBatis --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <!-- MySQL --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 其他依赖... --> </dependencies> ``` 3. 创建实体类和Mapper:创建与数据库表对应的实体类,并使用MyBatis的注解或XML配置文件来定义Mapper接口和SQL语句。 4. 配置MyBatis:在`application.properties`或`application.yml`文件中配置MyBatis相关的属性,如Mapper接口的扫描路径、XML配置文件的位置等。 5. 编写业务逻辑:根据您的需求,编写相应的业务逻辑代码,包括微信授权登录的逻辑处理。 6. 实现微信授权登录:使用微信开放平台提供的API,获取用户的授权信息,并将相关信息保存到数据库中。您可以使用第三方开源库(如unapp)来简化微信授权登录的过程。 需要注意的是,以上只是一个大致的步骤,具体实现还需根据您的项目需求进行调整。同时,为了保证代码的安全性和可靠性,建议您进行适当的异常处理、参数校验等。 希望以上内容对您有所帮助!如果您有任何疑问,请随时提问。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

qq1334611189

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

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

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

打赏作者

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

抵扣说明:

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

余额充值