基于SSM的情缘图书馆管理系统。SSM框架,适合java初学者。
主要功能包括:
图书编目管理:图书编目、编目维护;
图书信息管理:图书录入、图书信息;
图书借阅管理:借阅图书、借阅信息、归还、续借;
读者管理:办证、读者信息、读者类别、证件操作;
系统管理:权限信息、用户权限;
软件架构
- SSM+Tomcat8.5+Maven3.6.3+JDK1.8+MySQL5.7
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
public String addCategory(TbCategory category, HttpSession session, Model model) {
List<TbCategory> categoryList = libraryCategoryService.getCategoryAll();
boolean is = false;
for (TbCategory tbCategory : categoryList) {
if (category.getCatname().equals(tbCategory.getCatname())) {
is = true;
break;
}
}
if (!is) {
// 添加 数据到 数据库,并 修改 父类目
libraryCategoryService.addBookCategory(category, session);
} else {
model.addAttribute("errorMsg", "类目已经存在");
return "errorMsg";
}
return "redirect:/admin/ch/loan_BookClassify.action";
}
return "user/error";
}
//注册成功,将用户名放入seesion中
tbUser = this.login_loginValidation.findUserByUserName(user);
activeUser.setUserid(tbUser.getId());
activeUser.setUsername(tbUser.getUsername());
activeUser.setHeadImg(tbUser.getHeadimg());
session.setAttribute("activeUser", activeUser);
msg = "注册成功!正在为您登录,请稍候...";
url = "/user/userSystem.action";
model.addAttribute("msg", msg);
model.addAttribute("url", url);
return "user/error";
* @return
*/
@RequestMapping("/bookId")
public String toBookInfo(int id, Model model) {
BookExt bookInfo = libraryService.getBookInfoById(id);
// 将 时间戳 进行转换
Long dateSS = bookInfo.getLibrary().getCreatedate();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String formatDate = simpleDateFormat.format(new Date(dateSS * 1000));
bookInfo.setFormatDate(formatDate);
// 通过 图书id 获取 回复信息
List<CommentExt> commentExts = commentService.findCommentByBookId(id);
// 将 查询的 图书信息 设置到 域 中
model.addAttribute("bookInfo", bookInfo);
// 将 回复信息 设置到 域 汇总
model.addAttribute("commentExts", commentExts);
return "/user/bookDetail";
}
/**
* 用于 借阅 图书 操作
*
activeUser.setUserid(tbUser.getId());
activeUser.setUsername(tbUser.getUsername());
activeUser.setHeadImg(tbUser.getHeadimg());
session.setAttribute("activeUser", activeUser);
msg = "注册成功!正在为您登录,请稍候...";
url = "/user/userSystem.action";
model.addAttribute("msg", msg);
model.addAttribute("url", url);
return "user/error";
} else {
msg = "参数错误!";
url = "/login.action";
model.addAttribute("msg", msg);
model.addAttribute("url", url);
return "user/error";
}
}
//账号退出登录
@RequestMapping("/logout")
public String logout(HttpSession session) throws Exception {
session.invalidate();
return "redirect:/login.action";
}
// 管理员登录
@ResponseBody
public String commitComment(HttpSession session, TbComment comment) {
// 获取 session 中的用户信息
ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");
TbUser tbUser = new TbUser();
tbUser.setId(activeUser.getUserid());
comment.setUserId(tbUser.getId());
libraryService.addCommentInfo(comment);
return "ok";
}
}
登录注册Controller:
@Controller
@RequestMapping("/login")
public class Login_LoginController {
@Autowired
// 若 当前 类目 为 父类目 则获取 其 下面 的 所有子类目
// 若 当前 类目 为 子类目 则获取 其 同级 类目
List<TbCategory> categoryList = libraryCategoryService.getCategoryByCid(libraryQuery.getCateId());
// 获取当前类目信息
TbCategory currentCategory = libraryCategoryService.getCategoryById(libraryQuery.getCateId());
// 按照条件进行查询
PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, pageCount);
// model 将数据设置到域中
model.addAttribute("subCategoryList", categoryList);
model.addAttribute("libraryPageCount", libraryPageCount);
// 默认
if (currentCategory == null) {
currentCategory = new TbCategory();
currentCategory.setId(0);
}
session.setAttribute("currentCategory", currentCategory.getId());
return "/user/user_bookList";
}
/**
* 通过 图书 id 查询 图书详细信息
*
* @param id
* @return
*/
@RequestMapping("/bookId")
public String toBookInfo(int id, Model model) {
PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, pageCount);
// model 将数据设置到域中
model.addAttribute("subCategoryList", categoryList);
model.addAttribute("libraryPageCount", libraryPageCount);
// 默认
if (currentCategory == null) {
currentCategory = new TbCategory();
currentCategory.setId(0);
}
session.setAttribute("currentCategory", currentCategory.getId());
return "/user/user_bookList";
}
/**
* 通过 图书 id 查询 图书详细信息
*
* @param id
* @return
*/
@RequestMapping("/bookId")
public String toBookInfo(int id, Model model) {
BookExt bookInfo = libraryService.getBookInfoById(id);
// 将 时间戳 进行转换
Long dateSS = bookInfo.getLibrary().getCreatedate();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
TbCategory currentCategory = libraryCategoryService.getCategoryById(libraryQuery.getCateId());
// 按照条件进行查询
PageCount<TblibraryExt> libraryPageCount = libraryService.findLibraryByAll(libraryQuery, pageCount);
// model 将数据设置到域中
model.addAttribute("subCategoryList", categoryList);
model.addAttribute("libraryPageCount", libraryPageCount);
// 默认
if (currentCategory == null) {
currentCategory = new TbCategory();
currentCategory.setId(0);
}
session.setAttribute("currentCategory", currentCategory.getId());
return "/user/user_bookList";
}
/**
* 通过 图书 id 查询 图书详细信息
*
* @param id
* @return
*/
@RequestMapping("/bookId")
public String toBookInfo(int id, Model model) {
return "redirect:/user/ch/bookId.action?id=" + order.getBookId();
}
@RequestMapping("/commitInfo")
@ResponseBody
public String commitComment(HttpSession session, TbComment comment) {
// 获取 session 中的用户信息
ActiveUser activeUser = (ActiveUser) session.getAttribute("activeUser");
TbUser tbUser = new TbUser();
tbUser.setId(activeUser.getUserid());
comment.setUserId(tbUser.getId());
libraryService.addCommentInfo(comment);
return "ok";
}
}
登录注册Controller:
@Controller
@RequestMapping("/login")
return "user/error";
}
//注册成功,将用户名放入seesion中
tbUser = this.login_loginValidation.findUserByUserName(user);
activeUser.setUserid(tbUser.getId());
activeUser.setUsername(tbUser.getUsername());
activeUser.setHeadImg(tbUser.getHeadimg());
session.setAttribute("activeUser", activeUser);
msg = "注册成功!正在为您登录,请稍候...";
url = "/user/userSystem.action";
model.addAttribute("msg", msg);
model.addAttribute("url", url);
return "user/error";
} else {
msg = "参数错误!";
url = "/login.action";
model.addAttribute("msg", msg);
model.addAttribute("url", url);
return "user/error";
}
}
//账号退出登录
@RequestMapping("/logout")
public String logout(HttpSession session) throws Exception {
session.invalidate();
return "redirect:/login.action";