基于javaweb+jsp的在线小说阅读系统(读者、作者、管理员)(java+SSM+jsp+mysql+maven)
一、项目简述
功能包括: 1:用户及主要操作功能 游客可以浏览网站的主页,登陆注册,小说湿度,下单购 买,订单查询,个人信息查询,留言评论。 2:作者模块 作者登录注册,小说发表,小说维护等等。 3:作者模块 管理员登录,读者管理,小说管理,评论管理,充值订单 管理,订阅订单管理,折扣活动管理等等
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
@ResponseBody
public ResultData deleteAll(@RequestParam(name = "ids") String ids){
// 将ids转换成数组
String[] idArr=ids.split(",");
return readerService.batchDelete(idArr);
};
/**
* 批量恢复
* @param ids
* @return
*/
//
//读者列表
@RequestMapping("/reader/list")
public String list(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize){
PageInfo<Reader> pageInfo = readerService.list(page,pageSize);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-list";
}
//搜索读者显示列表
@RequestMapping("/reader/search")
public String searchList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize,
String keyword){
PageInfo<Reader> pageInfo = readerService.searchList(page, pageSize, keyword);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-list";
}
//读者删除列表
@RequestMapping("/reader/deleteList")
}
int readerId = reader.getReaderId();*/
int readerId = 1;
List<BookOrder> bookOrderList = bookOrderService.getAll(readerId);
model.addAttribute("bookOrderList",bookOrderList);
return "front/orderCenter";
}
}
读者控制层:
@Controller
public class ReaderController {
@Autowired
//
//读者列表
@RequestMapping("/reader/list")
public String list(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize){
PageInfo<Reader> pageInfo = readerService.list(page,pageSize);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-list";
}
//搜索读者显示列表
@RequestMapping("/reader/search")
public String searchList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize,
String keyword){
PageInfo<Reader> pageInfo = readerService.searchList(page, pageSize, keyword);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-list";
}
*/
@RequestMapping("/loginPage")
public String loginPage(){
return "login";
}
@RequestMapping(value = "/novelPage",method = RequestMethod.GET)
public String novelPage(Integer bookId, Model model){
Book book = bookService.findById(bookId);
List<Message> messageList = messageService.findByBookId(bookId);
model.addAttribute("book",book);
model.addAttribute("messageList",messageList);
return "novel";
}
@RequestMapping(value = "/shiduPage",method = RequestMethod.GET)
public String shiduPage(Integer bookId,Integer page,Model model){
Book book = bookService.findById(bookId);
Chapter chapter = book.getChapterList().get(page-1);
int totalPage= book.getChapterList().size();
}
/**
* 登陆操作
* @return
*/
@RequestMapping("/login")
@ResponseBody// 该方法返回的是json字符串
public ResultData login(Admin admin,HttpServletRequest request){
// 登陆操作
ResultData resultData = adminService.login(admin);
// 判断登陆成功,将用户数据保存到 session中
// 如何获取session对象?
if(resultData.getCode() == 200){
HttpSession session = request.getSession();
session.setAttribute("admin",resultData.getData());
}
// 重定向: 1. 客户端行为 2. 两次请求 3. 不能携带前一次请求的数据
// 转发: 1. 服务器端行为 2. 一次请求 3. 能够携带前一次请求的数据
return "redirect:/loginPage";
}
// @RequestMapping("/login")
// @ResponseBody// 该方法返回的是json字符串
// public ResultData login(Admin admin,HttpServletRequest request){
// // 登陆操作
// ResultData resultData = adminService.login(admin);
// // 判断登陆成功,将用户数据保存到 session中
// // 如何获取session对象?
// if(resultData.getCode() == 200){
// HttpSession session = request.getSession();
// session.setAttribute("admin",resultData.getData());
// }
//
// return resultData;
// }
public class BookOrderController {
@Autowired
private BookOrderService bookOrderService;
@Autowired
private BookService bookService;
@RequestMapping("/bookorder/bookorderlist")
public String bookorderlist(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "3") Integer pageSize) {
PageInfo<BookOrder> pageInfo = bookOrderService.list(page, pageSize);
//将数据转发到页面
model.addAttribute("list", pageInfo.getList());
model.addAttribute("pageInfo", pageInfo);
return "bookorder/bookorder-list";
}
@RequestMapping("/bookorder/orderSearch")
@ResponseBody
public ResultData delete(Integer orderid,Integer orderStatus){
return bookOrderService.delete(orderid,orderStatus);
}
@RequestMapping("/bookOrder/toOrder")
public String delete(Integer bookId,Model model){
Book book = bookService.findById(bookId);
model.addAttribute("book",book);
return "front/order";
}
// Reader reader = (Reader)session.getAttribute("reader");
// if(reader==null){
// return "login";
// }
Reader reader = readerService.findById(1 );
model.addAttribute("reader",reader);
return "front/center";
}
登录控制层:
/**
* @author:yy
*/
@Controller
public class LoginController {
@Autowired
private AdminService adminService;
@Autowired
private BookService bookService;
@RequestMapping("/history/add")
@ResponseBody
public ResultData add(History history){
return historyService.add(history);
}
// search
@RequestMapping("/history/search")
public String searchList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "3") Integer pageSize,
String keyword) {
PageInfo<History> pageInfo=historyService.searchList(page,pageSize,keyword);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "history/history-list";
}
// 批量删除
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-list";
}
//读者删除列表
@RequestMapping("/reader/deleteList")
public String deleteList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "5") Integer pageSize){
PageInfo<Reader> pageInfo = readerService.DeleteList(page,pageSize);
model.addAttribute("list",pageInfo.getList());
model.addAttribute("pageInfo",pageInfo);
return "reader/reader-del";
}
//添加读者
@RequestMapping("/reader/addPage")
public String addPage(){
return "front/register";
}
return "bookorder/bookorder-list";
}
@RequestMapping("/bookorder/orderSearch")
public String searchList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "3") Integer pageSize,
String keyword) {
PageInfo<BookOrder> pageInfo = bookOrderService.searchList(page,pageSize,keyword);
//将数据转发到页面
model.addAttribute("list", pageInfo.getList());
model.addAttribute("pageInfo", pageInfo);
String keyword) {
PageInfo<BookOrder> pageInfo = bookOrderService.searchList(page,pageSize,keyword);
//将数据转发到页面
model.addAttribute("list", pageInfo.getList());
model.addAttribute("pageInfo", pageInfo);
return "bookorder/bookorder-list";
}
@RequestMapping("/bookorder/bookorderadd")
public String bookorderadd() {
return "bookorder/bookorder-add";
}
@RequestMapping(value = "/bookorder/add",method = RequestMethod.POST)
@ResponseBody
@RequestMapping(value = "/bookorder/add",method = RequestMethod.POST)
@ResponseBody
public ResultData add(BookOrder bookOrder, HttpSession session) {
Reader reader = (Reader)session.getAttribute("reader");
if(reader==null){
return new ResultData(2001,"用户未登陆",null);
}
int readerId = reader.getReaderId();
bookOrder.setUserId(1);
bookOrder.setDiscountId(1);
bookOrder.setOrderDate(new Timestamp(System.currentTimeMillis()));
bookOrder.setOrderStatus(1);
bookOrder.setPayStatus(1);
ResultData resultData = bookOrderService.add(bookOrder);
return resultData;
}
*/
@RequestMapping("/loginPage")
public String loginPage(){
return "login";
}
@RequestMapping(value = "/novelPage",method = RequestMethod.GET)
public String novelPage(Integer bookId, Model model){
Book book = bookService.findById(bookId);
List<Message> messageList = messageService.findByBookId(bookId);
model.addAttribute("book",book);
model.addAttribute("messageList",messageList);
return "novel";
}
PageInfo<BookOrder> pageInfo = bookOrderService.searchList(page,pageSize,keyword);
//将数据转发到页面
model.addAttribute("list", pageInfo.getList());
model.addAttribute("pageInfo", pageInfo);
return "bookorder/bookorder-list";
}
@RequestMapping("/bookorder/bookorderadd")
public String bookorderadd() {
return "bookorder/bookorder-add";
}
@RequestMapping(value = "/bookorder/add",method = RequestMethod.POST)
@ResponseBody
public ResultData add(BookOrder bookOrder, HttpSession session) {
Reader reader = (Reader)session.getAttribute("reader");
if(reader==null){
return new ResultData(2001,"用户未登陆",null);
}
int readerId = reader.getReaderId();
bookOrder.setUserId(1);
bookOrder.setDiscountId(1);
return readerService.add(reader);
}
/**
* 编辑读者状态信息
* @param readerId : 当前读者Id
* @param readerStatus: 读者当前状态
* @return
*/
@RequestMapping("/reader/editStatus")
@ResponseBody
public ResultData editStatus(Integer readerId, Integer readerStatus){
return readerService.updateStatus(readerId, readerStatus);
登录控制层:
/**
* @author:yy
*/
@Controller
public class LoginController {
@Autowired
private AdminService adminService;
@Autowired
private BookService bookService;
@Autowired
private MessageService messageService;
bookOrder.setDiscountId(1);
bookOrder.setOrderDate(new Timestamp(System.currentTimeMillis()));
bookOrder.setOrderStatus(1);
bookOrder.setPayStatus(1);
ResultData resultData = bookOrderService.add(bookOrder);
return resultData;
}
@RequestMapping("/bookorder/editStatus")
@ResponseBody
public ResultData editStatus(Integer id, Integer status) {
return bookOrderService.updateStatus(id,status);
}
@RequestMapping("/bookorder/deleteAll")
@ResponseBody
public ResultData deleteAll(@RequestParam(name = "ids") String ids){
// 将ids转换成数组
String[] idArr = ids.split(",");
return bookOrderService.batchDelete(idArr);
* @param reader
* @return
*/
@RequestMapping("/reader/edit")
@ResponseBody
public ResultData edit(Reader reader){
return readerService.edit(reader);
}
/**
* 批量删除
* @param ids
// 只需要去将保存到session的数据干掉即可
request.getSession().setAttribute("admin",null);
// 重定向和转发的区别?
// 重定向: 1. 客户端行为 2. 两次请求 3. 不能携带前一次请求的数据
// 转发: 1. 服务器端行为 2. 一次请求 3. 能够携带前一次请求的数据
return "redirect:/loginPage";
}
}
历史控制层:
@Controller
* 编辑读者状态信息
* @param readerId : 当前读者Id
* @param readerStatus: 读者当前状态
* @return
*/
@RequestMapping("/reader/editStatus")
@ResponseBody
public ResultData editStatus(Integer readerId, Integer readerStatus){
return readerService.updateStatus(readerId, readerStatus);
}
/**
* 编辑读者
* @param
* @param
* @return
*/
@RequestMapping("/reader/editPage")
public String editPage(Model model, Integer readerId){
Reader dbreadder = readerService.findById(readerId);
model.addAttribute("reader",dbreadder);
return "front/personal";
}
/**
* 登陆操作
* @return
*/
@RequestMapping("/loginreader")
@ResponseBody
public ResultData login1(Reader reader,HttpServletRequest request){
// 登陆操作
ResultData resultData = readerService.login1(reader);
@RequestMapping("/bookorder/editStatus")
@ResponseBody
public ResultData editStatus(Integer id, Integer status) {
return bookOrderService.updateStatus(id,status);
}
@RequestMapping("/bookorder/deleteAll")
@ResponseBody
public ResultData deleteAll(@RequestParam(name = "ids") String ids){
// 将ids转换成数组
String[] idArr = ids.split(",");
return bookOrderService.batchDelete(idArr);
}
@RequestMapping("/bookorder/delete")
@ResponseBody
public ResultData delete(Integer orderid,Integer orderStatus){
return bookOrderService.delete(orderid,orderStatus);
}
@RequestMapping("/bookOrder/toOrder")
public String delete(Integer bookId,Model model){
/**
* 批量删除
* @param ids
* @return
*/
@RequestMapping("/reader/deleteAll")
@ResponseBody
public ResultData deleteAll(@RequestParam(name = "ids") String ids){
// 将ids转换成数组
String[] idArr=ids.split(",");
return readerService.batchDelete(idArr);
};
/**
* 批量恢复
* @param ids
model.addAttribute("reader",reader);
return "front/center";
}
登录控制层:
/**
* @author:yy
*/
@Controller
public class LoginController {
@Autowired
private AdminService adminService;
@Autowired
private BookService bookService;
@Autowired
private MessageService messageService;
/**
model.addAttribute("pageInfo",pageInfo);
return "history/history-list";
}
//添加
@RequestMapping("/history/addPage")
public String addPage(){
return "history/history-add";
}
// 添加
@RequestMapping("/history/add")
@ResponseBody
public ResultData add(History history){
return historyService.add(history);
}
// search
@RequestMapping("/history/search")
public String searchList(Model model,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "3") Integer pageSize,
String keyword) {
PageInfo<History> pageInfo=historyService.searchList(page,pageSize,keyword);
model.addAttribute("list",pageInfo.getList());
* 退出登陆的方法
* @return
*/
@RequestMapping("/logout")
public String logout(HttpServletRequest request){
// 只需要去将保存到session的数据干掉即可
request.getSession().setAttribute("admin",null);
// 重定向和转发的区别?
// 重定向: 1. 客户端行为 2. 两次请求 3. 不能携带前一次请求的数据
// 转发: 1. 服务器端行为 2. 一次请求 3. 能够携带前一次请求的数据
return "redirect:/loginPage";
}
}
历史控制层:
@Controller
public class HistoryController {
@Autowired
private HistoryService historyService;
//列表
@RequestMapping("/history/list")
public String list(Model model,
@RequestParam(defaultValue = "1") Integer page,