Skip to content

Commit 68392ef

Browse files
committed
ApiBoot Mybatis Enhance
1 parent bb67250 commit 68392ef

File tree

5 files changed

+245
-0
lines changed

5 files changed

+245
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright [2019] [恒宇少年 - 于起宇]
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<artifactId>api-boot-samples</artifactId>
24+
<groupId>org.minbox.framework</groupId>
25+
<version>2.0.6.RELEASE</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<artifactId>api-boot-sample-mybatis-enhance</artifactId>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-web</artifactId>
35+
</dependency>
36+
<!--ApiBoot Mybatis Enhance-->
37+
<dependency>
38+
<groupId>org.minbox.framework</groupId>
39+
<artifactId>api-boot-starter-mybatis-enhance</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>com.alibaba</groupId>
43+
<artifactId>druid-spring-boot-starter</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>mysql</groupId>
47+
<artifactId>mysql-connector-java</artifactId>
48+
</dependency>
49+
</dependencies>
50+
51+
<dependencyManagement>
52+
<dependencies>
53+
<dependency>
54+
<groupId>org.minbox.framework</groupId>
55+
<artifactId>api-boot-dependencies</artifactId>
56+
<scope>import</scope>
57+
<type>pom</type>
58+
<version>2.0.6.RELEASE</version>
59+
</dependency>
60+
</dependencies>
61+
</dependencyManagement>
62+
63+
<build>
64+
<plugins>
65+
<plugin>
66+
<groupId>org.springframework.boot</groupId>
67+
<artifactId>spring-boot-maven-plugin</artifactId>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample.mybatis.enhance;
19+
20+
import org.springframework.beans.factory.annotation.Autowired;
21+
import org.springframework.boot.SpringApplication;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.web.bind.annotation.GetMapping;
24+
import org.springframework.web.bind.annotation.PathVariable;
25+
import org.springframework.web.bind.annotation.RestController;
26+
27+
import java.util.List;
28+
29+
/**
30+
* ApiBoot Mybatis Enhance
31+
*
32+
* @author:恒宇少年 - 于起宇
33+
* <p>
34+
* DateTime:2019-04-26 17:02
35+
* Blog:http://blog.yuqiyu.com
36+
* WebSite:http://www.jianshu.com/u/092df3f77bca
37+
* Gitee:https://gitee.com/hengboy
38+
* GitHub:https://github.com/hengboy
39+
*/
40+
@SpringBootApplication
41+
@RestController
42+
public class ApiBootMybatisEnhanceApplication {
43+
44+
45+
public static void main(String[] args) {
46+
SpringApplication.run(ApiBootMybatisEnhanceApplication.class, args);
47+
}
48+
49+
@Autowired
50+
private UserMapper userMapper;
51+
52+
/**
53+
* 查询全部用户
54+
*
55+
* @return
56+
*/
57+
@GetMapping(value = "/users")
58+
public List<UserEntity> list() {
59+
return userMapper.selectAll();
60+
}
61+
62+
/**
63+
* 查询用户详情
64+
*
65+
* @param userId
66+
* @return
67+
*/
68+
@GetMapping(value = "/{userId}")
69+
public UserEntity one(@PathVariable String userId) {
70+
return userMapper.selectOne(userId);
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample.mybatis.enhance;
19+
20+
import com.gitee.hengboy.mybatis.enhance.common.annotation.Column;
21+
import com.gitee.hengboy.mybatis.enhance.common.annotation.Id;
22+
import com.gitee.hengboy.mybatis.enhance.common.annotation.Table;
23+
import com.gitee.hengboy.mybatis.enhance.common.enums.KeyGeneratorTypeEnum;
24+
import lombok.Data;
25+
26+
/**
27+
* @author:恒宇少年 - 于起宇
28+
* <p>
29+
* DateTime:2019-04-26 16:14
30+
* Blog:http://blog.yuqiyu.com
31+
* WebSite:http://www.jianshu.com/u/092df3f77bca
32+
* Gitee:https://gitee.com/hengboy
33+
* GitHub:https://github.com/hengboy
34+
*/
35+
@Data
36+
@Table(name = "local_user_info")
37+
public class UserEntity {
38+
@Column(name = "ui_id")
39+
@Id(generatorType = KeyGeneratorTypeEnum.UUID)
40+
private String uiId;
41+
42+
@Column(name = "ui_phone")
43+
private String uiPhone;
44+
45+
@Column(name = "ui_password")
46+
private String uiPassword;
47+
48+
@Column(name = "ui_status")
49+
private String uiStatus;
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright [2019] [恒宇少年 - 于起宇]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
package org.minbox.framework.api.boot.sample.mybatis.enhance;
19+
20+
import com.gitee.hengboy.mybatis.enhance.mapper.EnhanceMapper;
21+
22+
/**
23+
* @author:恒宇少年 - 于起宇
24+
* <p>
25+
* DateTime:2019-04-26 16:16
26+
* Blog:http://blog.yuqiyu.com
27+
* WebSite:http://www.jianshu.com/u/092df3f77bca
28+
* Gitee:https://gitee.com/hengboy
29+
* GitHub:https://github.com/hengboy
30+
*/
31+
public interface UserMapper extends EnhanceMapper<UserEntity, String> {
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
spring:
2+
application:
3+
name: api-boot-sample-mybatis-enhance
4+
datasource:
5+
druid:
6+
url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&serverTimezone=Asia/Shanghai
7+
driver-class-name: com.mysql.cj.jdbc.Driver
8+
username: root
9+
password: 123456
10+
# 打印SQL
11+
logging:
12+
level:
13+
org.minbox.framework.api.boot.sample.mybatis.enhance: debug
14+
15+
api:
16+
boot:
17+
# 配置Mybatis Enhance 读取自定义Mapper xml文件的位置
18+
# 默认为:classpath:mappers/*.xml
19+
enhance:
20+
mapper-locations: classpath:mappers/*.xml

0 commit comments

Comments
 (0)