package com.ding.control;
import com.ding.api.ResponseDate;
import com.ding.pojo.Book;
import com.ding.service.BookService;
import com.ding.vo.BookVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.log4j.Log4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.URLDecoder;
import java.net.UnknownHostException;
import java.util.List;
/**
* @author ding
* @createTime 2022-04-04 15:22
*/
@RestController
@Log4j
public class BookControl {
@Autowired
private BookService bookService;
@Autowired
private HttpServletRequest req;
//查询所有图书
@RequestMapping("/queryAll")
public PageInfo<Book> queryAll(@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "8") Integer pageSize){
String path = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
System.out.println("+===========================");
System.out.println("+===========================");
System.out.println(path);
System.out.println("+===========================");
System.out.println("+===========================");
System.out.println("+===========================");
//1.设置页面书籍
PageHelper.startPage(pageNo,pageSize);
//2.获取分页数据
List<Book> books = bookService.queryAll();
//3.传如参数得到返回值
PageInfo<Book> pageInfo = new PageInfo<>(books);
return pageInfo;
}
//按照类型查询图书,分页查询
@RequestMapping("/queryBookByType")
public PageInfo<Book> queryBookByType(@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize, Integer type){
//1.设置页面数据
PageHelper.startPage(pageNo,pageSize);
//2.获取分页数据
List<Book> books = bookService.queryBookByType(type);
//3.传参得到返回值
PageInfo<Book> pageInfo = new PageInfo<>(books);
return pageInfo;
}
//查询8本图书信息
@RequestMapping("/queryAllBook")
public List<Book> queryAllBook(){
List<Book> list = bookService.queryAllBook();
return list;
}
//查询4本图书信息,用于相关图书
@RequestMapping("/queryFourBook")
public List<Book> queryFourBook(Integer type){
return bookService.queryFourBook(type);
}
//查询5本图书,按照销量倒叙排序
@RequestMapping("/queryBookOrderByCount")
public List<Book> queryBookOrderByCount(Integer type){
return bookService.queryBookOrderByCount(type);
}
//查询一本图书信息
@RequestMapping("/queryBookById")
public Book queryBookById(Integer id){
Book book = bookService.queryBookById(id);
return book;
}
//按照 书名/作者名/出版社查询图书信息
@RequestMapping("/queryBookByCondition")
protected PageInfo<Book> queryBookByCondition(String type,@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,HttpSession session){
String c = null;
try {
//使用URLDecoder.decode解码,因为前端页面会乱码
c = URLDecoder.decode(type,"utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String content = "%" + c + "%";
//1.设置页面数据
PageHelper.startPage(pageNo,pageSize);
//2.获取分页数据
List<Book> books = bookService.queryBookByCondition(content);
//3.传参得到返回值
PageInfo<Book> pageInfo = new PageInfo<>(books);
//4.将内容存入session域中,因为现在只学到了这一个方法,所以只能这样做了先
session.setAttribute("books",pageInfo);
return pageInfo;
}
//修改图书信息
@RequestMapping("/admin/updateBook")
protected Integer updateBook(Book book){
System.out.println("*****************");
System.out.println("*****************");
System.out.println("*****************");
System.out.println(book);
return bookService.updateBook(book);
}
//删除图书信息
@RequestMapping("/admin/deleteBook")
protected Integer deleteBook(@RequestParam(name = "id") Integer id){
System.out.println(id);
return bookService.deleteBook(id);
}
//添加图书信息
@RequestMapping("/admin/addBook")
protected String addBook(BookVO book, HttpSession session){
MultipartFile upfile = book.getUpfile();
//HttpSession对象用来获取绝对路径,得到upload文件夹的绝对路径,比如 E:/upload/
String realPath = session.getServletContext().getRealPath("static/img/");
String imgPath = null;
String img_path = "http://localhost:8088/static/img/";
//判断是什么类型
if(book.getType().equals("1")){ //科技
imgPath = realPath + "science\\";
img_path = img_path + "science/";
}else if(book.getType().equals("2")){
imgPath = realPath + "literature\\";
img_path = img_path + "literature/";
}else if(book.getType().equals("3")){
imgPath = realPath + "humanity\\";
img_path = img_path + "humanity/";
}
else if(book.getType().equals("4")){
imgPath = realPath + "life\\";
img_path = img_path + "life/";
}
else if(book.getType().equals("5")){
imgPath = realPath + "child\\";
img_path = img_path + "child/";
}else if(book.getType().equals("6")){
imgPath = realPath + "fiction\\";
img_path = img_path + "fiction/";
}
System.out.println("创建的文件夹路径: " + imgPath);
//生成该对象
File dir = new File(imgPath);
//不存在就创建
if(!dir.exists()){
dir.mkdir();
}
//得到客户端上传的原始文件名
String oriFilename = upfile.getOriginalFilename();
//文件存放在服务端的绝对路径加文件名
String saveFileName = imgPath + oriFilename;
System.out.println("文件名为: " + oriFilename);
System.out.println("上传的文件保存在: " + saveFileName);
//将得到的地址存在book对象中
book.setImgPath(img_path + oriFilename);
File saveFile = new File(saveFileName);
try {
//把客户端上传的文件对象转换为本地文件对象
upfile.transferTo(saveFile);
} catch (IOException e) {
e.printStackTrace();
}
Integer count = bookService.addBook(book);
if(count == 1){
return "添加成功!";
}else{
return "出错了。。。";
}
}
/**
* 管理员后台查询图书
*/
//添加图书信息
@RequestMapping("/admin/searchBook")
protected ResponseDate<PageInfo<Book>> searchBook(@RequestParam(defaultValue = "1") Integer pageNo,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(name = "context") String context){
ResponseDate<PageInfo<Book>> resp = new ResponseDate<>();
String c = null;
try {
没有合适的资源?快使用搜索试试~ 我知道了~
基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共627个文件
jpg:144个
xml:125个
css:66个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip已获导师指导并通过的高分项目。下载即可使用,无需修改。 本项目是一套基于springboot+vue的网上书城项目,主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的Java学习者。包含:项目源码、项目文档、数据库脚本、软件工具等,该项目附带全部源码可作为毕设使用。项目都经过严格调试,确保可以运行! 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值 二、技术实现 springboot框架,mysql, 前端采用vue框架开发 基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip基于springboot+vue的网上书城项目源码+数据库(毕业设计).zip基于springboot+vue的网上书城项目源码+数据库(毕
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 627 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- icy3162023-04-16数据库有问题,还开启了私信免打扰,想问都问不了。
- zextreme2023-04-11资源内容总结地很全面,值得借鉴,对我来说很有用,解决了我的燃眉之急。
- weixin_516843022023-03-26非常有用的资源,有一定的参考价值,受益匪浅,值得下载。
- 我不是燕七2023-04-25资源内容总结地很全面,值得借鉴,对我来说很有用,解决了我的燃眉之急。
![avatar](https://profile-avatar.csdnimg.cn/6f999e5eff2040dc8aaf911dc17b4077_weixin_55305220.jpg!1)
程序员张小妍
- 粉丝: 1w+
- 资源: 3134
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)