Skip to content

Commit 494b101

Browse files
committed
add fastshow #16
1 parent 3827357 commit 494b101

File tree

9 files changed

+147
-5
lines changed

9 files changed

+147
-5
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
<version>${last.version}</version>
3131
</dependency>
3232
33-
<dependency>
34-
<groupId>com.codingapi.springboot</groupId>
35-
<artifactId>springboot-starter-data-permission</artifactId>
36-
<version>${last.version}</version>
37-
</dependency>
3833
```
3934

4035
## CONTRIBUTING

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@
143143
<version>${codingapi.framework.version}</version>
144144
</dependency>
145145

146+
<dependency>
147+
<groupId>com.codingapi.springboot</groupId>
148+
<artifactId>springboot-starter-fastshow</artifactId>
149+
<version>${codingapi.framework.version}</version>
150+
</dependency>
151+
146152
<dependency>
147153
<groupId>commons-dbutils</groupId>
148154
<artifactId>commons-dbutils</artifactId>
@@ -211,6 +217,7 @@
211217
<module>springboot-example</module>
212218
<module>springboot-starter-security-jwt</module>
213219
<module>springboot-starter-leaf</module>
220+
<module>springboot-starter-fastshow</module>
214221
</modules>
215222
</profile>
216223

@@ -223,6 +230,7 @@
223230
<module>springboot-example</module>
224231
<module>springboot-starter-security-jwt</module>
225232
<module>springboot-starter-leaf</module>
233+
<module>springboot-starter-fastshow</module>
226234
</modules>
227235

228236
<build>
@@ -269,6 +277,7 @@
269277
<module>springboot-starter</module>
270278
<module>springboot-starter-security-jwt</module>
271279
<module>springboot-starter-leaf</module>
280+
<module>springboot-starter-fastshow</module>
272281
</modules>
273282

274283

springboot-example/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
<artifactId>springboot-starter-leaf</artifactId>
4242
</dependency>
4343

44+
<dependency>
45+
<groupId>com.codingapi.springboot</groupId>
46+
<artifactId>springboot-starter-fastshow</artifactId>
47+
</dependency>
48+
4449

4550
<dependency>
4651
<groupId>org.springframework.boot</groupId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.codingapi.springboot.example.insfrastructure.query;
2+
3+
4+
import com.codingapi.springboot.example.insfrastructure.entity.DemoEntity;
5+
import com.codingapi.springboot.example.insfrastructure.jap.repository.DemoEntityRepository;
6+
import lombok.AllArgsConstructor;
7+
import org.springframework.data.domain.Example;
8+
import org.springframework.stereotype.Repository;
9+
import org.springframework.web.bind.annotation.RequestParam;
10+
import org.springframework.web.bind.annotation.ResponseBody;
11+
12+
import java.util.List;
13+
14+
@Repository
15+
@AllArgsConstructor
16+
public class DemoQueryApi {
17+
18+
private final DemoEntityRepository demoEntityRepository;
19+
20+
21+
@ResponseBody
22+
public List<DemoEntity> findByName(@RequestParam("name") String name) {
23+
DemoEntity entity = new DemoEntity();
24+
entity.setName(name);
25+
return demoEntityRepository.findAll(Example.of(entity));
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.codingapi.springboot.example.insfrastructure.query;
2+
3+
import com.codingapi.springboot.fastshow.mapping.MvcEndpointMapping;
4+
import lombok.AllArgsConstructor;
5+
import org.springframework.boot.ApplicationArguments;
6+
import org.springframework.boot.ApplicationRunner;
7+
import org.springframework.stereotype.Component;
8+
9+
@Component
10+
@AllArgsConstructor
11+
public class FastShowConfiguration implements ApplicationRunner {
12+
13+
private final MvcEndpointMapping mvcEndpointMapping;
14+
15+
private final DemoQueryApi demoQueryApi;
16+
17+
@Override
18+
public void run(ApplicationArguments args) throws Exception {
19+
//todo add scanner to add mapping
20+
mvcEndpointMapping.addGetMapping("/open/demo/findByName",demoQueryApi,DemoQueryApi.class.getMethod("findByName", String.class));
21+
}
22+
23+
}

springboot-starter-fastshow/pom.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>springboot-parent</artifactId>
7+
<groupId>com.codingapi.springboot</groupId>
8+
<version>1.4.0</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>springboot-starter-fastshow</artifactId>
13+
14+
<properties>
15+
<java.version>1.8</java.version>
16+
</properties>
17+
18+
19+
<dependencies>
20+
21+
<dependency>
22+
<groupId>org.springframework</groupId>
23+
<artifactId>spring-webmvc</artifactId>
24+
</dependency>
25+
</dependencies>
26+
27+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.codingapi.springboot.fastshow;
2+
3+
import com.codingapi.springboot.fastshow.mapping.MvcEndpointMapping;
4+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
5+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.context.annotation.Configuration;
8+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
9+
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
10+
11+
@Configuration
12+
@ConditionalOnClass(WebMvcConfigurer.class)
13+
public class FastShowConfiguration {
14+
15+
16+
@Bean
17+
@ConditionalOnMissingBean
18+
public MvcEndpointMapping mvcEndpointMapping(RequestMappingHandlerMapping handlerMapping){
19+
return new MvcEndpointMapping(handlerMapping);
20+
}
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.codingapi.springboot.fastshow.mapping;
2+
3+
import lombok.AllArgsConstructor;
4+
import org.springframework.http.MediaType;
5+
import org.springframework.web.bind.annotation.RequestMethod;
6+
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
7+
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
8+
import org.springframework.web.util.pattern.PathPatternParser;
9+
10+
import java.lang.reflect.Method;
11+
12+
@AllArgsConstructor
13+
public class MvcEndpointMapping {
14+
15+
private final RequestMappingHandlerMapping handlerMapping;
16+
17+
public void addGetMapping(String url, Object handler, Method method) {
18+
19+
RequestMappingInfo.BuilderConfiguration options = new RequestMappingInfo.BuilderConfiguration();
20+
options.setPatternParser(new PathPatternParser());
21+
22+
RequestMappingInfo mappingInfo = RequestMappingInfo
23+
.paths(url)
24+
.methods(RequestMethod.GET)
25+
.produces(MediaType.APPLICATION_JSON_VALUE)
26+
.options(options)
27+
.build();
28+
29+
handlerMapping.registerMapping(mappingInfo, handler, method);
30+
}
31+
32+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
2+
com.codingapi.springboot.fastshow.FastShowConfiguration

0 commit comments

Comments
 (0)