diff --git a/README.md b/README.md
index 88d169d658623a0f1c55a796a54b07aacd072f8e..4eaaf96f1de7a24f7688bed4500a111b09a93c88 100644
--- a/README.md
+++ b/README.md
@@ -44,11 +44,30 @@
### 工程架构说明
#### 后端架构
1. DAO
+<<<<<<< HEAD
+
+=======
+>>>>>>> master
> 负责与数据库交互等
2. Controller
> 提供Http Api接口,与前端Ajax对接
* Servlet
+<<<<<<< HEAD
+
+ > Servlet写到这个包里
+ * Filter
+
+ > 请求过滤,负责权限验证,编码修改等
+3. Service
+
+ > 业务逻辑,负责DAO层与Controller层的逻辑交互
+4. Util
+
+ > 工具包,将常用代码封装,提高代码复用性
+5. Bean
+
+=======
> Servlet写到这个包里
* Filter
@@ -62,6 +81,7 @@
> 工具包,将常用代码封装,提高代码复用性
5. Bean
+>>>>>>> master
> Java数据对象
#### 前端架构
diff --git a/Test/prtest b/Test/prtest
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/backend/.idea/uiDesigner.xml b/backend/.idea/uiDesigner.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e96534fb27b68192f27f985d3879e173ec77adb8
--- /dev/null
+++ b/backend/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/backend/pom.xml b/backend/pom.xml
index af7d17cd7e0e1ee24ca7d40266ba687b9f78a044..b17de6469a5a432becde6b1988bc476d002fcde7 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -51,7 +51,7 @@
junit
junit
4.13.2
- test
+
diff --git a/backend/src/main/java/bean/user/UserRegBean.java b/backend/src/main/java/bean/user/UserRegBean.java
new file mode 100644
index 0000000000000000000000000000000000000000..0516d9815507473cd92ca42887408a9e5129ce3f
--- /dev/null
+++ b/backend/src/main/java/bean/user/UserRegBean.java
@@ -0,0 +1,16 @@
+package bean.user;
+
+import lombok.Getter;
+import lombok.Setter;
+
+//Lombok库基操,快捷添加Getter,Setter
+@Getter
+@Setter
+public class UserRegBean {
+ //用户名
+ String username;
+ //密码
+ String passwd;
+ //用户类型
+ int userType;
+}
diff --git a/backend/src/main/java/controller/servlet/TestServlet.java b/backend/src/main/java/controller/servlet/TestServlet.java
index 68734bbebfa40d72c67d78a656dcb8e790c8e34e..eb230060c96cad1e42713a895d0d4704ae3992da 100644
--- a/backend/src/main/java/controller/servlet/TestServlet.java
+++ b/backend/src/main/java/controller/servlet/TestServlet.java
@@ -1,5 +1,7 @@
package controller.servlet;
+import util.JDBCUtil;
+
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
diff --git a/backend/src/main/java/dao/UserDao.java b/backend/src/main/java/dao/UserDao.java
new file mode 100644
index 0000000000000000000000000000000000000000..9aa3067fb309141f34b33b8d8343ba52a46392de
--- /dev/null
+++ b/backend/src/main/java/dao/UserDao.java
@@ -0,0 +1,12 @@
+package dao;
+
+import bean.user.UserRegBean;
+
+public interface UserDao {
+ /**
+ * 注册用户
+ */
+ void doRegisterUser(UserRegBean userRegBean);
+
+ String doUserlogin(String keyword, String passwd);
+}
diff --git a/backend/src/main/java/dao/UserDaoImpl.java b/backend/src/main/java/dao/UserDaoImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..a0d5b96a51c1128acf4eaf008bdc51ed0d13c3f6
--- /dev/null
+++ b/backend/src/main/java/dao/UserDaoImpl.java
@@ -0,0 +1,31 @@
+package dao;
+
+import bean.user.UserRegBean;
+import util.JDBCUtil;
+import util.SQLOperation;
+
+public class UserDaoImpl implements UserDao {
+ @Override
+ public void doRegisterUser(UserRegBean userRegBean) {
+ //获取数据库连接
+ JDBCUtil.getInstance().getConnection(connection -> {
+ //实例化SQL操作类
+ SQLOperation operation = new SQLOperation(connection);
+ //设置SQL语句
+ operation.setSql("INSERT INTO t_user (username,passwd,usertype,regtime) VALUES(?,?,?,now())");
+ //将变量填入上述SQL语句中的问号占位符
+ operation.prepareArgs(
+ userRegBean.getUsername(),
+ userRegBean.getPasswd(),
+ userRegBean.getUserType()
+ );
+ //执行更新操作
+ operation.excuteUpdate();
+ });
+ }
+
+ @Override
+ public String doUserlogin(String keyword, String passwd) {
+ return null;
+ }
+}
diff --git a/backend/src/main/java/util/JDBCUtil.java b/backend/src/main/java/util/JDBCUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..e1e66a64e600035442e85a79ba52211a5e604d3e
--- /dev/null
+++ b/backend/src/main/java/util/JDBCUtil.java
@@ -0,0 +1,51 @@
+package util;
+
+import com.alibaba.druid.pool.DruidDataSourceFactory;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.function.Consumer;
+
+/**
+ * 封装数据库连接
+ */
+public class JDBCUtil {
+ private static final JDBCUtil instance = new JDBCUtil();
+ DataSource dataSource;
+
+ //设计模式中的单例模式
+ public static JDBCUtil getInstance() {
+ return instance;
+ }
+
+ //数据库连接池初始化,使用阿里巴巴Druid连接池
+ private JDBCUtil() {
+ try {
+ Properties prop = new Properties();
+ prop.load(getClass().getResourceAsStream("/druid.properties"));
+ dataSource = DruidDataSourceFactory.createDataSource(prop);
+ System.out.println("数据库连接池初始化...");
+ } catch (Exception e) {
+ System.err.println("数据库连接池初始化异常!!!");
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 获取数据库连接并自动关闭连接
+ *
+ * @param callback 回调Lambda函数,在Lambda函数中编写逻辑
+ */
+ public void getConnection(Consumer callback) {
+ try {
+ Connection conn = dataSource.getConnection();
+ callback.accept(conn);
+ conn.close();
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+
+}
diff --git a/backend/src/main/java/util/SQLOperation.java b/backend/src/main/java/util/SQLOperation.java
new file mode 100644
index 0000000000000000000000000000000000000000..95de17c38e82082b5e0a8a408f4a7249b59f0b43
--- /dev/null
+++ b/backend/src/main/java/util/SQLOperation.java
@@ -0,0 +1,102 @@
+package util;
+
+import java.sql.*;
+import java.util.*;
+
+/**
+ * 封装数据库的增删改查操作
+ */
+public class SQLOperation {
+ private String sql;
+ private Connection conn;
+ private PreparedStatement statement;
+
+ /**
+ * @param conn 数据库连接
+ * @param sql SQL语句
+ */
+ public SQLOperation(Connection conn, String sql) {
+ this.conn = conn;
+ this.sql = sql;
+ getStatement();
+ }
+
+ /**
+ * @param conn 数据库连接
+ */
+ public SQLOperation(Connection conn) {
+ this.conn = conn;
+ }
+
+ /**
+ * 设置SQL语句
+ *
+ * @param sql 需要执行的SQL语句
+ */
+ public void setSql(String sql) {
+ this.sql = sql;
+ getStatement();
+ }
+
+ private void getStatement() {
+ try {
+ statement = conn.prepareStatement(sql);
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+
+ /**
+ * 将参数装进SQL语句中
+ *
+ * @param args 需要填入SQL语句中的参数
+ */
+ public void prepareArgs(Object... args) {
+ try {
+ for (int i = 0; i < args.length; i++) {
+ statement.setObject(i + 1, args[i]);
+ }
+ } catch (SQLException throwables) {
+ throwables.printStackTrace();
+ }
+ }
+
+ /**
+ * 执行查询语句
+ *
+ * @return 返回包含字典的查询列表
+ */
+ public List