package com.nx.controller;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nx.model.*;
import com.nx.service.BookService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Controller
@RequestMapping("/book")
public class BookController {
@Autowired
@Qualifier("bookServiceImpl")
private BookService bookService;
/*@RequestMapping("/toMain")
public String toMain(Model model){
return "main";
}*/
@RequestMapping("/Main")
public String toMain(Model model,@RequestParam(value = "pageNo",defaultValue = "1") Integer pageNo,@RequestParam(value = "pageSize",defaultValue = "12")Integer pageSize){
List<Book> books = bookService.selectBook();
model.addAttribute("books",books);
/*PageInfo<Book> pageInfo = bookService.selectBook(pageNo,pageSize);*/
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategories",bookCategories);
/* model.addAttribute("books",pageInfo);*/
if(books.size()==0){
model.addAttribute("msg","暂无书籍");
return "main";
}
return "main";
/*session.setAttribute("username",u_name);
session.setAttribute("password",u_password1);*/
}
@RequestMapping("/toAdd")
public String toAdd(Model model){
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("addCategory",bookCategories);
return "addBook";
}
@RequestMapping("/Add")
public String Add(@RequestParam("bookPhoto") CommonsMultipartFile file, Book book, Model model, HttpServletRequest request) throws IOException, ParseException {
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategories",bookCategories);
//上传路径保存设置
//String path = request.getServletContext().getRealPath("/upload");
File realPath = new File(request.getServletContext().getRealPath("/images/book"));
if (!realPath.exists()){
realPath.mkdir();
}
//上传文件地址
System.out.println("上传文件保存地址:"+realPath);
System.out.println(request.getServletContext().getRealPath("/images/book"));
String upload=UUID.randomUUID()+file.getOriginalFilename();
//通过CommonsMultipartFile的方法直接写文件(注意这个时候)
file.transferTo(new File(realPath +"/"+upload));
book.setB_photo(upload);
System.out.println(book.getB_photo());
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date=simpleDateFormat.parse(simpleDateFormat.format(new Date()));
book.setB_createTime(date);
int insertBook = bookService.insertBook(book);
System.out.println(insertBook);
if(insertBook>0) {
List<Book> books = bookService.selectBook();
model.addAttribute("books", books);
return "redirect:/book/Main";
}
return "redirect:/book/toAdd";
}
@RequestMapping("/query")
public String Query(String b_name,Model model){
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategories",bookCategories);
List<Book> books=bookService.selectBookAmbiguous(b_name);
if(books.size()==0){
model.addAttribute("msg","暂无此书籍");
return "main";
}
model.addAttribute("books",books);
return "main";
}
@RequestMapping("/Category")
public String QueryByCategory(int c_id,Model model){
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategories",bookCategories);
List<Book> books=bookService.selectBookByCategory(c_id);
System.out.println(books);
if(books.size()==0){
model.addAttribute("msg","暂无此类书籍");
return "main";
}
model.addAttribute("books",books);
return "main";
}
@RequestMapping("/myQuery")
public String toQuery(String b_name,Model model,HttpSession session){
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategory",bookCategories);
List<Book> books=bookService.selectMyBookAmbiguous(b_name,(Integer) session.getAttribute("userId"));
if(books.size()==0){
model.addAttribute("msg","暂无此书籍");
return "myShop";
}
model.addAttribute("myBooks",books);
return "myShop";
}
@RequestMapping("/toMyShop")
public String toMyShop(){
return "myShop";
}
@RequestMapping("/myCategory")
public String QueryByMyCategory(Integer b_cid,Integer b_uid,Model model){
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategory",bookCategories);
List<Book> books=bookService.selectBookByUserIdCategory(b_uid,b_cid);
System.out.println(books);
if(books.size()==0){
model.addAttribute("msg","暂无此类书籍");
return "myShop";
}
model.addAttribute("myBooks",books);
return "myShop";
}
@RequestMapping("/MyShop")
public String MyShop(HttpSession session,Model model){
Integer userId = (Integer) session.getAttribute("userId");
List<BookCategory> bookCategories = bookService.selectBookCategory();
model.addAttribute("bookCategory",bookCategories);
List<Book> books=bookService.selectBookByUserId(userId);
System.out.println(books);
if(books.size()==0){
model.addAttribute("msg","暂无上架书籍");
return "myShop";
}
model.addAttribute("myBooks",books);
return "myShop";
}
@RequestMapping("/bookMessage")
public String toBookMessage(HttpSession session,Model model){
Integer bookMessageId = (Integer) session.getAttribute("bookMessageId");
String bookPossess = (String) session.getAttribute("bookPossess");
Book bookMessage= bookService.selectBookById(bookMessageId);
String bookCategoryName = bookService.selectBookCategoryById(bookMessage.getB_cid());
model.addAttribute("bookMessages",bookMessage);
model.addAttribute("bookUser",bookPossess);
model.addAttribute("bookCategoryName",bookCategoryName);
model.addAttribute("username",session.getAttribute("username"));
List<Comment> comments = bookService.selectBookCommentById(bookMessageId);
model.addAttribute("comments",comments);
return "bookMessage";
}
@RequestMapping("/MyBookMessage")
public String toMyBookMessage(Model model,HttpSession session){
Integer myBookMessageId = (Integer) session.getAttribute("myBookMessageId");
String bookMyPossess = (String) session.getAttribute("bookMyPossess");
B
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。 java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。java毕业设计基于ssm的二手书籍交易管理系统源码+数据库。已获高分通过的项目。
资源推荐
资源详情
资源评论
收起资源包目录
java毕业设计基于ssm的二手书籍交易管理系统源码+数据库.zip (220个子文件)
BookController.class 26KB
UserController.class 18KB
BookServiceImpl.class 8KB
Orders.class 5KB
WalletController.class 5KB
BookMapper.class 4KB
Book.class 4KB
BookService.class 3KB
ShoppingCart.class 3KB
UserServiceImpl.class 3KB
User.class 3KB
Comment.class 3KB
WalletTradeRecord.class 3KB
LoginInterceptor.class 3KB
AdminController.class 2KB
BookCategory.class 2KB
Admin.class 2KB
WalletServiceImpl.class 2KB
Address.class 2KB
UserMapper.class 2KB
Wallet.class 2KB
UserService.class 1KB
AdminServiceImpl.class 1KB
WalletMapper.class 846B
WalletService.class 675B
AdminMapper.class 410B
AdminService.class 283B
order.css 3KB
myShop.css 3KB
main.css 3KB
manageBook.css 3KB
bookMessage.css 3KB
login.css 2KB
adminLogin.css 2KB
address.css 2KB
updateUser.css 2KB
myCenter.css 2KB
updatePassword.css 2KB
updateMyAddress.css 2KB
off.css 2KB
updateWallet.css 2KB
myBookMessage.css 2KB
addBook.css 2KB
shoppingCart.css 2KB
buyBook.css 1KB
wallet.css 1KB
phoneEmail.css 854B
register.css 715B
address.ico 736B
wallet.ico 587B
register.ico 532B
off.ico 482B
cart.ico 462B
set.ico 457B
my.ico 410B
error.ico 380B
admin.ico 378B
purse.ico 367B
login.ico 324B
ordermanage.ico 321B
comment.ico 313B
issue.ico 289B
over.ico 286B
favicon.ico 282B
order.ico 225B
GraduationDesign.iml 620B
BookController.java 30KB
UserController.java 19KB
BookServiceImpl.java 6KB
BookMapper.java 4KB
Orders.java 4KB
LoginInterceptor.java 4KB
BookService.java 4KB
WalletController.java 3KB
Book.java 3KB
ShoppingCart.java 3KB
User.java 3KB
UserServiceImpl.java 2KB
Comment.java 2KB
WalletTradeRecord.java 2KB
UserMapper.java 2KB
AdminController.java 1KB
UserService.java 1KB
WalletServiceImpl.java 1KB
BookCategory.java 1KB
Admin.java 1KB
Address.java 1020B
Wallet.java 966B
WalletMapper.java 738B
AdminServiceImpl.java 685B
WalletService.java 632B
AdminMapper.java 340B
AdminService.java 265B
bg2.jpeg 298KB
bg2.jpeg 298KB
bg1.jpeg 12KB
bg1.jpeg 12KB
gx.jpg 682KB
xk.jpg 189KB
o.jpg 159KB
共 220 条
- 1
- 2
- 3
程序员张小妍
- 粉丝: 1w+
- 资源: 3474
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页