java毕业项目:基于ssm框架的微信小程序图书管理系统1023

项目描述

基于ssm框架的微信小程序图书管理系统,功能完善。适合练习小程序开发,也可以用作课程设计和毕业设计。
主要功能:首页,图书列表,个人中心 等;

运行环境

jdk8+tomcat8+mysql+IntelliJ IDEA+微信小程序

项目技术

spring+spring mvc+mybatis+微信小程序

项目截图

java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第1张图片
java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第2张图片
java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第3张图片
java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第4张图片
java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第5张图片
java毕业项目:基于ssm框架的微信小程序图书管理系统1023_第6张图片

部分代码(3段)

/**
 * 图书模块controller
 */
 
@RestController
@RequestMapping("/api/book") 
public class ApiBookController {
	@Resource BookService bookService; 
	
	@InitBinder("bookTypeObj")
	public void initBinderbookTypeObj(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("bookTypeObj.");
	}
	
	@InitBinder("book")
	public void initBinderBook(WebDataBinder binder) {
		binder.setFieldDefaultPrefix("book.");
	}
	
	
	/*客户端ajax方式添加图书信息*/
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public JsonResult add(@Validated Book book, BindingResult br, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (br.hasErrors()) //验证输入参数
			return JsonResultBuilder.error(ReturnCode.INPUT_PARAM_ERROR);	 
		if(bookService.getBook(book.getBarcode()) != null) //验证主键是否重复
			return JsonResultBuilder.error(ReturnCode.PRIMARY_EXIST_ERROR);
        bookService.addBook(book); //添加到数据库
        return JsonResultBuilder.ok();
	}
	
	
	/*客户端ajax更新图书信息*/
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public JsonResult update(@Validated Book book, BindingResult br, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception {
		if (br.hasErrors())  //验证输入参数
			return JsonResultBuilder.error(ReturnCode.INPUT_PARAM_ERROR);  
        bookService.updateBook(book);  //更新记录到数据库
        return JsonResultBuilder.ok(bookService.getBook(book.getBarcode()));
         
	}
	 
	
	/*ajax方式显示获取图书详细信息*/
	@RequestMapping(value="/get/{barcode}",method=RequestMethod.POST)
	public JsonResult getBook(@PathVariable String barcode,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
        /*根据主键barcode获取Book对象*/
        Book book = bookService.getBook(barcode); 
        return JsonResultBuilder.ok(book);
	}
	
	
	/*ajax方式删除图书记录*/
	@RequestMapping(value="/delete/{barcode}",method=RequestMethod.POST)
	public JsonResult deleteBook(@PathVariable String barcode,Model model,HttpServletRequest request,HttpServletResponse response) throws Exception {
		bookService.deleteBook(barcode);
        return JsonResultBuilder.ok();
	}
	
	//客户端查询图书信息
	@RequestMapping(value="/list",method=RequestMethod.POST)
	public JsonResult list(String barcode,String bookName,@ModelAttribute("bookTypeObj") BookType bookTypeObj,String publishDate,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception{
		if (page==null || page == 0) page = 1;
		if (barcode == null) barcode = "";
		if (bookName == null) bookName = "";
		if (publishDate == null) publishDate = ""; 
		if(rows != 0)bookService.setRows(rows);
		List<Book> bookList = bookService.queryBook(barcode, bookName, bookTypeObj, publishDate, page);
	    /*计算总的页数和总的记录数*/
	    bookService.queryTotalPageAndRecordNumber(barcode, bookName, bookTypeObj, publishDate);
	    /*获取到总的页码数目*/
	    int totalPage = bookService.getTotalPage();
	    /*当前查询条件下总记录数*/
	    int recordNumber = bookService.getRecordNumber();
	    
	    HashMap<String, Object> resultMap = new HashMap<String, Object>();
	    resultMap.put("totalPage", totalPage);
	    resultMap.put("list", bookList);
	    
		return JsonResultBuilder.ok(resultMap);
	}
	
	
	
	//客户端查询5本最新出版的图书记录*/
	@RequestMapping(value="/latest_list",method=RequestMethod.POST)
	public JsonResult latestList(String barcode,String bookName,@ModelAttribute("bookTypeObj") BookType bookTypeObj,String publishDate,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		List<Book> bookList = bookService.queryLatestBook(); 
	    HashMap<String, Object> resultMap = new HashMap<String, Object>(); 
	    resultMap.put("list", bookList);
	    
		return JsonResultBuilder.ok(resultMap);
	}
}


/**
 * 图书类型模块controller
 */

@RestController
@RequestMapping("/api/bookType") 
public class ApiBookTypeController {
	
	@Resource BookTypeService bookTypeService;
	
	@RequestMapping(value="/listAll",method=RequestMethod.POST)
	public JsonResult list(String barcode,String bookName,@ModelAttribute("bookTypeObj") BookType bookTypeObj,String publishDate,Integer page,Integer rows, Model model, HttpServletRequest request,HttpServletResponse response) throws Exception{
		List<BookType> bookTypeList = bookTypeService.queryAllBookType(); 
		return JsonResultBuilder.ok(bookTypeList);
	}
}

数据库
DROP TABLE IF EXISTS `t_book`;
CREATE TABLE `t_book`  (
  `barcode` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'barcode',
  `bookName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '图书名称',
  `bookTypeObj` int(11) NOT NULL COMMENT '图书所在类别',
  `price` float NOT NULL COMMENT '图书价格',
  `count` int(11) NOT NULL COMMENT '库存',
  `publishDate` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '出版日期',
  `publish` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '出版社',
  `bookDesc` varchar(800) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '图书简介',
  PRIMARY KEY (`barcode`) USING BTREE,
  INDEX `bookTypeObj`(`bookTypeObj`) USING BTREE,
  CONSTRAINT `t_book_ibfk_1` FOREIGN KEY (`bookTypeObj`) REFERENCES `t_booktype` (`bookTypeId`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Records of t_book
-- ----------------------------
INSERT INTO `t_book` VALUES ('19971010', 'spring', 4, 13, 15, '2018-11-04', '替代servlet', '大大简便!!');
INSERT INTO `t_book` VALUES ('19980206', 'jQuery开发', 5, 55, 55, '2019-11-04', '我的出版社', '前端开发必备基础!!');
INSERT INTO `t_book` VALUES ('19990303', '墨刀工具', 3, 42, 100, '2020-11-05', '墨刀出版社', '墨刀很强大!!');
INSERT INTO `t_book` VALUES ('19990316', 'vue.js', 5, 35, 99, '2018-11-04', '上海出版社', 'vue.js简单快速!!');
INSERT INTO `t_book` VALUES ('19990317', 'Java的文件操作', 4, 50, 120, '2018-11-03', '北京出版社', 'Java基础操作,基础又重要。');
INSERT INTO `t_book` VALUES ('20001212', 'ps进阶', 3, 56, 100, '2020-09-03', '清华出版社', 'ps很强大!!!!');
INSERT INTO `t_book` VALUES ('20120916', 'mybatis', 4, 56, 100, '2017-11-04', '傻瓜出版社', '操作数据库');
INSERT INTO `t_book` VALUES ('20151212', 'pr', 3, 12, 12, '2018-11-05', '素材出版社', 'pr视频很重要');

-- ----------------------------
-- Table structure for t_booktype
-- ----------------------------
DROP TABLE IF EXISTS `t_booktype`;
CREATE TABLE `t_booktype`  (
  `bookTypeId` int(11) NOT NULL AUTO_INCREMENT COMMENT '图书类别',
  `bookTypeName` varchar(18) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '类别名称',
  `days` int(11) NOT NULL COMMENT '可借阅天数',
  PRIMARY KEY (`bookTypeId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;

-- ----------------------------
-- Records of t_booktype
-- ----------------------------
INSERT INTO `t_booktype` VALUES (3, 'UI/UE', 90);
INSERT INTO `t_booktype` VALUES (4, 'Java', 90);
INSERT INTO `t_booktype` VALUES (5, '前端', 90);

SET FOREIGN_KEY_CHECKS = 1;


源码地址

链接:https://pan.baidu.com/s/1NzJGdSPrq_zyhkfOutur4w?pwd=0b4o
提取码:0b4o

你可能感兴趣的:(java毕业设计实战,java,微信小程序,开发语言)