From 600c8939c3588104b849740ab7bdbeab5171bc14 Mon Sep 17 00:00:00 2001 From: koe7 <*******@163.com> Date: Fri, 17 Jun 2022 10:30:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BA=95=E5=B1=82=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../底层代码/bean/Ingredient.java | 89 +++++++++++++ 程序代码/底层代码/bean/Menu.java | 122 ++++++++++++++++++ 程序代码/底层代码/bean/User.java | 103 +++++++++++++++ 程序代码/底层代码/util/DBUtil.java | 76 +++++++++++ 4 files changed, 390 insertions(+) create mode 100644 程序代码/底层代码/bean/Ingredient.java create mode 100644 程序代码/底层代码/bean/Menu.java create mode 100644 程序代码/底层代码/bean/User.java create mode 100644 程序代码/底层代码/util/DBUtil.java diff --git a/程序代码/底层代码/bean/Ingredient.java b/程序代码/底层代码/bean/Ingredient.java new file mode 100644 index 0000000..18f1a50 --- /dev/null +++ b/程序代码/底层代码/bean/Ingredient.java @@ -0,0 +1,89 @@ +package bean; + +/** + * @Description + * @Author koe + * @Data 2022/6/15 15:35 + */ + +public class Ingredient { + private String ingreName; + private Integer ingreId; + private String ingreAdd; + private String ingreAttr; + private String ingrePut; + private Double ingrePrice; + + public Ingredient() { + } + + public Ingredient(String ingreName, Integer ingreId, String ingreAdd, + String ingreAttr, String ingrePut, Double ingrePrice) { + this.ingreName = ingreName; + this.ingreId = ingreId; + this.ingreAdd = ingreAdd; + this.ingreAttr = ingreAttr; + this.ingrePut = ingrePut; + this.ingrePrice = ingrePrice; + } + + public String getIngreName() { + return ingreName; + } + + public void setIngreName(String ingreName) { + this.ingreName = ingreName; + } + + public Integer getIngreId() { + return ingreId; + } + + public void setIngreId(Integer ingreId) { + this.ingreId = ingreId; + } + + public String getIngreAdd() { + return ingreAdd; + } + + public void setIngreAdd(String ingreAdd) { + this.ingreAdd = ingreAdd; + } + + public String getIngreAttr() { + return ingreAttr; + } + + public void setIngreAttr(String ingreAttr) { + this.ingreAttr = ingreAttr; + } + + public String getIngrePut() { + return ingrePut; + } + + public void setIngrePut(String ingrePut) { + this.ingrePut = ingrePut; + } + + public Double getIngrePrice() { + return ingrePrice; + } + + public void setIngrePrice(Double ingrePrice) { + this.ingrePrice = ingrePrice; + } + + @Override + public String toString() { + return "Ingredient{" + + "ingreName='" + ingreName + '\'' + + ", ingreId=" + ingreId + + ", ingreAdd='" + ingreAdd + '\'' + + ", ingreAttr='" + ingreAttr + '\'' + + ", ingrePut='" + ingrePut + '\'' + + ", ingrePrice=" + ingrePrice + + '}'; + } +} diff --git a/程序代码/底层代码/bean/Menu.java b/程序代码/底层代码/bean/Menu.java new file mode 100644 index 0000000..4920483 --- /dev/null +++ b/程序代码/底层代码/bean/Menu.java @@ -0,0 +1,122 @@ +package bean; + +/** + * @Description + * @Author koe + * @Data 2022/6/15 15:26 + */ + +public class Menu { + private String menuName; + private Integer menuId; + private String menuEle; + private String menuTaste; + private String menuCuis; + private String menuBrief; + private Integer menuLevel; + private String menuPut; + private double menuPrice; + + public Menu() { + } + + public Menu(String menuName, Integer menuId, String menuEle, String menuTaste, + String menuCuis, String menuBrief, Integer menuLevel, String menuPut, double menuPrice) { + this.menuName = menuName; + this.menuId = menuId; + this.menuEle = menuEle; + this.menuTaste = menuTaste; + this.menuCuis = menuCuis; + this.menuBrief = menuBrief; + this.menuLevel = menuLevel; + this.menuPut = menuPut; + this.menuPrice = menuPrice; + } + + public String getMenuName() { + return menuName; + } + + public void setMenuName(String menuName) { + this.menuName = menuName; + } + + public Integer getMenuId() { + return menuId; + } + + public void setMenuId(Integer menuId) { + this.menuId = menuId; + } + + public String getMenuEle() { + return menuEle; + } + + public void setMenuEle(String menuEle) { + this.menuEle = menuEle; + } + + public String getMenuTaste() { + return menuTaste; + } + + public void setMenuTaste(String menuTaste) { + this.menuTaste = menuTaste; + } + + public String getMenuCuis() { + return menuCuis; + } + + public void setMenuCuis(String menuCuis) { + this.menuCuis = menuCuis; + } + + public String getMenuBrief() { + return menuBrief; + } + + public void setMenuBrief(String menuBrief) { + this.menuBrief = menuBrief; + } + + public Integer getMenuLevel() { + return menuLevel; + } + + public void setMenuLevel(Integer menuLevel) { + this.menuLevel = menuLevel; + } + + public String getMenuPut() { + return menuPut; + } + + public void setMenuPut(String menuPut) { + this.menuPut = menuPut; + } + + public double getMenuPrice() { + return menuPrice; + } + + public void setMenuPrice(double menuPrice) { + this.menuPrice = menuPrice; + } + + @Override + public String toString() { + return "Menu{" + + "menuName='" + menuName + '\'' + + ", menuId=" + menuId + + ", menuEle='" + menuEle + '\'' + + ", menuTaste='" + menuTaste + '\'' + + ", menuCuis='" + menuCuis + '\'' + + ", menuBrief='" + menuBrief + '\'' + + ", menuLevel=" + menuLevel + + ", menuPut='" + menuPut + '\'' + + ", menuPrice=" + menuPrice + + '}'; + } +} diff --git a/程序代码/底层代码/bean/User.java b/程序代码/底层代码/bean/User.java new file mode 100644 index 0000000..eb138e3 --- /dev/null +++ b/程序代码/底层代码/bean/User.java @@ -0,0 +1,103 @@ +package bean; + +import java.util.Objects; + +/** + * @Description + * @Author koe + * @Data 2022/6/15 15:01 + */ + +public class User { + private String userId; + private Integer userPwd; + private String userName; + private String userNumb; + private String userLike; + private String userAdd; + private String userGend; + + public User() { + } + + public User(String userId, Integer userPwd, String userName, String userNumb, + String userLike, String userAdd, String userGend) { + this.userId = userId; + this.userPwd = userPwd; + this.userName = userName; + this.userNumb = userNumb; + this.userLike = userLike; + this.userAdd = userAdd; + this.userGend = userGend; + } + + @Override + public String toString() { + return "User{" + + "userId='" + userId + '\'' + + ", userPwd=" + userPwd + + ", userName='" + userName + '\'' + + ", userNumb='" + userNumb + '\'' + + ", userLike='" + userLike + '\'' + + ", userAdd='" + userAdd + '\'' + + ", userGend='" + userGend + '\'' + + '}'; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public int getUserPwd() { + return userPwd; + } + + public void setUserPwd(Integer userPwd) { + this.userPwd = userPwd; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserNumb() { + return userNumb; + } + + public void setUserNumb(String userNumb) { + this.userNumb = userNumb; + } + + public String getUserLike() { + return userLike; + } + + public void setUserLike(String userLike) { + this.userLike = userLike; + } + + public String getUserAdd() { + return userAdd; + } + + public void setUserAdd(String userAdd) { + this.userAdd = userAdd; + } + + public String getUserGend() { + return userGend; + } + + public void setUserGend(String userGend) { + this.userGend = userGend; + } + +} diff --git a/程序代码/底层代码/util/DBUtil.java b/程序代码/底层代码/util/DBUtil.java new file mode 100644 index 0000000..87772cd --- /dev/null +++ b/程序代码/底层代码/util/DBUtil.java @@ -0,0 +1,76 @@ +package util; + +import java.sql.*; + +/** + * @Description + * @Author koe + * @Data 2022/6/15 15:49 + */ + +public class DBUtil { + static String url = "jdbc:mysql://localhost:3306/eatwhat?useUnicode=true&characterEcoding=utf-8"; + // 中文变?问题 ?useUnicode=true&characterEncoding=utf-8 + static String user = "root"; + static String password = "123456"; + + /** + * 加载类库 链接驱动类 + */ + static{ + try { + Class.forName("com.mysql.jdbc.Driver"); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 实例化数据库链接对象 + * @return + */ + public static Connection getConnection(){ + Connection cont = null; + try { + cont = DriverManager.getConnection(url, user, password); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return cont; + } + + /** + * 关闭数据库链接 释放资源 + * @param res 结果指针对象 + * @param pstmt 执行对象 + * @param cont 链接对象 + */ + public static void closeJDBC(ResultSet res, Statement pstmt, Connection cont){ + if(res != null){ + try { + res.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(pstmt != null){ + try { + pstmt.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(cont != null){ + try { + cont.close(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } +}