结构
代码展示
Book类代码
package com.xszx.beans;
//实体类
public class Book {
private int id;
private String name;
private int bsum;
public Book() {
}
public Book(int id, String name, int bsum) {
this.id = id;
this.name = name;
this.bsum = bsum;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBsum() {
return bsum;
}
public void setBsum(int bsum) {
this.bsum = bsum;
}
@Override
public String toString() {
return "Book{" +
"id=" + id +
", name='" + name + '\'' +
", bsum=" + bsum +
'}';
}
}
Jbook类代码
package com.xszx.beans;
import java.util.Date;
public class Jbook {
private int id;
private int uid;//用户id
private int bid;//书籍id
private Date jdate;//借书日期
private Date hdate;//换书日期
public Jbook() {
}
public Jbook(int id, int uid, int bid, Date jdate, Date hdate) {
this.id = id;
this.uid = uid;
this.bid = bid;
this.jdate = jdate;
this.hdate = hdate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getBid() {
return bid;
}
public void setBid(int bid) {
this.bid = bid;
}
public Date getJdate() {
return jdate;
}
public void setJdate(Date jdate) {
this.jdate = jdate;
}
public Date getHdate() {
return hdate;
}
public void setHdate(Date hdate) {
this.hdate = hdate;
}
@Override
public String toString() {
return "Jbook{" +
"id=" + id +
", uid=" + uid +
", bid=" + bid +
", jdate=" + jdate +
", hdate=" + hdate +
'}';
}
}
User类代码
package com.xszx.beans;
public class User {
private int id;
private String username;
private String password;
private int role;//1为管理员 2为会员
public User() {
}
public User(int id, String username, String password) {
this.id = id;
this.username = username;
this.password = password;
}
public User(int id, String username, String password, int role) {
this.id = id;
this.username = username;
this.password = password;
this.role = role;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", username='" + username + '\'' +
", password='" + password + '\'' +
", role=" + role +
'}';
}
}
BookController类代码
package com.xszx.controller;
import com.xszx.beans.Book;
import com.xszx.beans.Jbook;
import com.xszx.beans.User;
import com.xszx.service.BookService;
import com.xszx.service.JbookService;
import com.xszx.service.impl.BookServiceImpl;
import com.xszx.service.impl.JbookServiceImpl;
import java.util.List;
import java.util.Scanner;
//控制层 控制请求转发
public class BookController {
Scanner sc=new Scanner(System.in);
BookService bookService = new BookServiceImpl();
JbookService jbookService = new JbookServiceImpl();
//主方法管理员界面
public void menu(User user){
System.out.println();
System.out.println(" ---小张图书管理系统--- " +
" ");
System.out.println("***【1】查看图书列表 【2】添加图书 【3】修改图书 " +
"【4】删除图书 【0】返回上一级***");
System.out.println("请选择您要进行的操作:");
int n = sc.nextInt();
if(n==1){
checkBook();
menu(null);
}else if (n==2){
addBook();
menu(null);
}else if(n==3){
alterBook();
menu(null);
}else if (n==4){
deleteBook();
menu(null);
}else if(n==0){
new UserController().menu(user);
}else {
System.out.println("输入错误,请重新输入!");
menu(null);
}
}
//用户界面
public void usermenu(User user){
User user1 = user;
System.out.println();
System.out.println(" ---小张图书系统--- " +
" ");
System.out.println("***【1】查看图书列表 【2】借书 【3】还书 " +
"【4】查看借书记录 【0】返回上一级***");
System.out.println("请选择您要进行的操作:");
int n = sc.nextInt();
if(n==1){
checkBook();
usermenu(user1);
}else if (n==2){
borrowBook(user1);
usermenu(user1);
}else if(n==3){
returnBook(user1);
usermenu(user1);
}else if (n==4){
jmenu(user1);
}else if(n==0){
new UserController().menu(user1);
}else{
System.out.println("输入错误,请重新输入!");
usermenu(user1);
}
}
public void jmenu(User user){
User user1 = user;
System.out.println();
System.out.println(" ---借书记录---" +
" ");
System.out.println("***【1】查看所有 【2】查看已归还的借书记录 " +
"【3】查看未归还的借书记录 【0】返回上一级***");
System.out.println("请选择您要进行的操作:");
int n = sc.nextInt();
if(n==1){
checkJbook(user1);
jmenu(user1);
}else if (n==2){
checkHbook(user1);
jmenu(user1);
}else if(n==3){
checkWHbook(user1);
jmenu(user1);
}else if (n==0){
usermenu(user1);
}else{
System.out.println("输入错误,请重新输入!");
jmenu(user1);
}
}
private void checkWHbook(User user) {
List<Jbook> jbookList = jbookService.checkWHbook(user);
for (Jbook jbook : jbookList){
System.out.println(jbo
标签:String,管理系统,--,user1,System,public,int,JavaSE,id
From: https://blog.csdn.net/weixin_68489989/article/details/140376321