Skip to content

Commit daacded

Browse files
authored
Merge pull request #35 from codingapi/dev
Dev
2 parents 19f75c8 + 10d6e58 commit daacded

File tree

65 files changed

+674
-1139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+674
-1139
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
1818

1919
* springboot-starter | Springboot领域驱动框架
2020
* springboot-starter-data-fast | 快速数据呈现框架
21-
* springboot-starter-id-generator | Id自增策略框架
2221
* springboot-starter-security-jwt | security&jwt权限框架
2322

2423
## SpringBoot DDD Architecture | SpringBoot DDD 框架图
@@ -42,13 +41,6 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
4241
<version>${last.version}</version>
4342
</dependency>
4443
45-
<!-- Id自增策略框架 -->
46-
<dependency>
47-
<groupId>com.codingapi.springboot</groupId>
48-
<artifactId>springboot-starter-id-generator</artifactId>
49-
<version>${last.version}</version>
50-
</dependency>
51-
5244
<!-- security&jwt权限框架 -->
5345
<dependency>
5446
<groupId>com.codingapi.springboot</groupId>

docs/wiki/home.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ maven install
1818
<version>${last.version}</version>
1919
</dependency>
2020
21-
<!-- Id自增策略框架 -->
22-
<dependency>
23-
<groupId>com.codingapi.springboot</groupId>
24-
<artifactId>springboot-starter-id-generator</artifactId>
25-
<version>${last.version}</version>
26-
</dependency>
2721
2822
<!-- security&jwt权限框架 -->
2923
<dependency>
@@ -35,7 +29,6 @@ maven install
3529

3630

3731
[springboot-starter](./springboot-starter)
38-
[springboot-starter-security-jwt](./springboot-starter-security-jwt)
39-
[springboot-starter-id-generator](./springboot-starter-id-generator)
32+
[springboot-starter-security-jwt](./springboot-starter-security-jwt)
4033
[springboot-starter-data-fast](./springboot-starter-data-fast.md)
4134

docs/wiki/springboot-starter-data-fast.md

Lines changed: 85 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,8 @@ springboot-starter-data-fast
22

33
基于JPA的快速API能力服务
44

5-
## FastController 快速API能力服务
6-
```java
7-
package com.codingapi.springboot.example.query;
8-
9-
import com.codingapi.springboot.example.infrastructure.jpa.entity.DemoEntity;
10-
import com.codingapi.springboot.example.infrastructure.jpa.pojo.PageSearch;
11-
import com.codingapi.springboot.fast.annotation.FastController;
12-
import com.codingapi.springboot.fast.annotation.FastMapping;
13-
import com.codingapi.springboot.framework.dto.response.MultiResponse;
14-
import org.springframework.security.access.prepost.PreAuthorize;
15-
import org.springframework.web.bind.annotation.RequestMethod;
16-
17-
@FastController
18-
public interface FastDemoApi {
19-
20-
21-
@PreAuthorize(value = "hasRole('ROLE_ADMIN')")
22-
@FastMapping(
23-
method = RequestMethod.GET,
24-
mapping = "/api/demo/findByName1",
25-
value = "select d from DemoEntity d where name = :name",
26-
countQuery = "select count(d) from DemoEntity d where name = :name")
27-
MultiResponse<DemoEntity> findByName1(PageSearch query);
28-
29-
30-
31-
@PreAuthorize(value = "hasRole('ROLE_USER')")
32-
@FastMapping(
33-
method = RequestMethod.GET,
34-
mapping = "/api/demo/findByName2",
35-
value = "select d from DemoEntity d where name = :name",
36-
countQuery = "select count(d) from DemoEntity d where name = :name")
37-
MultiResponse<DemoEntity> findByName2(PageSearch query);
38-
39-
}
40-
41-
```
42-
@FastController 用于标记当前接口为Fast接口
43-
@FastMapping 用于标记当前接口的映射关系
44-
mapping为接口映射路径,method为接口请求方法
45-
value为查询语句,countQuery为查询总数语句,query为查询参数,支持分页查询,排序查询,查询参数等等
46-
MultiResponse为返回结果
47-
@PreAuthorize(value = "hasRole('ROLE_USER')") 用于标记当前接口的权限,如果不需要权限可以不用添加
48-
495
## FastRepository 的使用教程
506

51-
527
继承FastRepository接口,实现自定义的接口,即可使用FastRepository的能力
538
```java
549

@@ -189,41 +144,98 @@ public interface DemoRepository extends FastRepository<Demo,Integer> {
189144
}
190145
191146
```
192-
## SortRepository的使用教程
193147

194-
```java
148+
## ScriptMapping 教程
195149

196-
public interface DemoRepository extends FastRepository<Demo,Integer>, SortRepository<Demo,Integer> {
150+
通过动态添加mvc mapping实现查询功能.
197151

198-
}
199152

200153
```
154+
ScriptMapping scriptMapping = new ScriptMapping({mapinggUrl}, {mapinggMethod}, {mappingGrovvry});
155+
scriptMappingRegister.addMapping(scriptMapping);
201156
202-
SortRepository的能力展示
157+
```
158+
mapinggUrl 是mvc接口的地址
159+
mapinggMethod 是mvc接口的请求方式
160+
mappingGrovvry 是执行的查询脚本
203161

204-
```java
162+
脚本实例代码:
163+
* 动态分页查询
164+
```
165+
// 获取name的请求参数
166+
var name = $request.getParameter("name","");
167+
var pageNumber = $request.getParameter("pageNumber",0);
168+
var pageSize = $request.getParameter("pageSize",10);
169+
// 创建分页对象
170+
var pageRequest = $request.pageRequest(pageNumber,pageSize);
171+
// 动态组织sql
172+
var sql = "select * from api_mapping where 1 =1 ";
173+
var countSql = "select count(1) from api_mapping where 1 =1 ";
174+
// 动态组织参数
175+
var params = [];
176+
if(!"".equals(name)){
177+
sql += " and name = ? ";
178+
countSql += " and name = ? ";
179+
params.push(name);
180+
}
181+
sql += " limit ?,?";
182+
// 添加分页参数
183+
params.add(pageRequest.getOffset());
184+
params.add(pageRequest.getPageSize());
185+
// 执行分页查询
186+
return $jdbc.queryForPage(sql,countSql,pageRequest,params.toArray());
187+
```
188+
* 动态条件查询
189+
```
190+
// 获取name的请求参数
191+
var name = $request.getParameter("name","");
192+
// 动态组织sql
193+
String sql = "select * from api_mapping where 1=1 ";
194+
// 动态组织参数
195+
var params = [];
196+
if(!"".equals(name)){
197+
sql += " and name = ? ";
198+
params.add(name);
199+
}
200+
// 执行查询
201+
return $jdbc.queryForList(sql,params.toArray());
202+
```
205203

206-
@Test
207-
@Transactional
208-
void pageSort() {
209-
demoRepository.deleteAll();
210-
Demo demo1 = new Demo();
211-
demo1.setName("123");
212-
demoRepository.save(demo1);
213-
214-
Demo demo2 = new Demo();
215-
demo2.setName("456");
216-
demoRepository.save(demo2);
217-
218-
List<Integer> ids = Arrays.asList(demo1.getId(), demo2.getId());
219-
System.out.println(ids);
220-
demoRepository.pageSort(PageRequest.of(1, 10), ids);
221-
222-
Demo newDemo1 = demoRepository.getReferenceById(demo1.getId());
223-
Demo newDemo2 = demoRepository.getReferenceById(demo2.getId());
224-
225-
assertEquals(newDemo2.getSort(), 1);
226-
assertEquals(newDemo1.getSort(), 0);
227-
}
204+
脚本语法介绍:
205+
* $request
206+
```
207+
// 获取参数name的值,如果参数不存在,则返回默认值
208+
var name = $request.getParameter("name","");
209+
// 获取分页对象
210+
var pageRequest = $request.pageRequest(0,10);
211+
// 获取分页对象的页码
212+
var pageNumber = pageRequest.getPageNumber();
213+
// 获取分页对象的每页记录数
214+
var pageSize = pageRequest.getPageSize();
215+
// 获取分页对象的偏移量
216+
var offset = pageRequest.getOffset();
217+
```
218+
* $jdbc
219+
```
220+
// 查询jdbcSQL $jdbc.queryForList({sql},{params})
221+
222+
// 查询无条件的数据
223+
var res = $jdbc.queryForList("select * from api_mapping");
224+
// 查询有条件的数据
225+
var res = $jdbc.queryForList("select * from api_mapping where name = ?",name);
226+
// 查询多条件的数据
227+
var res = $jdbc.queryForList("select * from api_mapping where name = ? and url = ?",name,url);
228+
229+
// 分页查询 $jdbc.queryForPage({sql},{countSql},{pageRequest},{params})
230+
var res = $jdbc.queryForPage("select * from api_mapping where name = ? and url = ?",
231+
"select count(1) from api_mapping where name = ? and url = ?",pageRequest,params.toArray());
232+
```
233+
* $jpa
234+
```
235+
// 查询jpa $jpa.listQuery({clazz},{sql},{params})
228236
237+
// 查询无条件的数据
238+
var res = $jpa.listQuery(com.example.entity.NodeEntity.class,"from NodeEntity");
239+
// 查询有条件的数据
240+
var res = $jpa.listQuery(com.example.entity.NodeEntity.class,"from NodeEntity where name = ?",name);
229241
```

docs/wiki/springboot-starter-id-generator.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

pom.xml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
9-
<version>3.1.5</version>
9+
<version>3.1.7</version>
1010
<relativePath/> <!-- lookup parent from repository -->
1111
</parent>
1212

1313
<groupId>com.codingapi.springboot</groupId>
1414
<artifactId>springboot-parent</artifactId>
15-
<version>3.1.6</version>
15+
<version>3.1.8.dev</version>
1616

1717
<url>https://github.com/codingapi/springboot-framewrok</url>
1818
<name>springboot-parent</name>
@@ -35,11 +35,14 @@
3535
<jsonwebtoken.jjwt.version>0.12.3</jsonwebtoken.jjwt.version>
3636
<commons-io.version>2.15.0</commons-io.version>
3737
<commons-dbutils.version>1.8.1</commons-dbutils.version>
38+
<commons-text.version>1.11.0</commons-text.version>
3839
<org.reflections.version>0.10.2</org.reflections.version>
3940
<perf4j.version>0.9.16</perf4j.version>
40-
<bcprov-jdk15on.version>1.70</bcprov-jdk15on.version>
41+
<bcprov-jdk18on.version>1.77</bcprov-jdk18on.version>
4142
<commons-crypto.version>1.2.0</commons-crypto.version>
4243
<snakeyaml.version>2.2</snakeyaml.version>
44+
<apache-groovy.version>4.0.15</apache-groovy.version>
45+
<h2.version>2.2.224</h2.version>
4346
</properties>
4447

4548
<dependencies>
@@ -73,10 +76,17 @@
7376
<dependencyManagement>
7477
<dependencies>
7578

79+
<dependency>
80+
<groupId>com.h2database</groupId>
81+
<artifactId>h2</artifactId>
82+
<version>${h2.version}</version>
83+
</dependency>
84+
85+
7686
<dependency>
7787
<groupId>org.bouncycastle</groupId>
78-
<artifactId>bcprov-jdk15on</artifactId>
79-
<version>${bcprov-jdk15on.version}</version>
88+
<artifactId>bcprov-jdk18on</artifactId>
89+
<version>${bcprov-jdk18on.version}</version>
8090
</dependency>
8191

8292
<dependency>
@@ -157,6 +167,30 @@
157167
<version>${commons-dbutils.version}</version>
158168
</dependency>
159169

170+
<dependency>
171+
<groupId>org.apache.commons</groupId>
172+
<artifactId>commons-text</artifactId>
173+
<version>${commons-text.version}</version>
174+
</dependency>
175+
176+
<dependency>
177+
<groupId>org.apache.groovy</groupId>
178+
<artifactId>groovy</artifactId>
179+
<version>${apache-groovy.version}</version>
180+
</dependency>
181+
182+
<dependency>
183+
<groupId>org.apache.groovy</groupId>
184+
<artifactId>groovy-json</artifactId>
185+
<version>${apache-groovy.version}</version>
186+
</dependency>
187+
188+
<dependency>
189+
<groupId>org.apache.groovy</groupId>
190+
<artifactId>groovy-xml</artifactId>
191+
<version>${apache-groovy.version}</version>
192+
</dependency>
193+
160194
</dependencies>
161195
</dependencyManagement>
162196

@@ -219,7 +253,6 @@
219253
<module>springboot-starter</module>
220254
<module>springboot-starter-security-jwt</module>
221255
<module>springboot-starter-data-fast</module>
222-
<module>springboot-starter-id-generator</module>
223256
</modules>
224257
</profile>
225258

@@ -231,7 +264,6 @@
231264
<module>springboot-starter</module>
232265
<module>springboot-starter-security-jwt</module>
233266
<module>springboot-starter-data-fast</module>
234-
<module>springboot-starter-id-generator</module>
235267
</modules>
236268

237269
<build>
@@ -281,7 +313,6 @@
281313
<module>springboot-starter</module>
282314
<module>springboot-starter-security-jwt</module>
283315
<module>springboot-starter-data-fast</module>
284-
<module>springboot-starter-id-generator</module>
285316
</modules>
286317

287318

0 commit comments

Comments
 (0)