(免费分享)基于springboot,vue在线小说系统

这篇具有很好参考价值的文章主要介绍了(免费分享)基于springboot,vue在线小说系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

本系统功能包括: 普通用户端登录注册,小说的分类,日榜,月榜,年榜, 小说的阅读,分章节,小说的评论,收藏,推荐等等,以 及后台小说的维护,上架,编辑等等。

项目技术: Springboot + Maven + Mybatis + Vue + Redis
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端
(免费分享)基于springboot,vue在线小说系统,免费毕设,spring boot,vue.js,后端

package com.homework.web.controller;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Date;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.homework.exception.ControllerException;
import com.homework.web.pojo.Chapter;
import com.homework.web.service.ChapterService;
import com.homework.web.util.ResponseObject;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/api/chapter")
@Api(tags = "共同前缀:/api/chapter", description = "ChapterController")
@Slf4j
public class ChapterController {

	@Autowired
	ChapterService chapterService;

	@PostMapping
	@ApiOperation("新增Chapter")
	@PreAuthorize("isAuthenticated()")
	public ResponseObject post(@RequestBody HashMap<String, String> data) {
		log.info("新增Chapter");
		if (data.get("title") == null || data.get("title").equals("")) {
			throw new ControllerException("volume_id不可为null");
		} else if (data.get("volume_id") == null || data.get("volume_id").equals("")) {
			throw new ControllerException("title不可为null,也不可为空字符串");
		} else if (data.get("chapterContent") == null || data.get("chapterContent").equals("")) {
			throw new ControllerException("chapterContent不可为null,也不可为空字符串");
		} else {
			try {
				// 文件夹
				File directory = new File(ResourceUtils.getURL("src").getPath() + "main/resources/static/txt/");
				if (!directory.exists()) {
					directory.mkdirs();
				}
				// 文件
				String content = new Date().getTime() + ".txt";
				File file2 = new File(directory, content);
				if (!file2.exists()) {
					file2.createNewFile();
				}
				// 往文件内写内容
				FileWriter fileWriter = new FileWriter(file2);
				fileWriter.write(data.get("chapterContent"));
				fileWriter.flush();
				fileWriter.close();
				Chapter chapter = new Chapter();
				chapter.setTitle(data.get("title"));
				chapter.setVolume_id(Integer.parseInt(data.get("volume_id")));
				chapter.setContent(content);
				return new ResponseObject("200", "操作成功", chapterService.insert(chapter));
			} catch (Exception e) {
				throw new ControllerException("操作失败");
			}
		}
	}

	@GetMapping
	@ApiOperation("查询Chapter")
	public ResponseObject get(Integer volume_id) {
		log.info("查询Chapter");
		if (volume_id == null) {
			throw new ControllerException("volume_id不可为null");
		} else {
			return new ResponseObject("200", "操作成功", chapterService.selectByVolume_id(volume_id));
		}
	}

	@GetMapping("/{id:[0-9]+}/last")
	@ApiOperation("查询上一章的Chapter")
	public ResponseObject getLast(@PathVariable Integer id) {
		log.info("查询上一章的Chapter");
		if (id == null) {
			throw new ControllerException("id不可为null");
		} else {
			Chapter chapter = chapterService.selectById(id);
			if (chapter == null) {
				throw new ControllerException("该id无法查找到chapter");
			} else {
				return new ResponseObject("200", "操作成功",
						chapterService.selectLastByVolume_idId(chapter.getVolume_id(), chapter.getId()));
			}
		}
	}

	@GetMapping("/{id:[0-9]+}/next")
	@ApiOperation("查询下一章的Chapter")
	public ResponseObject getNext(@PathVariable Integer id) {
		log.info("查询下一章的Chapter");
		if (id == null) {
			throw new ControllerException("id不可为null");
		} else {
			Chapter chapter = chapterService.selectById(id);
			if (chapter == null) {
				throw new ControllerException("该id无法查找到chapter");
			} else {
				return new ResponseObject("200", "操作成功",
						chapterService.selectNextByVolume_idId(chapter.getVolume_id(), chapter.getId()));
			}
		}
	}

	@GetMapping("/{id:[0-9]+}")
	@ApiOperation("查询Chapter")
	public ResponseObject getById(@PathVariable Integer id) {
		log.info("查询Chapter");
		if (id == null) {
			throw new ControllerException("id不可为null");
		} else {
			return new ResponseObject("200", "操作成功", chapterService.selectById(id));
		}
	}

	@GetMapping("/content")
	@ApiOperation("查询Chapter的content")
	public ResponseObject getContent(String content) {
		log.info("查询Chapter的content");
		if (content == null || content.equals("")) {
			throw new ControllerException("content不可为null,也不可为空字符串");
		} else {
			try {
				StringBuilder stringBuilder = new StringBuilder();
				File file = new File(new File(ResourceUtils.getURL("src").getPath() + "main/resources/static/txt/"),
						content);
				FileReader fileReader = new FileReader(file);
				char[] charArray = new char[1024];
				int length = 0;
				while ((length = fileReader.read(charArray)) != -1) {
					stringBuilder.append(new String(charArray, 0, length));
				}
				fileReader.close();
				return new ResponseObject("200", "操作成功", stringBuilder.toString());
			} catch (Exception e) {
				throw new ControllerException("找不到该章节的内容");
			}
		}
	}

	@PatchMapping("/content")
	@ApiOperation("修改Chapter的content")
	@PreAuthorize("isAuthenticated()")
	public ResponseObject patchContent(String content, @RequestBody HashMap<String, String> data) {
		log.info("修改Chapter的content");
		if (content == null || content.equals("")) {
			throw new ControllerException("content不可为null,也不可为空字符串");
		} else if (data.get("chapterContent") == null || data.get("chapterContent").equals("")) {
			throw new ControllerException("chapterContent不可为null,也不可为空字符串");
		} else {
			try {
				File file = new File(new File(ResourceUtils.getURL("src").getPath() + "main/resources/static/txt/"),
						content);
				FileWriter fileWriter = new FileWriter(file);
				fileWriter.write(data.get("chapterContent"));
				fileWriter.flush();
				fileWriter.close();
				return new ResponseObject("200", "操作成功", data.get("chapterContent"));
			} catch (Exception e) {
				throw new ControllerException("找不到该章节的内容");
			}
		}
	}

}

获取完整源码:
大家点赞、收藏、关注、评论啦 、查看 👇🏻 👇🏻 👇🏻微信公众号获取联系 👇🏻 👇🏻 👇🏻
免费领取下载链接-公众号输入口令:048文章来源地址https://www.toymoban.com/news/detail-520296.html

到了这里,关于(免费分享)基于springboot,vue在线小说系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 毕设成品 在线免费小说微信小程序的设计与实现(源码+论文)

    在线免费小说微信小程序的设计与实现 提示:适合用于课程设计或毕业设计,工作量达标,源码开放 微书的产品的定位即是为了满足用户无需下载,免费阅读的需求。适应的用户群体主要是城市上班族,在闲暇时光能借助微书不付费地读到自己喜欢的一些书籍,微信小程序

    2024年04月28日
    浏览(30)
  • 分享一个基于springboot+vue的在线租房与招聘平台系统代码 房屋租赁系统

    💕💕 作者:计算机源码社 💕💕 个人简介:本人七年开发经验,擅长Java、Python、PHP、.NET、微信小程序、爬虫、大数据等,大家有这一块的问题可以一起交流! 💕💕 学习资料、程序开发、技术解答、文档报告 💕💕Java项目 💕💕微信小程序项目 💕💕Python项目 💕💕A

    2024年02月09日
    浏览(31)
  • vue.js毕业设计,基于vue.js前后端分离在线小说电子书阅读小程序系统 开题报告

      毕业论文 基于Vue.js电子书阅读小程序系统 开题报告 学    院:                        专    业:                          年    级:                         学生姓名:                        指导教师:       黄菊华  

    2024年02月07日
    浏览(31)
  • vue.js毕业设计,基于vue.js前后端分离在线小说电子书阅读小程序系统设计与实现

    用户首次登陆系统需要注册一个用户作为账号,用户在登录平台后,可以进行平台的操作。主要模块包括以下几点: 登录功能:注册普通账号登录;登录后可以修改用户的基本信息,也可以退出。 资讯功能:后台录入资讯,在微信小程序在线电子书阅读系统的资讯模板展示

    2024年02月07日
    浏览(41)
  • 基于Java(SpringBoot框架)毕业设计作品成品(10)网络网上web在线阅读小说电子书系统设计与实现

    博主介绍 :《Vue.js入门与商城开发实战》《微信小程序商城开发》图书作者,CSDN博客专家,在线教育专家,CSDN钻石讲师;专注大学生毕业设计教育和辅导。 所有项目都配有从入门到精通的基础知识视频课程,免费 项目配有对应开发文档、开题报告、任务书、PPT、论文模版

    2024年02月07日
    浏览(41)
  • 毕业设计 微信小程序在线免费小说系统(源码+论文)

    在线免费小说微信小程序的设计与实现 提示:适合用于课程设计或毕业设计,工作量达标,源码开放 微书的产品的定位即是为了满足用户无需下载,免费阅读的需求。适应的用户群体主要是城市上班族,在闲暇时光能借助微书不付费地读到自己喜欢的一些书籍,微信小程序

    2024年02月16日
    浏览(34)
  • 基于SpringBoot+Vue的毕业设计与实现——Java毕设思路分享

    毕设选题经验分享:很多互联网专业的小伙伴们在选择自己的毕设主题的时候不知道做什么,在这时候就可以结合生活日常和当下较为流行的事物,通过对往年毕设的项目进行总结归纳,主题基本上都离不开旅游管理、移动办公、民宿服务系统、商城、博客、在线课程网站等

    2024年02月02日
    浏览(61)
  • 毕设分享springBoot+vue 网上购物商城系统(含源码+论文)

    Hi,各位同学好呀,这里是M学姐! 今天向大家分享一个今年(2022)最新完成的毕业设计项目作品,【基于SSM的网上购物商城】 学姐根据实现的难度和等级对项目进行评分(最低0分,满分5分) 难度系数:3分 工作量:5分 创新点:3分 界面美化:5分 界面美化的补充说明:使用vue的

    2024年02月11日
    浏览(36)
  • 基于SpringBoot的无忌在线考试系统(源码+讲解+调试运行)做毕设课设均可

    【毕设者】基于SpringBoot的无忌在线考试系统(源码+讲解+帮你调试运行)做毕设课设均可  前后端分离 前端使用 : Vue+ Element Plus 后端使用 : SpringBoot + Mysql8.0 +Mybatis-Plus 分为 管理员端 和 老师端 和 学生端 管理员端 登陆页 ​科目管理 查看所有科目 ,增加 ,修改 ,删除科目 , 模糊

    2024年02月09日
    浏览(29)
  • 基于SpringBoot和MySQL实现的在线小说平台

    制作小说阅读网可以给作者和读者提供一个相互交流的平台,作者将自己满 意的作品发布到这个平台让更多的人看到它们,而读者可以在这个平台寻找自己 感兴趣的作品并发布自己对作品的评论,作者能及时根据读者的评论来修改自己 的作品内容、调解创作思路。 这个平台

    2024年03月17日
    浏览(44)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包