diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/Others/sql/flashsale.sql b/Others/sql/flashsale.sql
index 2b2cbc3..f39117c 100644
--- a/Others/sql/flashsale.sql
+++ b/Others/sql/flashsale.sql
@@ -11,7 +11,7 @@
Target Server Version : 50726
File Encoding : 65001
- Date: 01/03/2022 15:16:20
+ Date: 01/03/2022 17:01:05
*/
SET NAMES utf8mb4;
@@ -35,7 +35,7 @@ CREATE TABLE `user_info` (
-- ----------------------------
-- Records of user_info
-- ----------------------------
-INSERT INTO `user_info` VALUES (1, '第一个用户', 2, 18, '110', 'phone', '');
+INSERT INTO `user_info` VALUES (1, 'admin', 2, 18, '110', 'phone', '');
-- ----------------------------
-- Table structure for user_password
@@ -53,5 +53,6 @@ CREATE TABLE `user_password` (
-- ----------------------------
-- Records of user_password
-- ----------------------------
+INSERT INTO `user_password` VALUES (1, '21232f297a57a5a743894a0e4a801fc3', 1);
SET FOREIGN_KEY_CHECKS = 1;
diff --git a/README.md b/README.md
index 016fedc..225c0db 100644
--- a/README.md
+++ b/README.md
@@ -6,4 +6,32 @@
数据库版本:MySQL 5.7
-项目数据库文件:[点击打开](./Others/sql/flashsale.sql)
\ No newline at end of file
+项目数据库文件:[点击打开](./Others/sql/flashsale.sql)
+
+### 默认用户
+
+> 用户名密码均为 `admin`
+
+### 本次修改通过以下方式查看👇
+
+> http://localhost:8090/user/get?id=1
+
+### 层次结构(以User为例,自上向下)
+
+| | 目录 | Java对象类型 | 说明 | 举例 |
+| ----------------------------- |-----------------------| ----------------- | ----------------------- | -------------------------------- |
+| **Controller层** | | | | |
+| Controller | controller | 类 class | | controller.UserController |
+| Controller | controller/viewobject | 类 class | | controller.UserController |
+| | | | | |
+| **Service层** | 转换成业务模型 | | | |
+| Service | service | 接口 interface | | service.UserService |
+| ServiceImpl | service/impl | Service接口实现类 | 将DataObject组装成Model | service.impl.UserServiceImpl |
+| Model | service/model | 类 class | 用户模型Model | service.model.UserModel |
+| | | | | |
+| **Dao层** | 对数据库的映射 | | | |
+| Mapper | dao | 接口 interface | | dao.UserDataObjectMapper |
+| Mapping | resources/mapping | Mapper接口实现类 | xml格式;SQL语句 | mapping/UserDataObjectMapper.xml |
+| Data Object | dataobject | 类 class | | dataobject.UserDataObject |
+
+**Tips:** Model与Data Object并非完全一一对应,例如UserModel是由ServiceImpl将UserDataObject和UserPasswordDataObject组装而成的。
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/App.java b/src/main/java/com/cxyxiaomo/flashsale/App.java
index 74afb16..0d0bc68 100644
--- a/src/main/java/com/cxyxiaomo/flashsale/App.java
+++ b/src/main/java/com/cxyxiaomo/flashsale/App.java
@@ -1,11 +1,10 @@
package com.cxyxiaomo.flashsale;
-import com.cxyxiaomo.flashsale.dao.userDataObjectMapper;
-import com.cxyxiaomo.flashsale.dataobject.userDataObject;
+import com.cxyxiaomo.flashsale.dao.UserDataObjectMapper;
+import com.cxyxiaomo.flashsale.dataobject.UserDataObject;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -20,12 +19,12 @@ import org.springframework.web.bind.annotation.RestController;
public class App {
@Autowired
- private userDataObjectMapper userDOMapper;
+ private UserDataObjectMapper userDOMapper;
@RequestMapping("/")
public String home() {
- userDataObject userDO = userDOMapper.selectByPrimaryKey(1);
+ UserDataObject userDO = userDOMapper.selectByPrimaryKey(1);
if (userDO == null) {
return "用户对象不存在!";
} else {
diff --git a/src/main/java/com/cxyxiaomo/flashsale/controller/UserController.java b/src/main/java/com/cxyxiaomo/flashsale/controller/UserController.java
new file mode 100644
index 0000000..030c1c3
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/controller/UserController.java
@@ -0,0 +1,26 @@
+package com.cxyxiaomo.flashsale.controller;
+
+import com.cxyxiaomo.flashsale.service.UserService;
+import com.cxyxiaomo.flashsale.service.model.UserModel;
+import org.apache.catalina.User;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller("user") // 允许被SpringBoot扫描到
+@RequestMapping("/user") // 通过 "/user" 访问到
+public class UserController {
+
+ @Autowired
+ private UserService userService;
+
+ @RequestMapping("/get")
+ @ResponseBody
+ public UserModel getUser(@RequestParam(name = "id") Integer id) {
+ // 调用Services服务获取对应id的用户对象并返回给前端
+ UserModel userModel = userService.getUserById(id);
+ return userModel;
+ }
+}
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dao/UserDOMapper.java b/src/main/java/com/cxyxiaomo/flashsale/dao/UserDOMapper.java
new file mode 100644
index 0000000..1d642ee
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/dao/UserDOMapper.java
@@ -0,0 +1,53 @@
+package com.cxyxiaomo.flashsale.dao;
+
+import com.cxyxiaomo.flashsale.dataobject.UserDO;
+
+public interface UserDataObjectMapper {
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int deleteByPrimaryKey(Integer id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int insert(UserDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int insertSelective(UserDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ UserDO selectByPrimaryKey(Integer id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int updateByPrimaryKeySelective(UserDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_info
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int updateByPrimaryKey(UserDO record);
+}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dao/UserPasswordDOMapper.java b/src/main/java/com/cxyxiaomo/flashsale/dao/UserPasswordDOMapper.java
new file mode 100644
index 0000000..9e1c2d2
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/dao/UserPasswordDOMapper.java
@@ -0,0 +1,55 @@
+package com.cxyxiaomo.flashsale.dao;
+
+import com.cxyxiaomo.flashsale.dataobject.UserPasswordDO;
+
+public interface UserPasswordDataObjectMapper {
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int deleteByPrimaryKey(Integer id);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int insert(UserPasswordDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int insertSelective(UserPasswordDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ UserPasswordDO selectByPrimaryKey(Integer id);
+
+ UserPasswordDO selectByUserId(Integer userId);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int updateByPrimaryKeySelective(UserPasswordDO record);
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method corresponds to the database table user_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ int updateByPrimaryKey(UserPasswordDO record);
+}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dao/userDataObjectMapper.java b/src/main/java/com/cxyxiaomo/flashsale/dao/userDataObjectMapper.java
index d61f8e8..19e7066 100644
--- a/src/main/java/com/cxyxiaomo/flashsale/dao/userDataObjectMapper.java
+++ b/src/main/java/com/cxyxiaomo/flashsale/dao/userDataObjectMapper.java
@@ -1,8 +1,8 @@
package com.cxyxiaomo.flashsale.dao;
-import com.cxyxiaomo.flashsale.dataobject.userDataObject;
+import com.cxyxiaomo.flashsale.dataobject.UserDataObject;
-public interface userDataObjectMapper {
+public interface UserDataObjectMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_info
@@ -17,7 +17,7 @@ public interface userDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int insert(userDataObject record);
+ int insert(UserDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -25,7 +25,7 @@ public interface userDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int insertSelective(userDataObject record);
+ int insertSelective(UserDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -33,7 +33,7 @@ public interface userDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- userDataObject selectByPrimaryKey(Integer id);
+ UserDataObject selectByPrimaryKey(Integer id);
/**
* This method was generated by MyBatis Generator.
@@ -41,7 +41,7 @@ public interface userDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int updateByPrimaryKeySelective(userDataObject record);
+ int updateByPrimaryKeySelective(UserDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -49,5 +49,5 @@ public interface userDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int updateByPrimaryKey(userDataObject record);
+ int updateByPrimaryKey(UserDataObject record);
}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dao/userPasswordDataObjectMapper.java b/src/main/java/com/cxyxiaomo/flashsale/dao/userPasswordDataObjectMapper.java
index 86e36ac..ea9f647 100644
--- a/src/main/java/com/cxyxiaomo/flashsale/dao/userPasswordDataObjectMapper.java
+++ b/src/main/java/com/cxyxiaomo/flashsale/dao/userPasswordDataObjectMapper.java
@@ -1,8 +1,8 @@
package com.cxyxiaomo.flashsale.dao;
-import com.cxyxiaomo.flashsale.dataobject.userPasswordDataObject;
+import com.cxyxiaomo.flashsale.dataobject.UserPasswordDataObject;
-public interface userPasswordDataObjectMapper {
+public interface UserPasswordDataObjectMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_password
@@ -17,7 +17,7 @@ public interface userPasswordDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int insert(userPasswordDataObject record);
+ int insert(UserPasswordDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -25,7 +25,7 @@ public interface userPasswordDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int insertSelective(userPasswordDataObject record);
+ int insertSelective(UserPasswordDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -33,7 +33,9 @@ public interface userPasswordDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- userPasswordDataObject selectByPrimaryKey(Integer id);
+ UserPasswordDataObject selectByPrimaryKey(Integer id);
+
+ UserPasswordDataObject selectByUserId(Integer userId);
/**
* This method was generated by MyBatis Generator.
@@ -41,7 +43,7 @@ public interface userPasswordDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int updateByPrimaryKeySelective(userPasswordDataObject record);
+ int updateByPrimaryKeySelective(UserPasswordDataObject record);
/**
* This method was generated by MyBatis Generator.
@@ -49,5 +51,5 @@ public interface userPasswordDataObjectMapper {
*
* @mbg.generated Tue Mar 01 14:58:29 CST 2022
*/
- int updateByPrimaryKey(userPasswordDataObject record);
+ int updateByPrimaryKey(UserPasswordDataObject record);
}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserDO.java b/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserDO.java
new file mode 100644
index 0000000..26476c0
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserDO.java
@@ -0,0 +1,234 @@
+package com.cxyxiaomo.flashsale.dataobject;
+
+public class UserDataObject {
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private Integer id;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.name
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private String name;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.gender
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private Byte gender;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.age
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private Integer age;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.telephone
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private String telephone;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.register_mode
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private String registerMode;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_info.third_party_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private String thirdPartyId;
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.id
+ *
+ * @return the value of user_info.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.id
+ *
+ * @param id the value for user_info.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.name
+ *
+ * @return the value of user_info.name
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.name
+ *
+ * @param name the value for user_info.name
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setName(String name) {
+ this.name = name == null ? null : name.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.gender
+ *
+ * @return the value of user_info.gender
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public Byte getGender() {
+ return gender;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.gender
+ *
+ * @param gender the value for user_info.gender
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setGender(Byte gender) {
+ this.gender = gender;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.age
+ *
+ * @return the value of user_info.age
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public Integer getAge() {
+ return age;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.age
+ *
+ * @param age the value for user_info.age
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.telephone
+ *
+ * @return the value of user_info.telephone
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public String getTelephone() {
+ return telephone;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.telephone
+ *
+ * @param telephone the value for user_info.telephone
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setTelephone(String telephone) {
+ this.telephone = telephone == null ? null : telephone.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.register_mode
+ *
+ * @return the value of user_info.register_mode
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public String getRegisterMode() {
+ return registerMode;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.register_mode
+ *
+ * @param registerMode the value for user_info.register_mode
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setRegisterMode(String registerMode) {
+ this.registerMode = registerMode == null ? null : registerMode.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_info.third_party_id
+ *
+ * @return the value of user_info.third_party_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public String getThirdPartyId() {
+ return thirdPartyId;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_info.third_party_id
+ *
+ * @param thirdPartyId the value for user_info.third_party_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setThirdPartyId(String thirdPartyId) {
+ this.thirdPartyId = thirdPartyId == null ? null : thirdPartyId.trim();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserPasswordDO.java b/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserPasswordDO.java
new file mode 100644
index 0000000..dbe6d39
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/dataobject/UserPasswordDO.java
@@ -0,0 +1,102 @@
+package com.cxyxiaomo.flashsale.dataobject;
+
+public class UserPasswordDataObject {
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_password.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private Integer id;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_password.encrpt_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private String encrptPassword;
+
+ /**
+ *
+ * This field was generated by MyBatis Generator.
+ * This field corresponds to the database column user_password.user_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ private Integer userId;
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_password.id
+ *
+ * @return the value of user_password.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public Integer getId() {
+ return id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_password.id
+ *
+ * @param id the value for user_password.id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_password.encrpt_password
+ *
+ * @return the value of user_password.encrpt_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public String getEncrptPassword() {
+ return encrptPassword;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_password.encrpt_password
+ *
+ * @param encrptPassword the value for user_password.encrpt_password
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setEncrptPassword(String encrptPassword) {
+ this.encrptPassword = encrptPassword == null ? null : encrptPassword.trim();
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method returns the value of the database column user_password.user_id
+ *
+ * @return the value of user_password.user_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public Integer getUserId() {
+ return userId;
+ }
+
+ /**
+ * This method was generated by MyBatis Generator.
+ * This method sets the value of the database column user_password.user_id
+ *
+ * @param userId the value for user_password.user_id
+ *
+ * @mbg.generated Tue Mar 01 14:58:29 CST 2022
+ */
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dataobject/userDataObject.java b/src/main/java/com/cxyxiaomo/flashsale/dataobject/userDataObject.java
index 1de516a..26476c0 100644
--- a/src/main/java/com/cxyxiaomo/flashsale/dataobject/userDataObject.java
+++ b/src/main/java/com/cxyxiaomo/flashsale/dataobject/userDataObject.java
@@ -1,6 +1,6 @@
package com.cxyxiaomo.flashsale.dataobject;
-public class userDataObject {
+public class UserDataObject {
/**
*
* This field was generated by MyBatis Generator.
diff --git a/src/main/java/com/cxyxiaomo/flashsale/dataobject/userPasswordDataObject.java b/src/main/java/com/cxyxiaomo/flashsale/dataobject/userPasswordDataObject.java
index d0fbc67..dbe6d39 100644
--- a/src/main/java/com/cxyxiaomo/flashsale/dataobject/userPasswordDataObject.java
+++ b/src/main/java/com/cxyxiaomo/flashsale/dataobject/userPasswordDataObject.java
@@ -1,6 +1,6 @@
package com.cxyxiaomo.flashsale.dataobject;
-public class userPasswordDataObject {
+public class UserPasswordDataObject {
/**
*
* This field was generated by MyBatis Generator.
diff --git a/src/main/java/com/cxyxiaomo/flashsale/service/UserService.java b/src/main/java/com/cxyxiaomo/flashsale/service/UserService.java
new file mode 100644
index 0000000..7c80be6
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/service/UserService.java
@@ -0,0 +1,8 @@
+package com.cxyxiaomo.flashsale.service;
+
+import com.cxyxiaomo.flashsale.service.model.UserModel;
+
+public interface UserService {
+ // 通过用户id获取用户对象的方法
+ UserModel getUserById(Integer id);
+}
diff --git a/src/main/java/com/cxyxiaomo/flashsale/service/impl/UserServiceImpl.java b/src/main/java/com/cxyxiaomo/flashsale/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..2476856
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/service/impl/UserServiceImpl.java
@@ -0,0 +1,49 @@
+package com.cxyxiaomo.flashsale.service.impl;
+
+import com.cxyxiaomo.flashsale.dao.UserDataObjectMapper;
+import com.cxyxiaomo.flashsale.dao.UserPasswordDataObjectMapper;
+import com.cxyxiaomo.flashsale.dataobject.UserDataObject;
+import com.cxyxiaomo.flashsale.dataobject.UserPasswordDataObject;
+import com.cxyxiaomo.flashsale.service.UserService;
+import com.cxyxiaomo.flashsale.service.model.UserModel;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserServiceImpl implements UserService {
+
+ @Autowired
+ private UserDataObjectMapper userDataObjectMapper;
+ @Autowired
+ private UserPasswordDataObjectMapper userPasswordDataObjectMapper;
+
+ @Override
+ public UserModel getUserById(Integer id) {
+ // 调用UserDataObjectMapper获取到对应的用户DataObject
+ UserDataObject userDO = userDataObjectMapper.selectByPrimaryKey(id);
+ if (userDO == null) {
+ return null;
+ } else {
+ // 通过用户id获取对应的用户加密密码信息
+ UserPasswordDataObject userPwdDO = userPasswordDataObjectMapper.selectByUserId(userDO.getId());
+ return convertFromDataObject(userDO, userPwdDO);
+ }
+ }
+
+ private UserModel convertFromDataObject(UserDataObject userDataObject, UserPasswordDataObject userPasswordDataObject) {
+
+ if (userDataObject == null) {
+ return null;
+ }
+
+ UserModel userModel = new UserModel();
+ BeanUtils.copyProperties(userDataObject, userModel);
+ if (userDataObject != null) {
+ // 不可再使用copyProperties,因为里面id字段是重复的
+ userModel.setEncryptPassword(userPasswordDataObject.getEncrptPassword());
+ }
+
+ return userModel;
+ }
+}
diff --git a/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java b/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java
new file mode 100644
index 0000000..c9d44b2
--- /dev/null
+++ b/src/main/java/com/cxyxiaomo/flashsale/service/model/UserModel.java
@@ -0,0 +1,77 @@
+package com.cxyxiaomo.flashsale.service.model;
+
+public class UserModel {
+ private Integer id;
+ private String name;
+ private Byte gender;
+ private String age;
+ private String telphone;
+ private String registerMode;
+ private String thirdPartyId;
+
+ private String encryptPassword;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Byte getGender() {
+ return gender;
+ }
+
+ public void setGender(Byte gender) {
+ this.gender = gender;
+ }
+
+ public String getAge() {
+ return age;
+ }
+
+ public void setAge(String age) {
+ this.age = age;
+ }
+
+ public String getTelphone() {
+ return telphone;
+ }
+
+ public void setTelphone(String telphone) {
+ this.telphone = telphone;
+ }
+
+ public String getRegisterMode() {
+ return registerMode;
+ }
+
+ public void setRegisterMode(String registerMode) {
+ this.registerMode = registerMode;
+ }
+
+ public String getThirdPartyId() {
+ return thirdPartyId;
+ }
+
+ public void setThirdPartyId(String thirdPartyId) {
+ this.thirdPartyId = thirdPartyId;
+ }
+
+ public String getEncryptPassword() {
+ return encryptPassword;
+ }
+
+ public void setEncryptPassword(String encryptPassword) {
+ this.encryptPassword = encryptPassword;
+ }
+}
diff --git a/src/main/resources/mapping/UserDOMapper.xml b/src/main/resources/mapping/UserDOMapper.xml
new file mode 100644
index 0000000..7e42f9c
--- /dev/null
+++ b/src/main/resources/mapping/UserDOMapper.xml
@@ -0,0 +1,157 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ id, name, gender, age, telephone, register_mode, third_party_id
+
+
+
+
+ delete from user_info
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ insert into user_info (id, name, gender,
+ age, telephone, register_mode,
+ third_party_id)
+ values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT},
+ #{age,jdbcType=INTEGER}, #{telephone,jdbcType=VARCHAR}, #{registerMode,jdbcType=VARCHAR},
+ #{thirdPartyId,jdbcType=VARCHAR})
+
+
+
+ insert into user_info
+
+
+ id,
+
+
+ name,
+
+
+ gender,
+
+
+ age,
+
+
+ telephone,
+
+
+ register_mode,
+
+
+ third_party_id,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{name,jdbcType=VARCHAR},
+
+
+ #{gender,jdbcType=TINYINT},
+
+
+ #{age,jdbcType=INTEGER},
+
+
+ #{telephone,jdbcType=VARCHAR},
+
+
+ #{registerMode,jdbcType=VARCHAR},
+
+
+ #{thirdPartyId,jdbcType=VARCHAR},
+
+
+
+
+
+ update user_info
+
+
+ name = #{name,jdbcType=VARCHAR},
+
+
+ gender = #{gender,jdbcType=TINYINT},
+
+
+ age = #{age,jdbcType=INTEGER},
+
+
+ telephone = #{telephone,jdbcType=VARCHAR},
+
+
+ register_mode = #{registerMode,jdbcType=VARCHAR},
+
+
+ third_party_id = #{thirdPartyId,jdbcType=VARCHAR},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ update user_info
+ set name = #{name,jdbcType=VARCHAR},
+ gender = #{gender,jdbcType=TINYINT},
+ age = #{age,jdbcType=INTEGER},
+ telephone = #{telephone,jdbcType=VARCHAR},
+ register_mode = #{registerMode,jdbcType=VARCHAR},
+ third_party_id = #{thirdPartyId,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapping/UserPasswordDOMapper.xml b/src/main/resources/mapping/UserPasswordDOMapper.xml
new file mode 100644
index 0000000..77908b2
--- /dev/null
+++ b/src/main/resources/mapping/UserPasswordDOMapper.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+ id, encrpt_password, user_id
+
+
+
+
+
+ delete from user_password
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ insert into user_password (id, encrpt_password, user_id
+ )
+ values (#{id,jdbcType=INTEGER}, #{encrptPassword,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}
+ )
+
+
+
+ insert into user_password
+
+
+ id,
+
+
+ encrpt_password,
+
+
+ user_id,
+
+
+
+
+ #{id,jdbcType=INTEGER},
+
+
+ #{encrptPassword,jdbcType=VARCHAR},
+
+
+ #{userId,jdbcType=INTEGER},
+
+
+
+
+
+ update user_password
+
+
+ encrpt_password = #{encrptPassword,jdbcType=VARCHAR},
+
+
+ user_id = #{userId,jdbcType=INTEGER},
+
+
+ where id = #{id,jdbcType=INTEGER}
+
+
+
+ update user_password
+ set encrpt_password = #{encrptPassword,jdbcType=VARCHAR},
+ user_id = #{userId,jdbcType=INTEGER}
+ where id = #{id,jdbcType=INTEGER}
+
+
\ No newline at end of file
diff --git a/src/main/resources/mapping/userDataObjectMapper.xml b/src/main/resources/mapping/userDataObjectMapper.xml
index 559de6e..719f771 100644
--- a/src/main/resources/mapping/userDataObjectMapper.xml
+++ b/src/main/resources/mapping/userDataObjectMapper.xml
@@ -1,7 +1,7 @@
-
-
+
+