package com.wdd.library.controller;
import com.wdd.library.pojo.Admin;
import com.wdd.library.pojo.LendInfo;
import com.wdd.library.pojo.Reader;
import com.wdd.library.service.AdminService;
import com.wdd.library.service.LendInfoSerivce;
import com.wdd.library.service.ReaderService;
import com.wdd.library.util.AjaxResult;
import com.wdd.library.util.Const;
import com.wdd.library.util.PageBean;
import com.wdd.library.util.StringUtil;
import org.activiti.engine.impl.util.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
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 javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;
@Controller
public class commonController {
@Autowired
private ReaderService readerService;
@Autowired
private AdminService adminService;
@Autowired
private LendInfoSerivce lendInfoSerivce;
//跳转登录界面
@RequestMapping("/toLogin")
public String login(){
return "login";
}
//跳转注册界面
@RequestMapping("/toRegister")
public String toRegister(){
return "register";
}
//注册是查询是否存在该读者
@RequestMapping("/checkReader")
@ResponseBody
public AjaxResult checkreader(Integer reader_id) {
AjaxResult ajaxResult = new AjaxResult();
int count=readerService.checkReader(reader_id);
if(count==0){
ajaxResult.setSuccess(true);
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("当前学号已被注册!");
}
return ajaxResult;
}
//添加读者
@RequestMapping("/submitAddReader")
@ResponseBody
public AjaxResult submitAddreader(Reader reader) {
AjaxResult ajaxResult = new AjaxResult();
try{
readerService.addReader(reader);
ajaxResult.setSuccess(true);
ajaxResult.setMessage("注册成功");
}catch(Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("注册失败");
}
return ajaxResult;
}
//登录
@RequestMapping("/doLogin")
@ResponseBody
public AjaxResult list(String name, String password, String access, HttpSession session){
AjaxResult ajaxResult = new AjaxResult();
try{
if(access.equals("0")){
//管理员
Admin ad = new Admin();
ad.setName(name);
ad.setPassword(Integer.parseInt(password));
Admin admin = adminService.select(ad);
if(admin != null){
session.setAttribute(Const.ADMIN,admin);
ajaxResult.setStatus("0");
}else{
ajaxResult.setStatus("2");
ajaxResult.setMessage("用户名或密码错误");
}
}else{
//读者
Reader rd = new Reader();
rd.setReader_id(Integer.parseInt(name));
rd.setPassword(Integer.parseInt(password));
Reader reader = readerService.select(rd);
if(reader != null){
session.setAttribute(Const.READER,reader);
ajaxResult.setStatus("1");
}else{
ajaxResult.setStatus("2");
ajaxResult.setMessage("用户名或密码错误");
}
}
}catch (Exception e){
e.printStackTrace();
ajaxResult.setStatus("3");
ajaxResult.setMessage("服务器异常,请改天登录");
}
return ajaxResult;
}
//推出
@RequestMapping("/loginout")
public String loginout(HttpSession session){
session.invalidate();
return "login";
}
//跳转借阅管理页面
@RequestMapping("/listDisBackAdmin")
public String listDisBackAdmin() {
return "listDisBackAdmin";
}
//跳转读者借阅记录页面
@RequestMapping("/listDisBack")
public String listDisBack() {
return "listDisBack";
}
@RequestMapping("/listDisBackBook")
@ResponseBody
public String listDisBackBook(@RequestParam(value = "page", defaultValue = "1") Integer pageno,
@RequestParam(value = "limit", defaultValue = "5") Integer pagesize,
@RequestParam(value = "power",defaultValue = "0") Integer power,
String rname,String bname,String state){
Map<String,Object> paramMap = new HashMap();
paramMap.put("pageno",pageno);
paramMap.put("pagesize",pagesize);
if(StringUtil.isNotEmpty(bname)) paramMap.put("bname",bname);
if(StringUtil.isNotEmpty(rname)) paramMap.put("rname",rname);
if(StringUtil.isNotEmpty(state)) paramMap.put("state",state);
//为0说明是读者,1说明是管理员点击未还图书
if (power.equals(0)){
//读者号
//pageBean.setAdminId(admin.getAdminId());
//读者姓名
//pageBean.setRname(admin.getName());
}
PageBean<LendInfo> pageBean = lendInfoSerivce.queryLeadInfoPage(paramMap);
JSONObject obj = new JSONObject();
// Layui table 组件要求返回的格式
obj.put("code", 0);
obj.put("msg", "");
obj.put("count",pageBean.getTotalsize());
obj.put("data", pageBean.getDatas());
return obj.toString();
}
//管理员归还图书
@RequestMapping(value = "/backBook")
@ResponseBody
public AjaxResult backBook(@RequestParam(value = "reader_id" , defaultValue = "1") Integer reader_id,
@RequestParam(value = "book_id" , defaultValue = "1") Integer book_id) {
AjaxResult ajaxResult = new AjaxResult();
Map<String, Object> ret = new HashMap<String, Object>();
ret.put("reader_id",reader_id);
ret.put("book_id",book_id);
try{
lendInfoSerivce.backBook(ret);
ajaxResult.setSuccess(true);
ajaxResult.setMessage("已归还");
}catch (Exception e){
e.printStackTrace();
ajaxResult.setSuccess(false);
ajaxResult.setMessage("归还失败");
}
return ajaxResult;
}
//跳转到修改密码界面
@RequestMapping("/toAlterpwdPage")
public String toAlterpwdPage(String state, Model model) {
model.addAttribute("state",state);
return "alterPwd";
}
//确认密码
@RequestMapping("/checkPwd")
@ResponseBody
public AjaxResult checkPwd(Integer password,String state,HttpSession session){
AjaxResult ajaxResult = new AjaxResult();
if (state.equals("0")){
Admin admin = (Admin)session.getAttribute(Const.ADMIN);
if(admin.getPassword().equals(password)){
ajaxResult.setSuccess(true);
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("原密码错误");
}
}else{
Reader reader = (Reader)session.getAttribute(Const.READER);
if(reader.getPassword().equals(password)){
ajaxResult.setSuccess(true);
}else{
ajaxResult.setSuccess(false);
ajaxResult.setMessage("原密码错误");
}
}
return ajaxResult;
}
//修改密码
@RequestMapping("/alterpwd")
@ResponseBody
public AjaxResult alterpwd(Integer password,String state,HttpSession session){
AjaxResult ajaxResult = new AjaxResult();
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于ssm实现的图书借阅管理系统源码+数据库(借阅、归还、列表查询、增删改查等功能).zip 【资源介绍】 编译环境 : jdk 1.8 mysql 5.0 及以上 tomcat 7 框架 : springmvc + spring + mybatis jar包管理工具 : Maven 编译器 : IDEA 【备注】 该项目是个人毕设项目,答辩评审分达到95分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。 该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。 项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。
资源推荐
资源详情
资源评论
收起资源包目录
基于ssm实现的图书借阅管理系统源码+数据库(借阅、归还、列表查询、增删改查等功能).zip (183个子文件)
layui.css 68KB
layer.css 14KB
style.css 11KB
layui.mobile.css 10KB
laydate.css 8KB
laydate.css 7KB
code.css 1KB
iconfont.eot 40KB
iconfont.eot 2KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
commonController.java 9KB
libraryController.java 6KB
ReaderController.java 4KB
TypeController.java 3KB
LendInfoSerivceImpl.java 2KB
Book.java 2KB
PageBean.java 2KB
ReaderServiceImpl.java 2KB
Reader.java 2KB
LendInfo.java 2KB
BookServiceImpl.java 2KB
LoginInterceptor.java 1KB
TypeServiceImpl.java 850B
StartSystemListener.java 678B
AjaxResult.java 582B
AdminServiceImpl.java 578B
共 183 条
- 1
- 2
资源评论
z同学的编程之路
- 粉丝: 1808
- 资源: 2129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功