-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MyBatis的介绍和相关代码
- Loading branch information
Showing
26 changed files
with
834 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
Navicat Premium Data Transfer | ||
Source Server : local | ||
Source Server Type : MySQL | ||
Source Server Version : 50719 | ||
Source Host : localhost:3306 | ||
Source Schema : cloud_study | ||
Target Server Type : MySQL | ||
Target Server Version : 50719 | ||
File Encoding : 65001 | ||
Date: 03/09/2017 15:53:54 | ||
*/ | ||
|
||
SET NAMES utf8mb4; | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for course | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `course`; | ||
CREATE TABLE `course` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`courseName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, | ||
`teacher_id` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; | ||
|
||
-- ---------------------------- | ||
-- Records of course | ||
-- ---------------------------- | ||
INSERT INTO `course` VALUES (1, 'Math', 1); | ||
|
||
-- ---------------------------- | ||
-- Table structure for teacher | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `teacher`; | ||
CREATE TABLE `teacher` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`teacherName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; | ||
|
||
-- ---------------------------- | ||
-- Records of teacher | ||
-- ---------------------------- | ||
INSERT INTO `teacher` VALUES (1, 'WangMing'); | ||
|
||
-- ---------------------------- | ||
-- Table structure for user | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `user`; | ||
CREATE TABLE `user` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`userName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, | ||
`corp` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; | ||
|
||
-- ---------------------------- | ||
-- Records of user | ||
-- ---------------------------- | ||
INSERT INTO `user` VALUES (1, 'XiaoMing', 'Netease'); | ||
|
||
-- ---------------------------- | ||
-- Table structure for usercourse | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `usercourse`; | ||
CREATE TABLE `usercourse` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`user_id` int(11) DEFAULT NULL, | ||
`course_id` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`id`) USING BTREE | ||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; | ||
|
||
-- ---------------------------- | ||
-- Records of usercourse | ||
-- ---------------------------- | ||
INSERT INTO `usercourse` VALUES (1, 1, 1); | ||
|
||
SET FOREIGN_KEY_CHECKS = 1; |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/micro/profession/mybatis/GetUserInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.micro.profession.mybatis; | ||
|
||
public interface GetUserInfo { | ||
|
||
/** | ||
* 根据用户id获取用户信息 | ||
* @param id 用户id | ||
* @return 用户信息 | ||
*/ | ||
public User getUser(int id); | ||
|
||
/** | ||
* 新增用户 | ||
* @param user 用户信息 | ||
*/ | ||
public void addUser(User user); | ||
|
||
/** | ||
* 修改用户信息 | ||
* @param user 用户信息 | ||
*/ | ||
public void updateUser(User user); | ||
|
||
/** | ||
* 删除用户 | ||
* @param user 用户信息 | ||
*/ | ||
public void deleteUser(User user); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/micro/profession/mybatis/GetUserInfoAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.micro.profession.mybatis; | ||
|
||
import org.apache.ibatis.annotations.Select; | ||
|
||
public interface GetUserInfoAnnotation { | ||
|
||
@Select("select * from user where id = #{id}") | ||
public User getUser(int id); | ||
} |
Oops, something went wrong.