Skip to content

Dev #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
Jan 2, 2024
Merged

Dev #35

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8cee298
Merge pull request #26 from codingapi/3.x
xlorne Oct 6, 2023
bed97b2
Merge pull request #27 from codingapi/3.x
xlorne Oct 28, 2023
af4d8a9
Merge pull request #28 from codingapi/3.x
xlorne Oct 28, 2023
ff1e681
Merge pull request #30 from codingapi/3.x
xlorne Nov 8, 2023
ff6f570
Merge pull request #31 from codingapi/3.x
xlorne Nov 9, 2023
87f2057
Merge pull request #32 from codingapi/3.x
xlorne Dec 9, 2023
9b5b292
add persistence module
xlorne Dec 25, 2023
db41527
add persistence module
xlorne Dec 25, 2023
5c41144
support delete & update
xlorne Dec 25, 2023
46976f9
support find schema
xlorne Dec 25, 2023
28d4531
fix schema
xlorne Dec 25, 2023
23b1f44
fix schema
xlorne Dec 25, 2023
61243e5
fix schema
xlorne Dec 25, 2023
3870d57
add DynamicMappingRegister
xlorne Dec 31, 2023
cee260b
add DynamicScript
xlorne Dec 31, 2023
9289000
add test
xlorne Dec 31, 2023
0cc6855
add test
xlorne Dec 31, 2023
800ff33
fix response mvc
xlorne Jan 1, 2024
1b1f802
fix PageRequest
xlorne Jan 1, 2024
1295ad0
fix PageRequest
xlorne Jan 1, 2024
cc20d7d
fix ScriptRequest
xlorne Jan 1, 2024
0fea3c2
fix fast-data
xlorne Jan 1, 2024
2b31922
remove id-generator
xlorne Jan 1, 2024
6adfbf1
remove data-fast
xlorne Jan 1, 2024
5fc6e5f
remove data-fast
xlorne Jan 1, 2024
385c944
remove
xlorne Jan 1, 2024
b41b9fa
add todo
xlorne Jan 1, 2024
ae16a67
add ScriptMethod
xlorne Jan 1, 2024
3237d88
add jackson-databind
xlorne Jan 2, 2024
7058f84
add EnumSerializer
xlorne Jan 2, 2024
5159af6
fix docs
xlorne Jan 2, 2024
167bd59
update 3.1.7
xlorne Jan 2, 2024
a425ea9
update 3.1.7
xlorne Jan 2, 2024
39722d5
add todo
xlorne Jan 2, 2024
10d6e58
add 3.1.8.dev
xlorne Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ v.3.x 为springboot 3.x版本,使用jdk17版本

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

## SpringBoot DDD Architecture | SpringBoot DDD 框架图
Expand All @@ -42,13 +41,6 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
<version>${last.version}</version>
</dependency>

<!-- Id自增策略框架 -->
<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-starter-id-generator</artifactId>
<version>${last.version}</version>
</dependency>

<!-- security&jwt权限框架 -->
<dependency>
<groupId>com.codingapi.springboot</groupId>
Expand Down
9 changes: 1 addition & 8 deletions docs/wiki/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ maven install
<version>${last.version}</version>
</dependency>

<!-- Id自增策略框架 -->
<dependency>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-starter-id-generator</artifactId>
<version>${last.version}</version>
</dependency>

<!-- security&jwt权限框架 -->
<dependency>
Expand All @@ -35,7 +29,6 @@ maven install


[springboot-starter](./springboot-starter)
[springboot-starter-security-jwt](./springboot-starter-security-jwt)
[springboot-starter-id-generator](./springboot-starter-id-generator)
[springboot-starter-security-jwt](./springboot-starter-security-jwt)
[springboot-starter-data-fast](./springboot-starter-data-fast.md)

158 changes: 85 additions & 73 deletions docs/wiki/springboot-starter-data-fast.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,8 @@ springboot-starter-data-fast

基于JPA的快速API能力服务

## FastController 快速API能力服务
```java
package com.codingapi.springboot.example.query;

import com.codingapi.springboot.example.infrastructure.jpa.entity.DemoEntity;
import com.codingapi.springboot.example.infrastructure.jpa.pojo.PageSearch;
import com.codingapi.springboot.fast.annotation.FastController;
import com.codingapi.springboot.fast.annotation.FastMapping;
import com.codingapi.springboot.framework.dto.response.MultiResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMethod;

@FastController
public interface FastDemoApi {


@PreAuthorize(value = "hasRole('ROLE_ADMIN')")
@FastMapping(
method = RequestMethod.GET,
mapping = "/api/demo/findByName1",
value = "select d from DemoEntity d where name = :name",
countQuery = "select count(d) from DemoEntity d where name = :name")
MultiResponse<DemoEntity> findByName1(PageSearch query);



@PreAuthorize(value = "hasRole('ROLE_USER')")
@FastMapping(
method = RequestMethod.GET,
mapping = "/api/demo/findByName2",
value = "select d from DemoEntity d where name = :name",
countQuery = "select count(d) from DemoEntity d where name = :name")
MultiResponse<DemoEntity> findByName2(PageSearch query);

}

```
@FastController 用于标记当前接口为Fast接口
@FastMapping 用于标记当前接口的映射关系
mapping为接口映射路径,method为接口请求方法
value为查询语句,countQuery为查询总数语句,query为查询参数,支持分页查询,排序查询,查询参数等等
MultiResponse为返回结果
@PreAuthorize(value = "hasRole('ROLE_USER')") 用于标记当前接口的权限,如果不需要权限可以不用添加

## FastRepository 的使用教程


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

Expand Down Expand Up @@ -189,41 +144,98 @@ public interface DemoRepository extends FastRepository<Demo,Integer> {
}

```
## SortRepository的使用教程

```java
## ScriptMapping 教程

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

}

```
ScriptMapping scriptMapping = new ScriptMapping({mapinggUrl}, {mapinggMethod}, {mappingGrovvry});
scriptMappingRegister.addMapping(scriptMapping);

SortRepository的能力展示
```
mapinggUrl 是mvc接口的地址
mapinggMethod 是mvc接口的请求方式
mappingGrovvry 是执行的查询脚本

```java
脚本实例代码:
* 动态分页查询
```
// 获取name的请求参数
var name = $request.getParameter("name","");
var pageNumber = $request.getParameter("pageNumber",0);
var pageSize = $request.getParameter("pageSize",10);
// 创建分页对象
var pageRequest = $request.pageRequest(pageNumber,pageSize);
// 动态组织sql
var sql = "select * from api_mapping where 1 =1 ";
var countSql = "select count(1) from api_mapping where 1 =1 ";
// 动态组织参数
var params = [];
if(!"".equals(name)){
sql += " and name = ? ";
countSql += " and name = ? ";
params.push(name);
}
sql += " limit ?,?";
// 添加分页参数
params.add(pageRequest.getOffset());
params.add(pageRequest.getPageSize());
// 执行分页查询
return $jdbc.queryForPage(sql,countSql,pageRequest,params.toArray());
```
* 动态条件查询
```
// 获取name的请求参数
var name = $request.getParameter("name","");
// 动态组织sql
String sql = "select * from api_mapping where 1=1 ";
// 动态组织参数
var params = [];
if(!"".equals(name)){
sql += " and name = ? ";
params.add(name);
}
// 执行查询
return $jdbc.queryForList(sql,params.toArray());
```

@Test
@Transactional
void pageSort() {
demoRepository.deleteAll();
Demo demo1 = new Demo();
demo1.setName("123");
demoRepository.save(demo1);

Demo demo2 = new Demo();
demo2.setName("456");
demoRepository.save(demo2);

List<Integer> ids = Arrays.asList(demo1.getId(), demo2.getId());
System.out.println(ids);
demoRepository.pageSort(PageRequest.of(1, 10), ids);

Demo newDemo1 = demoRepository.getReferenceById(demo1.getId());
Demo newDemo2 = demoRepository.getReferenceById(demo2.getId());

assertEquals(newDemo2.getSort(), 1);
assertEquals(newDemo1.getSort(), 0);
}
脚本语法介绍:
* $request
```
// 获取参数name的值,如果参数不存在,则返回默认值
var name = $request.getParameter("name","");
// 获取分页对象
var pageRequest = $request.pageRequest(0,10);
// 获取分页对象的页码
var pageNumber = pageRequest.getPageNumber();
// 获取分页对象的每页记录数
var pageSize = pageRequest.getPageSize();
// 获取分页对象的偏移量
var offset = pageRequest.getOffset();
```
* $jdbc
```
// 查询jdbcSQL $jdbc.queryForList({sql},{params})

// 查询无条件的数据
var res = $jdbc.queryForList("select * from api_mapping");
// 查询有条件的数据
var res = $jdbc.queryForList("select * from api_mapping where name = ?",name);
// 查询多条件的数据
var res = $jdbc.queryForList("select * from api_mapping where name = ? and url = ?",name,url);

// 分页查询 $jdbc.queryForPage({sql},{countSql},{pageRequest},{params})
var res = $jdbc.queryForPage("select * from api_mapping where name = ? and url = ?",
"select count(1) from api_mapping where name = ? and url = ?",pageRequest,params.toArray());
```
* $jpa
```
// 查询jpa $jpa.listQuery({clazz},{sql},{params})

// 查询无条件的数据
var res = $jpa.listQuery(com.example.entity.NodeEntity.class,"from NodeEntity");
// 查询有条件的数据
var res = $jpa.listQuery(com.example.entity.NodeEntity.class,"from NodeEntity where name = ?",name);
```
34 changes: 0 additions & 34 deletions docs/wiki/springboot-starter-id-generator.md

This file was deleted.

47 changes: 39 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.1.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.1.6</version>
<version>3.1.8.dev</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand All @@ -35,11 +35,14 @@
<jsonwebtoken.jjwt.version>0.12.3</jsonwebtoken.jjwt.version>
<commons-io.version>2.15.0</commons-io.version>
<commons-dbutils.version>1.8.1</commons-dbutils.version>
<commons-text.version>1.11.0</commons-text.version>
<org.reflections.version>0.10.2</org.reflections.version>
<perf4j.version>0.9.16</perf4j.version>
<bcprov-jdk15on.version>1.70</bcprov-jdk15on.version>
<bcprov-jdk18on.version>1.77</bcprov-jdk18on.version>
<commons-crypto.version>1.2.0</commons-crypto.version>
<snakeyaml.version>2.2</snakeyaml.version>
<apache-groovy.version>4.0.15</apache-groovy.version>
<h2.version>2.2.224</h2.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -73,10 +76,17 @@
<dependencyManagement>
<dependencies>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>


<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${bcprov-jdk15on.version}</version>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bcprov-jdk18on.version}</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -157,6 +167,30 @@
<version>${commons-dbutils.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${commons-text.version}</version>
</dependency>

<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${apache-groovy.version}</version>
</dependency>

<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${apache-groovy.version}</version>
</dependency>

<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>${apache-groovy.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -219,7 +253,6 @@
<module>springboot-starter</module>
<module>springboot-starter-security-jwt</module>
<module>springboot-starter-data-fast</module>
<module>springboot-starter-id-generator</module>
</modules>
</profile>

Expand All @@ -231,7 +264,6 @@
<module>springboot-starter</module>
<module>springboot-starter-security-jwt</module>
<module>springboot-starter-data-fast</module>
<module>springboot-starter-id-generator</module>
</modules>

<build>
Expand Down Expand Up @@ -281,7 +313,6 @@
<module>springboot-starter</module>
<module>springboot-starter-security-jwt</module>
<module>springboot-starter-data-fast</module>
<module>springboot-starter-id-generator</module>
</modules>


Expand Down
Loading