Skip to content

Commit

Permalink
modified as mybatis
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghuanhao committed Feb 13, 2019
1 parent 8171ff8 commit 2023516
Show file tree
Hide file tree
Showing 47 changed files with 1,616 additions and 1,648 deletions.
15 changes: 13 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.library</groupId>
<artifactId>library</artifactId>
<version>1.0</version>
<version>1.1</version>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -47,7 +47,6 @@
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
Expand All @@ -68,6 +67,18 @@
<artifactId>jackson-databind</artifactId>
<version>2.8.11.3</version>
</dependency>
<!--mybatis-spring适配器 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<!-- mybatis ORM框架 -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.library.domain;
package com.library.bean;

public class Admin {

private long adminId;
private long admin_id;
private String password;
private String username;

public long getAdminId() {
return adminId;
return admin_id;
}

public void setAdminId(long adminId) {
this.adminId = adminId;
public void setAdminId(long admin_id) {
this.admin_id = admin_id;
}

public String getPassword() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package com.library.domain;
package com.library.bean;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

public class Book implements Serializable {

private long bookId;
private long book_id;
private String name;
private String author;
private String publish;
private String isbn;
private String ISBN;
private String introduction;
private String language;
private BigDecimal price;
private Date pubdate;
private int classId;
private Date pub_date;
private int class_id;
private int number;

public long getBookId() {
return bookId;
return book_id;
}

public void setBookId(long bookId) {
this.bookId = bookId;
public void setBookId(long book_id) {
this.book_id = book_id;
}

public String getName() {
Expand Down Expand Up @@ -51,11 +51,11 @@ public void setPublish(String publish) {
}

public String getIsbn() {
return isbn;
return ISBN;
}

public void setIsbn(String isbn) {
this.isbn = isbn;
this.ISBN = isbn;
}

public String getIntroduction() {
Expand Down Expand Up @@ -83,19 +83,19 @@ public void setPrice(BigDecimal price) {
}

public Date getPubdate() {
return pubdate;
return pub_date;
}

public void setPubdate(Date pubdate) {
this.pubdate = pubdate;
public void setPubdate(Date pub_date) {
this.pub_date = pub_date;
}

public int getClassId() {
return classId;
return class_id;
}

public void setClassId(int classId) {
this.classId = classId;
public void setClassId(int class_id) {
this.class_id = class_id;
}

public int getNumber() {
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/com/library/bean/Lend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.library.bean;

import java.io.Serializable;
import java.util.Date;

public class Lend implements Serializable {

private long ser_num;
private long book_id;
private long reader_id;
private Date lend_date;
private Date back_date;

public long getReaderId() {
return reader_id;
}

public void setReaderId(long reader_id) {
this.reader_id = reader_id;
}

public long getBookId() {
return book_id;
}

public void setBookId(long book_id) {
this.book_id = book_id;
}

public void setSer_num(long ser_num) {
this.ser_num = ser_num;
}

public Date getBackDate() {
return back_date;
}

public void setBackDate(Date back_date) {
this.back_date = back_date;
}

public Date getLendDate() {
return lend_date;
}

public void setLendDate(Date lend_date) {
this.lend_date = lend_date;
}

public long getSer_num() {
return ser_num;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package com.library.domain;
package com.library.bean;

import java.io.Serializable;

public class ReaderCard implements Serializable {

private long readerId;
private String name;
private long reader_id;
private String username;
private String password;

public long getReaderId() {
return readerId;
return reader_id;
}

public void setReaderId(long readerId) {
this.readerId = readerId;
public void setReaderId(long reader_id) {
this.reader_id = reader_id;
}

public String getName() {
return name;
return username;
}

public void setName(String name) {
this.name = name;
public void setName(String username) {
this.username = username;
}

public String getPassword() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.library.domain;
package com.library.bean;

import java.io.Serializable;
import java.util.Date;

public class ReaderInfo implements Serializable {

private long readerId;
private long reader_id;
private String name;
private String sex;
private Date birth;
private String address;
private String phone;

public long getReaderId() {
return readerId;
return reader_id;
}

public void setReaderId(long readerId) {
this.readerId = readerId;
public void setReaderId(long reader_id) {
this.reader_id = reader_id;
}

public String getName() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.library.web;
package com.library.controller;

import com.library.domain.Book;
import com.library.domain.Lend;
import com.library.domain.ReaderCard;
import com.library.bean.Book;
import com.library.bean.Lend;
import com.library.bean.ReaderCard;
import com.library.service.BookService;
import com.library.service.LendService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -85,7 +85,7 @@ public String addBookDo(@RequestParam(value = "pubstr") String pubstr, Book book

@RequestMapping("/updatebook.html")
public ModelAndView bookEdit(HttpServletRequest request) {
long bookId = Integer.parseInt(request.getParameter("bookId"));
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("admin_book_edit");
modelAndView.addObject("detail", book);
Expand All @@ -103,18 +103,18 @@ public String bookEditDo(@RequestParam(value = "pubstr") String pubstr, Book boo
return "redirect:/admin_books.html";
}

@RequestMapping("/bookdetail.html")
public ModelAndView bookDetail(HttpServletRequest request) {
long bookId = Integer.parseInt(request.getParameter("bookId"));
@RequestMapping("/admin_book_detail.html")
public ModelAndView adminBookDetail(HttpServletRequest request) {
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("admin_book_detail");
modelAndView.addObject("detail", book);
return modelAndView;
}

@RequestMapping("/readerbookdetail.html")
@RequestMapping("/reader_book_detail.html")
public ModelAndView readerBookDetail(HttpServletRequest request) {
long bookId = Integer.parseInt(request.getParameter("bookId"));
long bookId = Long.parseLong(request.getParameter("bookId"));
Book book = bookService.getBook(bookId);
ModelAndView modelAndView = new ModelAndView("reader_book_detail");
modelAndView.addObject("detail", book);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.library.web;
package com.library.controller;

import com.library.domain.ReaderCard;
import com.library.bean.ReaderCard;
import com.library.service.BookService;
import com.library.service.LendService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -27,7 +27,7 @@ public String deleteBook(HttpServletRequest request, RedirectAttributes redirect
} else {
redirectAttributes.addFlashAttribute("error", "图书删除失败!");
}
return "redirect:/allbooks.html";
return "redirect:/admin_books.html";
}

@RequestMapping("/lendlist.html")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.library.web;
package com.library.controller;

import com.library.domain.Admin;
import com.library.domain.ReaderCard;
import com.library.bean.Admin;
import com.library.bean.ReaderCard;
import com.library.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -73,7 +73,6 @@ Object loginCheck(HttpServletRequest request) {

@RequestMapping("/admin_main.html")
public ModelAndView toAdminMain(HttpServletResponse response) {

return new ModelAndView("admin_main");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.library.web;
package com.library.controller;

import com.library.domain.ReaderCard;
import com.library.domain.ReaderInfo;
import com.library.bean.ReaderCard;
import com.library.bean.ReaderInfo;
import com.library.service.LoginService;
import com.library.service.ReaderCardService;
import com.library.service.ReaderInfoService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.library.web;
package com.library.controller;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -12,7 +12,7 @@

@Configuration
@EnableWebMvc
@ComponentScan("com.library.web")
@ComponentScan("com.library.controller")
public class WebConfig extends WebMvcConfigurerAdapter {

@Bean
Expand Down
Loading

0 comments on commit 2023516

Please sign in to comment.