├── .idea
├── .name
├── compiler.xml
├── encodings.xml
├── misc.xml
├── vcs.xml
└── workspace.xml
├── README.md
├── image
├── 1.png
├── 10.png
├── 11.png
├── 12.png
├── 13.png
├── 14.png
├── 15.png
├── 16.png
├── 17.png
├── 18.png
├── 19.png
├── 2.png
├── 20.png
├── 21.png
├── 22.png
├── 23.png
├── 24.png
├── 25.png
├── 26.png
├── 27.png
├── 28.png
├── 3.png
├── 4.png
├── 5.png
├── 6.png
├── 7.png
├── 8.png
└── 9.png
├── mr-entity
├── pom.xml
├── src
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── mrcoder
│ │ │ └── mrentity
│ │ │ ├── entity
│ │ │ ├── master
│ │ │ │ └── Student.java
│ │ │ └── slave
│ │ │ │ └── Teacher.java
│ │ │ └── mapper
│ │ │ ├── master
│ │ │ └── StudentMapper.java
│ │ │ └── slave
│ │ │ └── TeacherMapper.java
│ │ └── resources
│ │ ├── generator
│ │ ├── masterGenerator.xml
│ │ └── slaveGenerator.xml
│ │ └── mapper
│ │ ├── master
│ │ └── StudentMapper.xml
│ │ └── slave
│ │ └── TeacherMapper.xml
└── target
│ └── classes
│ ├── com
│ └── mrcoder
│ │ └── mrentity
│ │ ├── entity
│ │ ├── master
│ │ │ └── Student.class
│ │ └── slave
│ │ │ └── Teacher.class
│ │ └── mapper
│ │ ├── master
│ │ └── StudentMapper.class
│ │ └── slave
│ │ └── TeacherMapper.class
│ ├── generator
│ ├── masterGenerator.xml
│ └── slaveGenerator.xml
│ └── mapper
│ ├── master
│ └── StudentMapper.xml
│ └── slave
│ └── TeacherMapper.xml
├── mr-service
├── pom.xml
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── mrcoder
│ │ └── mrservice
│ │ ├── RedisService.java
│ │ ├── StudentService.java
│ │ ├── TeacherService.java
│ │ └── impl
│ │ ├── StudentServiceImpl.java
│ │ └── TeacherServiceImpl.java
└── target
│ └── classes
│ └── com
│ └── mrcoder
│ └── mrservice
│ ├── RedisService.class
│ ├── StudentService.class
│ ├── TeacherService.class
│ └── impl
│ ├── StudentServiceImpl.class
│ └── TeacherServiceImpl.class
├── mr-utils
├── pom.xml
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── mrcoder
│ │ └── mrutils
│ │ └── redis
│ │ └── RedisUtil.java
└── target
│ └── classes
│ └── com
│ └── mrcoder
│ └── mrutils
│ └── redis
│ └── RedisUtil.class
├── pom.xml
└── web-service
├── .gitignore
├── .mvn
└── wrapper
│ ├── MavenWrapperDownloader.java
│ ├── maven-wrapper.jar
│ └── maven-wrapper.properties
├── logs
├── logback_debug.log
├── logback_error.log
├── logback_info.log
└── logback_warn.log
├── mvnw
├── mvnw.cmd
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── com
│ │ │ └── mrcoder
│ │ │ └── webservice
│ │ │ ├── WebServiceApplication.java
│ │ │ ├── config
│ │ │ ├── DruidConfig.java
│ │ │ ├── MybatisConfig.java
│ │ │ ├── RedisConfig.java
│ │ │ ├── Swagger2Config.java
│ │ │ ├── datasource
│ │ │ │ ├── DataSourceConfig.java
│ │ │ │ ├── MasterSqlSessionTemplateConfig.java
│ │ │ │ ├── SlaveSqlSessionTemplateConfig.java
│ │ │ │ └── TransactionManagerConfig.java
│ │ │ └── wrapper
│ │ │ │ ├── CustomWrapper.java
│ │ │ │ └── MapWrapperFactory.java
│ │ │ └── controller
│ │ │ └── TestController.java
│ └── resources
│ │ ├── application.yml
│ │ ├── jta.properties
│ │ └── logback-spring.xml
└── test
│ └── java
│ └── com
│ └── mrcoder
│ └── webservice
│ └── WebServiceApplicationTests.java
└── transaction-logs
├── springboot-mybatis.lck
└── springboot-mybatis0.log
/.idea/.name:
--------------------------------------------------------------------------------
1 | mrcoder-service
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
23 |
24 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Abstraction issuesJava
18 |
19 |
20 | Android
21 |
22 |
23 | Angular
24 |
25 |
26 | Assignment issuesJava
27 |
28 |
29 | Bitwise operation issuesJava
30 |
31 |
32 | Bitwise operation issuesJavaScript
33 |
34 |
35 | Class structureJava
36 |
37 |
38 | Cloning issuesJava
39 |
40 |
41 | Code style issuesJava
42 |
43 |
44 | Control flow issuesGroovy
45 |
46 |
47 | Control flow issuesJava
48 |
49 |
50 | Control flow issuesJavaScript
51 |
52 |
53 | CorrectnessLintAndroid
54 |
55 |
56 | Cucumber
57 |
58 |
59 | Declaration redundancyJava
60 |
61 |
62 | Dependency issuesJava
63 |
64 |
65 | EditorConfig
66 |
67 |
68 | Error handlingGroovy
69 |
70 |
71 | Error handlingJava
72 |
73 |
74 | Flow type checkerJavaScript
75 |
76 |
77 | General
78 |
79 |
80 | GeneralJavaScript
81 |
82 |
83 | Groovy
84 |
85 |
86 | IconsUsabilityLintAndroid
87 |
88 |
89 | ImportsJava
90 |
91 |
92 | Inheritance issuesJava
93 |
94 |
95 | InitializationJava
96 |
97 |
98 | Internationalization
99 |
100 |
101 | InternationalizationJava
102 |
103 |
104 | InternationalizationLintAndroid
105 |
106 |
107 | JUnitJava
108 |
109 |
110 | Java
111 |
112 |
113 | Java 5Java language level migration aidsJava
114 |
115 |
116 | Java 7Java language level migration aidsJava
117 |
118 |
119 | Java 8Java language level migration aidsJava
120 |
121 |
122 | Java 9Java language level migration aidsJava
123 |
124 |
125 | Java language level issuesJava
126 |
127 |
128 | Java language level migration aidsJava
129 |
130 |
131 | JavaScript
132 |
133 |
134 | JavaScript function metricsJavaScript
135 |
136 |
137 | JavadocJava
138 |
139 |
140 | Kotlin
141 |
142 |
143 | Kotlin Android
144 |
145 |
146 | Less
147 |
148 |
149 | LintAndroid
150 |
151 |
152 | MessagesCorrectnessLintAndroid
153 |
154 |
155 | MigrationKotlin
156 |
157 |
158 | Numeric issuesJava
159 |
160 |
161 | OSGi
162 |
163 |
164 | PerformanceJava
165 |
166 |
167 | PerformanceLintAndroid
168 |
169 |
170 | Plugin DevKit
171 |
172 |
173 | PortabilityJava
174 |
175 |
176 | Potentially confusing code constructsGroovy
177 |
178 |
179 | Potentially confusing code constructsJavaScript
180 |
181 |
182 | Probable bugsJava
183 |
184 |
185 | Probable bugsKotlin
186 |
187 |
188 | RegExp
189 |
190 |
191 | Resource managementJava
192 |
193 |
194 | Sass/SCSS
195 |
196 |
197 | SecurityLintAndroid
198 |
199 |
200 | Serialization issuesJava
201 |
202 |
203 | Spring
204 |
205 |
206 | Spring CoreSpring
207 |
208 |
209 | Style issuesKotlin
210 |
211 |
212 | Threading issuesGroovy
213 |
214 |
215 | Threading issuesJava
216 |
217 |
218 | TypeScript
219 |
220 |
221 | TypographyUsabilityLintAndroid
222 |
223 |
224 | UI Form
225 |
226 |
227 | UsabilityLintAndroid
228 |
229 |
230 | Verbose or redundant code constructsJava
231 |
232 |
233 | WebSocket
234 |
235 |
236 | XMLSpring CoreSpring
237 |
238 |
239 | XPath
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | Van
46 | mj
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | 1556524007862
128 |
129 |
130 | 1556524007862
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 | 1.8
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SpringBootFrame
2 |
3 |
4 | 
5 | 
6 | 
7 | 
8 | 
9 |
10 |
11 | ## 介绍
12 |
13 | 本项目是基于springboot最新版2.1.4RELEASE搭建的多模块多数据源开发框架,可直接投产,无需关心项目结构的搭建,集成常用高频的依赖,只需关心业务的实现。
14 |
15 | * maven 多模块
16 | * 多数据源
17 | * atomikos分布式事务
18 | * mybatis
19 | * mybatis-generator
20 | * druid监控
21 | * swagger2 api文档
22 | * redis
23 | * mysql
24 | * aop
25 | * fastjson
26 | * package
27 |
28 | # 觉得不错,请star支持一下~
--------------------------------------------------------------------------------
/image/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/1.png
--------------------------------------------------------------------------------
/image/10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/10.png
--------------------------------------------------------------------------------
/image/11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/11.png
--------------------------------------------------------------------------------
/image/12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/12.png
--------------------------------------------------------------------------------
/image/13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/13.png
--------------------------------------------------------------------------------
/image/14.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/14.png
--------------------------------------------------------------------------------
/image/15.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/15.png
--------------------------------------------------------------------------------
/image/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/16.png
--------------------------------------------------------------------------------
/image/17.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/17.png
--------------------------------------------------------------------------------
/image/18.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/18.png
--------------------------------------------------------------------------------
/image/19.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/19.png
--------------------------------------------------------------------------------
/image/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/2.png
--------------------------------------------------------------------------------
/image/20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/20.png
--------------------------------------------------------------------------------
/image/21.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/21.png
--------------------------------------------------------------------------------
/image/22.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/22.png
--------------------------------------------------------------------------------
/image/23.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/23.png
--------------------------------------------------------------------------------
/image/24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/24.png
--------------------------------------------------------------------------------
/image/25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/25.png
--------------------------------------------------------------------------------
/image/26.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/26.png
--------------------------------------------------------------------------------
/image/27.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/27.png
--------------------------------------------------------------------------------
/image/28.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/28.png
--------------------------------------------------------------------------------
/image/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/3.png
--------------------------------------------------------------------------------
/image/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/4.png
--------------------------------------------------------------------------------
/image/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/5.png
--------------------------------------------------------------------------------
/image/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/6.png
--------------------------------------------------------------------------------
/image/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/7.png
--------------------------------------------------------------------------------
/image/8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/8.png
--------------------------------------------------------------------------------
/image/9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/image/9.png
--------------------------------------------------------------------------------
/mr-entity/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.mrcoder
6 | mr-entity
7 | 0.0.1
8 | mr-entity
9 | mr-entity
10 |
11 |
12 | com.mrcoder
13 | mrcoder-service
14 | 1.0.0
15 | ../pom.xml
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/mr-entity/src/main/java/com/mrcoder/mrentity/entity/master/Student.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrentity.entity.master;
2 |
3 |
4 | import java.io.Serializable;
5 |
6 | public class Student implements Serializable {
7 | private Long id;
8 |
9 | private String name;
10 |
11 | private int age;
12 |
13 | private int grade;
14 |
15 | public Student() {
16 | }
17 |
18 | public Student(String name, int age, int grade) {
19 | this.name = name;
20 | this.age = age;
21 | this.grade = grade;
22 | }
23 |
24 | @Override
25 | public String toString() {
26 | return "Student{" +
27 | "id=" + id +
28 | ", name='" + name + '\'' +
29 | ", age=" + age +
30 | ", grade=" + grade +
31 | '}';
32 | }
33 |
34 | public Long getId() {
35 | return id;
36 | }
37 |
38 | public void setId(Long id) {
39 | this.id = id;
40 | }
41 |
42 | public String getName() {
43 | return name;
44 | }
45 |
46 | public void setName(String name) {
47 | this.name = name;
48 | }
49 |
50 | public int getAge() {
51 | return age;
52 | }
53 |
54 | public void setAge(int age) {
55 | this.age = age;
56 | }
57 |
58 | public int getGrade() {
59 | return grade;
60 | }
61 |
62 | public void setGrade(int grade) {
63 | this.grade = grade;
64 | }
65 | }
--------------------------------------------------------------------------------
/mr-entity/src/main/java/com/mrcoder/mrentity/entity/slave/Teacher.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrentity.entity.slave;
2 |
3 |
4 | import java.io.Serializable;
5 |
6 | public class Teacher implements Serializable {
7 |
8 | private Long id;
9 | private String name;
10 | private int age;
11 | private int course;
12 |
13 | public Teacher() {
14 | }
15 |
16 | public Teacher(String name, int age, int course) {
17 | this.name = name;
18 | this.age = age;
19 | this.course = course;
20 | }
21 |
22 | @Override
23 | public String toString() {
24 | return "Teacher{" +
25 | "id=" + id +
26 | ", name='" + name + '\'' +
27 | ", age='" + age + '\'' +
28 | ", course='" + course + '\'' +
29 | '}';
30 | }
31 |
32 | public Long getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Long id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public int getAge() {
49 | return age;
50 | }
51 |
52 | public void setAge(int age) {
53 | this.age = age;
54 | }
55 |
56 | public int getCourse() {
57 | return course;
58 | }
59 |
60 | public void setCourse(int course) {
61 | this.course = course;
62 | }
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/mr-entity/src/main/java/com/mrcoder/mrentity/mapper/master/StudentMapper.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrentity.mapper.master;
2 |
3 | import com.mrcoder.mrentity.entity.master.Student;
4 | import org.apache.ibatis.annotations.Select;
5 |
6 | import java.util.List;
7 |
8 | public interface StudentMapper {
9 | // @Select("SELECT * FROM student")
10 | List getList();
11 |
12 | // @Select("SELECT * FROM student WHERE id = #{id}")
13 | Student getById(Long id);
14 |
15 | // @Insert("INSERT INTO student(age,grade,name) VALUES(#{age}, #{grade}, #{name})")
16 | Integer insert(Student student);
17 |
18 | // @Update("UPDATE student SET name=#{name},age=#{age}, grade=#{grade} WHERE id =#{id}")
19 | Integer update(Student student);
20 |
21 | // @Delete("DELETE FROM student WHERE id =#{id}")
22 | Integer delete(Long id);
23 |
24 |
25 | //注解方式,本项目不建议使用
26 | @Select("SELECT * FROM student")
27 | List getListByAnno();
28 | }
29 |
--------------------------------------------------------------------------------
/mr-entity/src/main/java/com/mrcoder/mrentity/mapper/slave/TeacherMapper.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrentity.mapper.slave;
2 |
3 |
4 | import com.mrcoder.mrentity.entity.slave.Teacher;
5 |
6 | import java.util.List;
7 |
8 | public interface TeacherMapper {
9 | // @Select("SELECT * FROM teacher")
10 | List getList();
11 |
12 | // @Select("SELECT * FROM teacher WHERE id = #{id}")
13 | Teacher getById(Long id);
14 |
15 | // @Insert("INSERT INTO teacher(age,course,name) VALUES(#{age}, #{course}, #{name})")
16 | void insert(Teacher teacher);
17 |
18 | // @Update("UPDATE teacher SET name=#{name},age=#{age}, course=#{course} WHERE id =#{id}")
19 | void update(Teacher teacher);
20 |
21 | // @Delete("DELETE FROM teacher WHERE id =#{id}")
22 | void delete(Long id);
23 | }
24 |
--------------------------------------------------------------------------------
/mr-entity/src/main/resources/generator/masterGenerator.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
50 |
51 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
70 |
71 |
--------------------------------------------------------------------------------
/mr-entity/src/main/resources/generator/slaveGenerator.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
69 |
70 |
--------------------------------------------------------------------------------
/mr-entity/src/main/resources/mapper/master/StudentMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | id, name, age, grade
13 |
14 |
15 |
20 |
21 |
27 |
28 |
29 | INSERT INTO
30 | student
31 | (age,grade,name)
32 | VALUES
33 | (#{age}, #{grade}, #{name})
34 |
35 |
36 |
37 | UPDATE
38 | student
39 | SET
40 | age = #{age},
41 | grade = #{grade},
42 | name = #{name}
43 | WHERE
44 | id = #{id}
45 |
46 |
47 |
48 | DELETE FROM
49 | student
50 | WHERE
51 | id =#{id}
52 |
53 |
54 |
--------------------------------------------------------------------------------
/mr-entity/src/main/resources/mapper/slave/TeacherMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | id, name, age, course
13 |
14 |
15 |
20 |
21 |
27 |
28 |
29 | INSERT INTO
30 | teacher
31 | (age,course,name)
32 | VALUES
33 | (#{age}, #{course}, #{name})
34 |
35 |
36 |
37 | UPDATE
38 | teacher
39 | SET
40 | age = #{age},
41 | course = #{course},
42 | name = #{name}
43 | WHERE
44 | id = #{id}
45 |
46 |
47 |
48 | DELETE FROM
49 | teacher
50 | WHERE
51 | id =#{id}
52 |
53 |
54 |
--------------------------------------------------------------------------------
/mr-entity/target/classes/com/mrcoder/mrentity/entity/master/Student.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-entity/target/classes/com/mrcoder/mrentity/entity/master/Student.class
--------------------------------------------------------------------------------
/mr-entity/target/classes/com/mrcoder/mrentity/entity/slave/Teacher.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-entity/target/classes/com/mrcoder/mrentity/entity/slave/Teacher.class
--------------------------------------------------------------------------------
/mr-entity/target/classes/com/mrcoder/mrentity/mapper/master/StudentMapper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-entity/target/classes/com/mrcoder/mrentity/mapper/master/StudentMapper.class
--------------------------------------------------------------------------------
/mr-entity/target/classes/com/mrcoder/mrentity/mapper/slave/TeacherMapper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-entity/target/classes/com/mrcoder/mrentity/mapper/slave/TeacherMapper.class
--------------------------------------------------------------------------------
/mr-entity/target/classes/generator/masterGenerator.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
50 |
51 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
70 |
71 |
--------------------------------------------------------------------------------
/mr-entity/target/classes/generator/slaveGenerator.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
49 |
50 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
69 |
70 |
--------------------------------------------------------------------------------
/mr-entity/target/classes/mapper/master/StudentMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | id, name, age, grade
13 |
14 |
15 |
20 |
21 |
27 |
28 |
29 | INSERT INTO
30 | student
31 | (age,grade,name)
32 | VALUES
33 | (#{age}, #{grade}, #{name})
34 |
35 |
36 |
37 | UPDATE
38 | student
39 | SET
40 | age = #{age},
41 | grade = #{grade},
42 | name = #{name}
43 | WHERE
44 | id = #{id}
45 |
46 |
47 |
48 | DELETE FROM
49 | student
50 | WHERE
51 | id =#{id}
52 |
53 |
54 |
--------------------------------------------------------------------------------
/mr-entity/target/classes/mapper/slave/TeacherMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | id, name, age, course
13 |
14 |
15 |
20 |
21 |
27 |
28 |
29 | INSERT INTO
30 | teacher
31 | (age,course,name)
32 | VALUES
33 | (#{age}, #{course}, #{name})
34 |
35 |
36 |
37 | UPDATE
38 | teacher
39 | SET
40 | age = #{age},
41 | course = #{course},
42 | name = #{name}
43 | WHERE
44 | id = #{id}
45 |
46 |
47 |
48 | DELETE FROM
49 | teacher
50 | WHERE
51 | id =#{id}
52 |
53 |
54 |
--------------------------------------------------------------------------------
/mr-service/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.mrcoder
6 | mr-service
7 | 0.0.1
8 | mr-service
9 | mr-service
10 |
11 |
12 |
13 | com.mrcoder
14 | mrcoder-service
15 | 1.0.0
16 | ../pom.xml
17 |
18 |
19 |
20 |
21 | com.mrcoder
22 | mr-entity
23 | 0.0.1
24 |
25 |
26 | com.mrcoder
27 | mr-utils
28 | 0.0.1
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/mr-service/src/main/java/com/mrcoder/mrservice/RedisService.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrservice;
2 |
3 | import com.mrcoder.mrutils.redis.RedisUtil;
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.data.redis.core.StringRedisTemplate;
6 | import org.springframework.stereotype.Service;
7 |
8 |
9 | /**
10 | * redis 测试业务层
11 | */
12 | @Service
13 | public class RedisService {
14 |
15 | @Autowired
16 | private StringRedisTemplate stringRedisTemplate;
17 |
18 | @Autowired
19 | private RedisUtil redisUtil;//内部封装了 RedisTemplate
20 |
21 | /**
22 | * 测试存储 String 类型数据
23 | */
24 | public void setValue(String key, String string) {
25 | redisUtil.set(key, string);
26 | }
27 |
28 | /**
29 | * 测试读取 String 类型数据
30 | */
31 | public Object getValue(String key) {
32 | boolean flag = redisUtil.hasKey(key);
33 | Object rs = null;
34 | if (flag) {
35 | rs = redisUtil.get(key);
36 | }
37 | return rs;
38 | }
39 |
40 | }
--------------------------------------------------------------------------------
/mr-service/src/main/java/com/mrcoder/mrservice/StudentService.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrservice;
2 |
3 |
4 | import com.mrcoder.mrentity.entity.master.Student;
5 |
6 | import java.util.List;
7 |
8 | public interface StudentService {
9 |
10 | public List getListByAnno();
11 |
12 | public List getList();
13 |
14 | public Student getById(Long id);
15 |
16 | public Integer save(Student s);
17 |
18 | public Integer update(Student s);
19 |
20 | public Integer delete(Long id);
21 |
22 | public void trans(int code);
23 | }
24 |
--------------------------------------------------------------------------------
/mr-service/src/main/java/com/mrcoder/mrservice/TeacherService.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrservice;
2 |
3 |
4 | public class TeacherService {
5 | }
6 |
--------------------------------------------------------------------------------
/mr-service/src/main/java/com/mrcoder/mrservice/impl/StudentServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrservice.impl;
2 |
3 | import com.mrcoder.mrentity.entity.master.Student;
4 | import com.mrcoder.mrentity.entity.slave.Teacher;
5 | import com.mrcoder.mrentity.mapper.master.StudentMapper;
6 | import com.mrcoder.mrentity.mapper.slave.TeacherMapper;
7 | import com.mrcoder.mrservice.StudentService;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.stereotype.Service;
10 | import org.springframework.transaction.annotation.Transactional;
11 |
12 | import java.util.List;
13 |
14 | @Service
15 | public class StudentServiceImpl implements StudentService {
16 |
17 | @Autowired
18 | private StudentMapper studentMapper;
19 |
20 | @Autowired
21 | private TeacherMapper teacherMapper;
22 |
23 | public List getListByAnno() {
24 | return studentMapper.getListByAnno();
25 | }
26 |
27 | public List getList() {
28 | return studentMapper.getList();
29 | }
30 |
31 | public Student getById(Long id) {
32 | return studentMapper.getById(id);
33 | }
34 |
35 | public Integer save(Student s) {
36 | return studentMapper.insert(s);
37 | }
38 |
39 | public Integer update(Student s) {
40 | return studentMapper.update(s);
41 | }
42 |
43 | public Integer delete(Long id) {
44 | return studentMapper.delete(id);
45 | }
46 |
47 | @Transactional
48 | public void trans(int code) {
49 | Student s1 = new Student();
50 | s1.setAge(10);
51 | s1.setGrade(10);
52 | s1.setName("s1");
53 | studentMapper.insert(s1);
54 |
55 | Teacher t1 = new Teacher();
56 | t1.setAge(10);
57 | t1.setName("t1");
58 | t1.setCourse(10);
59 | teacherMapper.insert(t1);
60 | int result = 1 / code;
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/mr-service/src/main/java/com/mrcoder/mrservice/impl/TeacherServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrservice.impl;
2 |
3 | public class TeacherServiceImpl {
4 | }
5 |
--------------------------------------------------------------------------------
/mr-service/target/classes/com/mrcoder/mrservice/RedisService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-service/target/classes/com/mrcoder/mrservice/RedisService.class
--------------------------------------------------------------------------------
/mr-service/target/classes/com/mrcoder/mrservice/StudentService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-service/target/classes/com/mrcoder/mrservice/StudentService.class
--------------------------------------------------------------------------------
/mr-service/target/classes/com/mrcoder/mrservice/TeacherService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-service/target/classes/com/mrcoder/mrservice/TeacherService.class
--------------------------------------------------------------------------------
/mr-service/target/classes/com/mrcoder/mrservice/impl/StudentServiceImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-service/target/classes/com/mrcoder/mrservice/impl/StudentServiceImpl.class
--------------------------------------------------------------------------------
/mr-service/target/classes/com/mrcoder/mrservice/impl/TeacherServiceImpl.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MrCoderStack/SpringBootFrame/be58b12c737a92223173a9e4df38789496eaff7c/mr-service/target/classes/com/mrcoder/mrservice/impl/TeacherServiceImpl.class
--------------------------------------------------------------------------------
/mr-utils/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.mrcoder
6 | mr-utils
7 | 0.0.1
8 | mr-utils
9 | mr-utils
10 |
11 |
12 | com.mrcoder
13 | mrcoder-service
14 | 1.0.0
15 | ../pom.xml
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/mr-utils/src/main/java/com/mrcoder/mrutils/redis/RedisUtil.java:
--------------------------------------------------------------------------------
1 | package com.mrcoder.mrutils.redis;
2 |
3 |
4 | import org.springframework.data.redis.core.RedisTemplate;
5 | import org.springframework.util.CollectionUtils;
6 |
7 | import java.util.List;
8 | import java.util.Map;
9 | import java.util.Set;
10 | import java.util.concurrent.TimeUnit;
11 |
12 | /**
13 | * @Description: redis 工具类
14 | */
15 | public class RedisUtil {
16 |
17 | private RedisTemplate redisTemplate;
18 |
19 | public void setRedisTemplate(RedisTemplate redisTemplate) {
20 | this.redisTemplate = redisTemplate;
21 | }
22 |
23 | /**
24 | * 指定缓存失效时间
25 | *
26 | * @param key 键
27 | * @param time 时间(秒)
28 | * @return
29 | */
30 | public boolean expire(String key, long time) {
31 | try {
32 | if (time > 0) {
33 | redisTemplate.expire(key, time, TimeUnit.SECONDS);
34 | }
35 | return true;
36 | } catch (Exception e) {
37 | e.printStackTrace();
38 | return false;
39 | }
40 | }
41 |
42 | /**
43 | * 根据key 获取过期时间
44 | *
45 | * @param key 键 不能为null
46 | * @return 时间(秒) 返回0代表为永久有效
47 | */
48 | public long getExpire(String key) {
49 | return redisTemplate.getExpire(key, TimeUnit.SECONDS);
50 | }
51 |
52 | /**
53 | * 判断key是否存在
54 | *
55 | * @param key 键
56 | * @return true 存在 false不存在
57 | */
58 | public boolean hasKey(String key) {
59 | try {
60 | return redisTemplate.hasKey(key);
61 | } catch (Exception e) {
62 | e.printStackTrace();
63 | return false;
64 | }
65 | }
66 |
67 | /**
68 | * 删除缓存
69 | *
70 | * @param key 可以传一个值 或多个
71 | */
72 | @SuppressWarnings("unchecked")
73 | public void del(String... key) {
74 | if (key != null && key.length > 0) {
75 | if (key.length == 1) {
76 | redisTemplate.delete(key[0]);
77 | } else {
78 | redisTemplate.delete(CollectionUtils.arrayToList(key));
79 | }
80 | }
81 | }
82 |
83 | /**
84 | * 普通缓存获取
85 | *
86 | * @param key 键
87 | * @return 值
88 | */
89 | public Object get(String key) {
90 | return key == null ? null : redisTemplate.opsForValue().get(key);
91 | }
92 |
93 | /**
94 | * 普通缓存放入
95 | *
96 | * @param key 键
97 | * @param value 值
98 | * @return true成功 false失败
99 | */
100 | public boolean set(String key, Object value) {
101 | try {
102 | redisTemplate.opsForValue().set(key, value);
103 | return true;
104 | } catch (Exception e) {
105 | e.printStackTrace();
106 | return false;
107 | }
108 | }
109 |
110 | /**
111 | * 普通缓存放入并设置时间
112 | *
113 | * @param key 键
114 | * @param value 值
115 | * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
116 | * @return true成功 false 失败
117 | */
118 | public boolean set(String key, Object value, long time) {
119 | try {
120 | if (time > 0) {
121 | redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
122 | } else {
123 | set(key, value);
124 | }
125 | return true;
126 | } catch (Exception e) {
127 | e.printStackTrace();
128 | return false;
129 | }
130 | }
131 |
132 | /**
133 | * 递增
134 | *
135 | * @param key 键
136 | * @param delta 要增加几(大于0)
137 | * @return
138 | */
139 | public long incr(String key, long delta) {
140 | if (delta < 0) {
141 | throw new RuntimeException("递增因子必须大于0");
142 | }
143 | return redisTemplate.opsForValue().increment(key, delta);
144 | }
145 |
146 | /**
147 | * 递减
148 | *
149 | * @param key 键
150 | * @param delta 要减少几(小于0)
151 | * @return
152 | */
153 | public long decr(String key, long delta) {
154 | if (delta < 0) {
155 | throw new RuntimeException("递减因子必须大于0");
156 | }
157 | return redisTemplate.opsForValue().increment(key, -delta);
158 | }
159 |
160 | /**
161 | * HashGet
162 | *
163 | * @param key 键 不能为null
164 | * @param item 项 不能为null
165 | * @return 值
166 | */
167 | public Object hget(String key, String item) {
168 | return redisTemplate.opsForHash().get(key, item);
169 | }
170 |
171 | /**
172 | * 获取hashKey对应的所有键值
173 | *
174 | * @param key 键
175 | * @return 对应的多个键值
176 | */
177 | public Map