基于javaweb+mysql的ssm+maven电子书网络图书在线小说阅读管理系统(java+ssm+jsp+javascript+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven电子书网络图书在线小说阅读管理系统(java+ssm+jsp+javascript+mysql)
项目介绍
本项目包含管理员、用户两种角色;
管理员角色包含以下功能:
登录页面,管理员管理书籍,用户管理等功能。
用户角色包含以下功能:
首页,用户登录页面,电子书查看页面,下载电子书,查看分类,用户上传图书,查看个人中心,添加反馈,查看反馈等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:是;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:JSP+CSS+JavaScript
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中config.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入http://localhost:8080/ssm_ebooknet 登录
if (null == session.getAttribute("status")) {
return "backstage/adminLogin";
}
Map<String,Object> resultMap;
resultMap = backStageService.getAdminByRole();
List<User> userList = (List<User>) resultMap.get("userList");
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
model.addAttribute("weekUser",weekUser);
model.addAttribute("monthUser",monthUser);
model.addAttribute("totalUser",totalUser);
return "backstage/sysuserManage";
}
@RequestMapping(value = "/setSuperManage",method=RequestMethod.POST)
public String setSuperManage(Model model,HttpSession session,long id,int role) {
User user = userDao.queryById(id);
user.setRole(role);
userDao.updateUserInfo(user);
if(id == Long.parseLong(session.getAttribute("id")+"")) {
session.setAttribute("role", role);
}
Map<String,Object> resultMap;
resultMap = backStageService.getAdminByRole();
List<User> userList = (List<User>) resultMap.get("userList");
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
model.addAttribute("weekUser",weekUser);
model.addAttribute("monthUser",monthUser);
model.addAttribute("totalUser",totalUser);
return "redirect:sysuserManage";
}
@RequestMapping(value = "/preeditAdmin",method=RequestMethod.GET)
public String preeditAdmin(Model model,HttpSession session,long id) {
User user = userDao.queryById(id);
model.addAttribute("editadmin",user);
return "backstage/editAdmin";
}
return false;
}
}
public List<doBookHelper> iteratorUploadList(List<Upload> uploadList) {
List<doBookHelper> doBookHelperList = new ArrayList<doBookHelper>();
Book book;
for (Upload upload : uploadList) {
doBookHelper bookHelper = new doBookHelper();
book = bookDao.queryById(upload.getUploadedBook());
bookHelper.setId(book.getId());
bookHelper.setTitle(book.getBook_title());
bookHelper.setAuthor(book.getBook_author());
bookHelper.setUploader(upload.getUploader());
bookHelper.setUploadedDate(upload.getUploadedDate());
doBookHelperList.add(bookHelper);
}
return doBookHelperList;
}
public List<doBookHelper> getUploadBooks() {
List<doBookHelper> doBookHelperList;
List<Upload> uploadList = uploadDao.queryByUploadedDate();
doBookHelperList = iteratorUploadList(uploadList);
return doBookHelperList;
}
public List<doBookHelper> getBooksByDays(int days) {
List<doBookHelper> doBookHelperList;
List<Upload> uploadList;
if (days == 30) {
uploadList = uploadDao.searchByThirtyDays();
} else if (days == 7) {
uploadList = uploadDao.searchBySevenDays();
} else {
uploadList = uploadDao.searchByToday();
}
doBookHelperList = iteratorUploadList(uploadList);
return doBookHelperList;
}
public List<doBookHelper> getBooksByTitle(String title) {
List<doBookHelper> doBookHelperList = new ArrayList<doBookHelper>();
List<Book> bookList = bookDao.searchBookByTitle(title);
for (Book book: bookList) {
doBookHelper bookHelper = new doBookHelper();
bookHelper.setId(book.getId());
bookHelper.setTitle(book.getBook_title());
bookHelper.setAuthor(book.getBook_author());
for (int i = str.length();--i>=0;){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}
public List<Feedback> getFeedback() {
List<Feedback> feedbackList = feedbackDao.queryAllNotRead();
return feedbackList;
}
public int setOneFeedbackRead(int id) {
int count = feedbackDao.setOneRead(id);
return count;
}
public int setAllFeedbackRead() {
return feedbackDao.setAllRead();
}
}
book.setType_id(type_id);
book.setBook_format(format);
book.setDownload_times(0);
String file1 = typeNames.get(0) +
"/" + typeNames.get(1) + "/" +
bookHelper.getTitle() + "." + format;
book.setBook_file("ebooks/" + file1);
String coverPath1 = coverPath_pre + typeNames.get(0) +
"/" + typeNames.get(1) + "/" +
bookHelper.getTitle() + ".jpg";
book.setBook_cover(coverPath1);
dateFormat = new SimpleDateFormat("yyMMdd", Locale.CHINESE);
String pubDate = dateFormat.format(date);
String upDate = dateFormat.format(new Date());
int random = new Random().nextInt(900) + 100;
String idStr = "" + typeId + pubDate + upDate + random;
long bookID = Long.parseLong(idStr);
logger.info("The book id you uploaded is " + bookID);
book.setId(bookID);
bookService.uploadBook(book);
UserHelper userHelper = (UserHelper) session.getAttribute("userHelper");
bookService.updateRecords(userHelper.getId(), bookID);
userService.updateUserContribution(2, userHelper.getId());
model.addAttribute("bookID", bookID);
logger.info("you are coming to the uploading successful page!");
return "upload_success";
}
}
}
bis.close();
}
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
@RequestMapping(value = "/book_download")
public void getBookDownload(long bookID, String filePath, HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
String file_dir_pre = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(0,Thread.currentThread().getContextClassLoader().getResource("").getPath().length()-16);
String fPath = file_dir_pre+filePath;
long fileLength = new File(fPath).length();
response.setContentType("application/x-msdownload");
response.setHeader("Content-disposition", "attachment; filename="
+ new String(fileName.getBytes("utf-8"), "ISO8859-1"));
response.setHeader("Content-Length", String.valueOf(fileLength));
// 新建文件输入流并对它进行缓冲
FileInputStream input = new FileInputStream(fPath);
bis = new BufferedInputStream(input);
// 新建文件输出流并对它进行缓冲
bos = new BufferedOutputStream(response.getOutputStream());
// 缓冲数组
byte[] b = new byte[1024 * 5];
int len;
while ((len = bis.read(b)) != -1) {
bos.write(b, 0, len);
}
// 刷新此缓冲的输出流
if(user == null) {
return false;
}else if(user.getRole() == 0){
return false;
}
else if(user.getRole() == 1||user.getRole() == 2){
session.setAttribute("role", user.getRole());
session.setAttribute("id", user.getId());
return true;
}else {
return false;
}
}
public List<doBookHelper> iteratorUploadList(List<Upload> uploadList) {
List<doBookHelper> doBookHelperList = new ArrayList<doBookHelper>();
Book book;
for (Upload upload : uploadList) {
doBookHelper bookHelper = new doBookHelper();
book = bookDao.queryById(upload.getUploadedBook());
bookHelper.setId(book.getId());
bookHelper.setTitle(book.getBook_title());
bookHelper.setAuthor(book.getBook_author());
bookHelper.setUploader(upload.getUploader());
bookHelper.setUploadedDate(upload.getUploadedDate());
doBookHelperList.add(bookHelper);
}
return doBookHelperList;
}
public List<doBookHelper> getUploadBooks() {
List<doBookHelper> doBookHelperList;
List<Upload> uploadList = uploadDao.queryByUploadedDate();
doBookHelperList = iteratorUploadList(uploadList);
return doBookHelperList;
}
public List<doBookHelper> getBooksByDays(int days) {
List<doBookHelper> doBookHelperList;
List<Upload> uploadList;
if (days == 30) {
MultipartFile bookFile = bookHelper.getBookFile();
MultipartFile coverFile = bookHelper.getBookCover();
if (bookFile.isEmpty()) {
logger.info("Uploading failed! The book you are uploading is empty!");
return "upload_failed";
} else if (coverFile.isEmpty()) {
logger.info("Uploading failed! The book cover you are uploading is empty!");
return "upload_failed";
} else {
String typeId = "" + bookHelper.getLargeType() + bookHelper.getSmallType();
int type_id = Integer.parseInt(typeId);
String format = fileName.substring(fileName.lastIndexOf('.') + 1);
List<String> typeNames;
typeNames = bookService.getTypeNames(type_id);
String filePath_pre = (String) PropertyConfigurer.getProperty("book_path");
String file_dir_pre = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(0, Thread.currentThread().getContextClassLoader().getResource("").getPath().length() - 16) + filePath_pre;
String filePath = file_dir_pre + typeNames.get(0) +
"/" + typeNames.get(1) + "/" +
bookHelper.getTitle() + "." + format;
File file = new File(file_dir_pre + typeNames.get(0) +
"/" + typeNames.get(1));
if (!file.exists()) {
file.mkdirs();
}
File localBookFile = new File(filePath);
if (localBookFile.exists()) {
logger.info("Uploading failed! The book is existed!");
return "upload_failed2";
}
bookFile.transferTo(localBookFile);
String coverPath_pre = (String) PropertyConfigurer.getProperty("book_cover_path");
String coverPath = file_dir_pre + coverPath_pre + typeNames.get(0) +
"/" + typeNames.get(1) + "/" +
bookHelper.getTitle() + ".jpg";
file = new File(file_dir_pre + coverPath_pre + typeNames.get(0) +
"/" + typeNames.get(1));
if (!file.exists()) {
file.mkdirs();
}
File localCoverFile = new File(coverPath);
coverFile.transferTo(localCoverFile);
logger.info("The book has uploaded to local path successfully!");
Book book = new Book();
book.setBook_title(bookHelper.getTitle());
book.setBook_author(bookHelper.getAuthor());
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM");
Date date = dateFormat.parse(bookHelper.getPubYear());
book.setBook_pubYear(date);
book.setBook_summary(bookHelper.getSummary());
book.setType_id(type_id);
book.setBook_format(format);
book.setDownload_times(0);
@ResponseBody
public Map<String,Integer> checkUserCode(String userCode) {
Map<String, Integer> resultMap = new HashMap<String, Integer>();
int count = userService.checkUserCode(userCode);
resultMap.put("isRegistered", count);
return resultMap;
}
@RequestMapping(value = "register",method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> register(@RequestBody User user) {
Map<String, Object> resultMap = new HashMap<String, Object>();
user.setRole(0);
userService.addUser(user);
logger.info("you have registered!");
return resultMap;
}
}
public class TestInterceptor implements HandlerInterceptor{
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
//这句话是解决乱码的
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
ModelAndView modelAndView) throws Exception {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
//这句话是解决乱码的
}
@Override
@Autowired
private BookDao bookDao;
@Autowired
private UserDao userDao;
@Autowired
private FeedbackDao feedbackDao;
public boolean getLogin(String username, String password, HttpSession session) {
User user = userDao.queryByLogin(username,password);
if(user == null) {
return false;
}else if(user.getRole() == 0){
return false;
}
else if(user.getRole() == 1||user.getRole() == 2){
session.setAttribute("role", user.getRole());
session.setAttribute("id", user.getId());
return true;
}else {
return false;
}
}
public List<doBookHelper> iteratorUploadList(List<Upload> uploadList) {
List<doBookHelper> doBookHelperList = new ArrayList<doBookHelper>();
Book book;
for (Upload upload : uploadList) {
doBookHelper bookHelper = new doBookHelper();
book = bookDao.queryById(upload.getUploadedBook());
bookHelper.setId(book.getId());
bookHelper.setTitle(book.getBook_title());
bookHelper.setAuthor(book.getBook_author());
bookHelper.setUploader(upload.getUploader());
bookHelper.setUploadedDate(upload.getUploadedDate());
doBookHelperList.add(bookHelper);
}
return doBookHelperList;
}
public List<doBookHelper> getUploadBooks() {
List<doBookHelper> doBookHelperList;
List<Upload> uploadList = uploadDao.queryByUploadedDate();
doBookHelperList = iteratorUploadList(uploadList);
return doBookHelperList;
}
model.addAttribute("sumOfTypeBooks",everyTypeBooks);
String maxUploadDate = bookService.getMaxUploadDate();
model.addAttribute("maxUploadDate", maxUploadDate);
List<RankingBook> rankingBooks;
rankingBooks = bookService.queryByUploadedDate();
model.addAttribute("rankingBooks",rankingBooks);
List<RankingBook> rankingBooks1;
rankingBooks1 = bookService.queryByDownloadTimes();
model.addAttribute("rankingBooks1",rankingBooks1);
List<BookType> bookTypes;
bookTypes = bookService.getTypes();
model.addAttribute("bookTypes",bookTypes);
List<BookType> bookLargeTypes;
bookLargeTypes = bookService.getLargerTypes();
model.addAttribute("bookLargeTypes",bookLargeTypes);
return "backstage/bookManage";
}
@Autowired
GonggaoService gonggaoService;
@RequestMapping(value = "/gonggaoManage")
String getLists(Model model,HttpSession session) {
if (null == session.getAttribute("status")) {
return "backstage/adminLogin";
}
List<Gonggao> list = gonggaoService.getLists();
for(Gonggao gonggao:list) {
if(gonggao.getContent()!=null&&gonggao.getContent().length()>10) {
gonggao.setContent(gonggao.getContent().substring(0,10)+"...");
}
}
model.addAttribute("gonggaoList", list);
Map<String,Object> resultMap;
resultMap = backStageService.getUserByRole();
List<User> userList = (List<User>) resultMap.get("userList");
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
model.addAttribute("weekUser",weekUser);
model.addAttribute("monthUser",monthUser);
model.addAttribute("totalUser",totalUser);
return "backstage/gonggaoManage";
private static final Log logger = LogFactory.getLog(MainController.class);
@Autowired
private BookService bookService;
@Autowired
GonggaoService gonggaoService;
@RequestMapping(value = "/index")
public String index(Model model) {
logger.info("Welcome to gatheringbook.cn!");
String name = (String)PropertyConfigurer.getProperty("book_path");
System.out.println("hello, " + name);
int sumOfBooks = bookService.queryNumberOfBooks();
model.addAttribute("sumOfBooks", sumOfBooks);
List<Integer> everyTypeBooks;
everyTypeBooks = bookService.queryNumberOfSomeTypeBooks();
model.addAttribute("sumOfTypeBooks",everyTypeBooks);
String maxUploadDate = bookService.getMaxUploadDate();
model.addAttribute("maxUploadDate", maxUploadDate);
List<RankingBook> rankingBooks;
rankingBooks = bookService.queryByUploadedDate();
model.addAttribute("rankingBooks",rankingBooks);
List<RankingBook> rankingBooks1;
rankingBooks1 = bookService.queryByDownloadTimes();
model.addAttribute("rankingBooks1",rankingBooks1);
List<Gonggao> gonggaos;
gonggaos = gonggaoService.getLists();
for(Gonggao gonggao:gonggaos) {
if(gonggao.getContent()!=null&&gonggao.getContent().length()>10) {
gonggao.setContent(gonggao.getContent().substring(0,10)+"...");
SimpleDateFormat dateFm = new SimpleDateFormat("yyyy-MM-dd"); //格式化当前系统日期
String dateTime = dateFm.format(gonggao.getShijian());
gonggao.setTime(dateTime);
}
}
model.addAttribute("gonggaos",gonggaos);
return "main";
}
}
@RequestMapping(value = "getUploadPage")
public String getUploadPage(HttpSession session) {
UserHelper userHelper = (UserHelper) session.getAttribute("userHelper");
if (null == userHelper) {
return "redirect:index";
}
logger.info("you are visiting uploading page!");
return "upload";
}
@RequestMapping(value = "doUpload", method = RequestMethod.POST)
public String doUpload(@ModelAttribute BookHelper bookHelper, Model model, HttpSession session) throws IllegalStateException, IOException, ParseException {
logger.info("you are uploading a book! ");
logger.info("This book is " + bookHelper.getTitle() + "!");
String fileName = bookHelper.getBookFile().getOriginalFilename();
String bookCover = bookHelper.getBookCover().getOriginalFilename();
MultipartFile bookFile = bookHelper.getBookFile();
MultipartFile coverFile = bookHelper.getBookCover();
if (bookFile.isEmpty()) {
logger.info("Uploading failed! The book you are uploading is empty!");
return "upload_failed";
} else if (coverFile.isEmpty()) {
logger.info("Uploading failed! The book cover you are uploading is empty!");
return "upload_failed";
} else {
String typeId = "" + bookHelper.getLargeType() + bookHelper.getSmallType();
int type_id = Integer.parseInt(typeId);
String format = fileName.substring(fileName.lastIndexOf('.') + 1);
List<String> typeNames;
typeNames = bookService.getTypeNames(type_id);
String filePath_pre = (String) PropertyConfigurer.getProperty("book_path");
String file_dir_pre = Thread.currentThread().getContextClassLoader().getResource("").getPath().substring(0, Thread.currentThread().getContextClassLoader().getResource("").getPath().length() - 16) + filePath_pre;
String filePath = file_dir_pre + typeNames.get(0) +
"/" + typeNames.get(1) + "/" +
bookHelper.getTitle() + "." + format;
File file = new File(file_dir_pre + typeNames.get(0) +
"/" + typeNames.get(1));
if (!file.exists()) {
file.mkdirs();
}
File localBookFile = new File(filePath);
if (localBookFile.exists()) {
logger.info("Uploading failed! The book is existed!");
return "upload_failed2";
}
logger.info("you are removing a book!");
Map<String,Object> resultMap = new HashMap<String,Object>();
int result = backStageService.deleteBook(bookId);
resultMap.put("result",result);
return resultMap;
}
@RequestMapping(value = "/userManage")
public String userManage(Model model,HttpSession session) {
if (null == session.getAttribute("status")) {
return "backstage/adminLogin";
}
Map<String,Object> resultMap;
resultMap = backStageService.getUserByRole();
List<User> userList = (List<User>) resultMap.get("userList");
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
model.addAttribute("weekUser",weekUser);
model.addAttribute("monthUser",monthUser);
model.addAttribute("totalUser",totalUser);
return "backstage/userManage";
}
@RequestMapping(value = "/deleteUser")
@ResponseBody
public Map<String,Integer> deleteUser(long userId) {
logger.info("you are removing a user!");
Map<String,Integer> resultMap = new HashMap<String,Integer>();
int result = backStageService.deleteUser(userId);
resultMap.put("result",result);
return resultMap;
}
@RequestMapping(value = "/searchUser")
public String searchUser(String user, Model model,HttpSession session) {
if (null == session.getAttribute("status")) {
return "backstage/adminLogin";
}
List<User> userList = backStageService.getUserBySearch(user);
Map<String,Object> resultMap;
resultMap = backStageService.getUserByContribution();
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
if (bos != null) {
bos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
bookService.addDownloadTimes(bookID);
logger.info("you are downloading the book, the book file is " + fileName);
}
}
@RequestMapping(value = "/bookSearch")
public String bookSearch(String searchBy, String searchTxt, Model model) throws ParseException {
logger.info("you are searching book!");
logger.info("The search context is " + searchTxt);
List<Book> books = bookService.searchBook(searchBy, searchTxt);
model.addAttribute("books", books);
model.addAttribute("searchTxt",searchTxt);
return "searchResult";
}
}
/**
*/
@Controller
public class BookController {
@Autowired
private BookService bookService;
@Autowired
private UserService userService;
private static final Log logger = LogFactory.getLog(BookController.class);
@RequestMapping(value = "/bookList")
public String getBookList(String bookType, String smallType, @RequestParam(value = "pageId",defaultValue = "1") int pageId, Model model) {
logger.info("you are visiting the books list page!");
List<BookType> smallTypes;
smallTypes = bookService.getSmallTypesOfBook(bookType);
model.addAttribute("smallTypesOfBook", smallTypes);
model.addAttribute("bookType",bookType);
private BackStageService backStageService;
@Autowired
private UserDao userDao;
@Autowired
private BookTypeDao bookTypeDao;
@Autowired
private BookService bookService;
@RequestMapping(value = "/")
public String getLogin() {
return "backstage/adminLogin";
}
@RequestMapping(value = "/backlogin")
public String login(String username, String password, Model model, HttpSession session) {
boolean isLogin = backStageService.getLogin(username, password, session);
if (isLogin) {
session.setAttribute("status",true);
return "redirect:bookManage";
} else {
model.addAttribute("error","登陆失败,请重试!");
return "backstage/adminLogin";
}
}
@RequestMapping(value = "/bookManage")
public String bookManage(Model model,HttpSession session) {
if (null == session.getAttribute("status")) {
return "backstage/adminLogin";
}
List<doBookHelper> bookList;
bookList = backStageService.getUploadBooks();
model.addAttribute("bookList",bookList);
String name = (String)PropertyConfigurer.getProperty("book_path");
System.out.println("hello, " + name);
int sumOfBooks = bookService.queryNumberOfBooks();
model.addAttribute("sumOfBooks", sumOfBooks);
List<Integer> everyTypeBooks;
everyTypeBooks = bookService.queryNumberOfSomeTypeBooks();
model.addAttribute("sumOfTypeBooks",everyTypeBooks);
String maxUploadDate = bookService.getMaxUploadDate();
model.addAttribute("maxUploadDate", maxUploadDate);
List<RankingBook> rankingBooks;
rankingBooks = bookService.queryByUploadedDate();
model.addAttribute("rankingBooks",rankingBooks);
List<RankingBook> rankingBooks1;
rankingBooks1 = bookService.queryByDownloadTimes();
model.addAttribute("rankingBooks1",rankingBooks1);
@RequestMapping(value = "/editUser",method=RequestMethod.POST)
public String editUser(Model model,HttpSession session,User user) {
try {
user.setUserName(new String(user.getUserName().getBytes("UTF-8"), "UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
userDao.updateUserInfo(user);
Map<String,Object> resultMap;
resultMap = backStageService.getUserByRole();
List<User> userList = (List<User>) resultMap.get("userList");
int totalUser = (Integer) resultMap.get("totalUser");
int weekUser = (Integer) resultMap.get("weekUser");
int monthUser = (Integer) resultMap.get("monthUser");
model.addAttribute("userList",userList);
model.addAttribute("weekUser",weekUser);
model.addAttribute("monthUser",monthUser);
model.addAttribute("totalUser",totalUser);
return "backstage/userManage";
}
@RequestMapping(value = "/editBook",method=RequestMethod.POST)
public String editBook(Model model,HttpSession session,Book book) {
try {
book.setBook_author(new String(book.getBook_author().getBytes("UTF-8"), "UTF-8"));
book.setBook_summary(new String(book.getBook_summary().getBytes("UTF-8"), "UTF-8"));
book.setBook_title(new String(book.getBook_title().getBytes("UTF-8"), "UTF-8"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
bookService.updateBook(book);
List<doBookHelper> bookList;
bookList = backStageService.getUploadBooks();
model.addAttribute("bookList",bookList);
String name = (String)PropertyConfigurer.getProperty("book_path");
System.out.println("hello, " + name);
int sumOfBooks = bookService.queryNumberOfBooks();
model.addAttribute("sumOfBooks", sumOfBooks);
List<Integer> everyTypeBooks;
everyTypeBooks = bookService.queryNumberOfSomeTypeBooks();
model.addAttribute("sumOfTypeBooks",everyTypeBooks);
String maxUploadDate = bookService.getMaxUploadDate();
model.addAttribute("maxUploadDate", maxUploadDate);
List<RankingBook> rankingBooks;
rankingBooks = bookService.queryByUploadedDate();
model.addAttribute("rankingBooks",rankingBooks);
List<RankingBook> rankingBooks1;
@ResponseBody
public void feedback(String contact, String suggestion,HttpSession session) {
UserHelper userHelper = (UserHelper) session.getAttribute("userHelper");
userService.addFeedback(userHelper.getId(),contact,suggestion);
logger.info("you are posting the suggestion!");
logger.info("contact:" + contact);
logger.info("suggestion:" + suggestion);
}
}
/**
*/
@Controller
public class LoginController {
@Autowired
private UserService userService;
private static final Log logger = LogFactory.getLog(LoginController.class);