图书管理系统——service层
service.java
1 import java.util.ArrayList; 2 import java.util.List; 3 4 import bean.dao; 5 import bean.Book; 6 7 public class Service { 8 static dao dao=new dao(); 9 public static Boolean add(Book activity) { 10 if(dao.findNameBook(activity.getNameBook())==true) { 11 System.out.print("已存在"); 12 return false; 13 } 14 else{ 15 dao.add(activity); 16 return true; 17 } 18 } 19 20 public static Boolean jieyue(Book activity) { 21 if(dao.findNameBook(activity.getNameBook())==true) { 22 System.out.print("已存在"); 23 Book book=new Book(); 24 book.setNumber(activity.getNumber()); 25 return false; 26 } 27 else{ 28 dao.add(activity); 29 return true; 30 } 31 } 32 33 public static ArrayList<Book> search(Book activity) { 34 if(dao.findNameBook(activity.getNameBook())==true) { 35 ArrayList<Book> activity1=dao.select(activity.getNameBook()); 36 //System.out.print(course1.getClassroom()+" "+course1.getName()+" "+course1.getTeacher()); 37 return activity1; 38 } 39 else { 40 System.out.print("未找到"); 41 return null; 42 } 43 44 } 45 public static List<Book> list() { 46 return dao.getAllinformation(); 47 } 48 }
serviceindex.java
1 import java.util.ArrayList; 2 import java.util.List; 3 4 import bean.dao; 5 import bean.Book; 6 7 public class Service { 8 static dao dao=new dao(); 9 public static Boolean add(Book activity) { 10 if(dao.findNameBook(activity.getNameBook())==true) { 11 System.out.print("已存在"); 12 return false; 13 } 14 else{ 15 dao.add(activity); 16 return true; 17 } 18 } 19 20 public static Boolean jieyue(Book activity) { 21 if(dao.findNameBook(activity.getNameBook())==true) { 22 System.out.print("已存在"); 23 Book book=new Book(); 24 book.setNumber(activity.getNumber()); 25 return false; 26 } 27 else{ 28 dao.add(activity); 29 return true; 30 } 31 } 32 33 public static ArrayList<Book> search(Book activity) { 34 if(dao.findNameBook(activity.getNameBook())==true) { 35 ArrayList<Book> activity1=dao.select(activity.getNameBook()); 36 //System.out.print(course1.getClassroom()+" "+course1.getName()+" "+course1.getTeacher()); 37 return activity1; 38 } 39 else { 40 System.out.print("未找到"); 41 return null; 42 } 43 44 } 45 public static List<Book> list() { 46 return dao.getAllinformation(); 47 } 48 }
servicepeople.java
1 import java.util.ArrayList; 2 import java.util.List; 3 4 import bean.daopeople; 5 import bean.studentInfo; 6 7 public class Servicepeople { 8 static daopeople daopeople=new daopeople(); 9 public static Boolean add(studentInfo activity) { 10 if(daopeople.findNamepeople(activity.getName())==true) { 11 System.out.print("已存在"); 12 return false; 13 } 14 else{ 15 daopeople.add(activity); 16 return true; 17 } 18 } 19 20 public static ArrayList<studentInfo> search(studentInfo activity) { 21 if(daopeople.findNamepeople(activity.getName())==true) { 22 ArrayList<studentInfo> activity1=daopeople.select(activity.getName()); 23 //System.out.print(course1.getClassroom()+" "+course1.getName()+" "+course1.getTeacher()); 24 return activity1; 25 } 26 else { 27 System.out.print("未找到"); 28 return null; 29 } 30 31 } 32 public static List<studentInfo> list() { 33 return daopeople.getAllinformation(); 34 } 35 }
明天计划
明天练习servlet层