From 69a9807e817baa88b24ebd952b3e7a99dbffe75e Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Wed, 9 Sep 2020 22:08:09 +0800 Subject: [PATCH 01/14] =?UTF-8?q?java=20=E5=90=84=E7=A7=8D=20proxy=20?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++--- lab-69-proxy/lab-69-proxy-cglib/pom.xml | 22 ++++++++++++++++ .../springboot/labs/lab69/TestProxyMain.java | 19 ++++++++++++++ .../UserServiceMethodInterceptor.java | 17 ++++++++++++ .../labs/lab69/service/UserServiceImpl.java | 9 +++++++ lab-69-proxy/lab-69-proxy-jdk/pom.xml | 22 ++++++++++++++++ .../labs/lab69/GenerateProxyMain.java | 25 ++++++++++++++++++ .../springboot/labs/lab69/TestProxyMain.java | 26 +++++++++++++++++++ .../lab69/handler/UserServiceHandler.java | 24 +++++++++++++++++ .../labs/lab69/service/UserService.java | 7 +++++ .../labs/lab69/service/UserServiceImpl.java | 9 +++++++ lab-69-proxy/pom.xml | 20 ++++++++++++++ pom.xml | 2 ++ 13 files changed, 206 insertions(+), 4 deletions(-) create mode 100644 lab-69-proxy/lab-69-proxy-cglib/pom.xml create mode 100644 lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java create mode 100644 lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/intercept/UserServiceMethodInterceptor.java create mode 100644 lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java create mode 100644 lab-69-proxy/lab-69-proxy-jdk/pom.xml create mode 100644 lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/GenerateProxyMain.java create mode 100644 lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java create mode 100644 lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/handler/UserServiceHandler.java create mode 100644 lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserService.java create mode 100644 lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java create mode 100644 lab-69-proxy/pom.xml diff --git a/README.md b/README.md index 0181341f4..9ee72fd2c 100644 --- a/README.md +++ b/README.md @@ -397,10 +397,10 @@ 如下是草稿目录,未来需要整理下 -# lab-9 - -记录阅读极客时间《数据结构与算法之美》的题目。 - # lab-50 Email 示例 + +# lab-69-proxy + +动态代理 diff --git a/lab-69-proxy/lab-69-proxy-cglib/pom.xml b/lab-69-proxy/lab-69-proxy-cglib/pom.xml new file mode 100644 index 000000000..c9d1e933d --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-cglib/pom.xml @@ -0,0 +1,22 @@ + + + + lab-69 + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-69-proxy-cglib + + + + cglib + cglib + 3.3.0 + + + + diff --git a/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java new file mode 100644 index 000000000..9885e9df6 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java @@ -0,0 +1,19 @@ +package cn.iocoder.springboot.labs.lab69; + +import cn.iocoder.springboot.labs.lab69.intercept.UserServiceMethodInterceptor; +import cn.iocoder.springboot.labs.lab69.service.UserServiceImpl; +import net.sf.cglib.proxy.Enhancer; + +public class TestProxyMain { + + public static void main(String[] args) { + // 创建 cglib 增强对象 + Enhancer enhancer = new Enhancer(); + enhancer.setSuperclass(UserServiceImpl.class); // 设置父类 + enhancer.setCallback(new UserServiceMethodInterceptor()); + // 创建代理 + UserServiceImpl userService = (UserServiceImpl) enhancer.create(); + userService.create("yunai", "buzhidao"); + } + +} diff --git a/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/intercept/UserServiceMethodInterceptor.java b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/intercept/UserServiceMethodInterceptor.java new file mode 100644 index 000000000..c607ee000 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/intercept/UserServiceMethodInterceptor.java @@ -0,0 +1,17 @@ +package cn.iocoder.springboot.labs.lab69.intercept; + +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + +import java.lang.reflect.Method; + +public class UserServiceMethodInterceptor implements MethodInterceptor { + + public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable { + System.out.println("before invoke"); + Object ret = methodProxy.invokeSuper(object, args); + System.out.println("after invoke"); + return ret; + } + +} diff --git a/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java new file mode 100644 index 000000000..61a1f79f4 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-cglib/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java @@ -0,0 +1,9 @@ +package cn.iocoder.springboot.labs.lab69.service; + +public class UserServiceImpl { + + public void create(String username, String password) { + System.out.println(String.format("登陆的用户名(%s) 密码(%s)", username, password)); + } + +} diff --git a/lab-69-proxy/lab-69-proxy-jdk/pom.xml b/lab-69-proxy/lab-69-proxy-jdk/pom.xml new file mode 100644 index 000000000..239401ba0 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/pom.xml @@ -0,0 +1,22 @@ + + + + lab-69 + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-69-proxy-jdk + + + + commons-io + commons-io + 2.7 + + + + diff --git a/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/GenerateProxyMain.java b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/GenerateProxyMain.java new file mode 100644 index 000000000..1c57a1964 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/GenerateProxyMain.java @@ -0,0 +1,25 @@ +package cn.iocoder.springboot.labs.lab69; + +import cn.iocoder.springboot.labs.lab69.service.UserServiceImpl; +import org.apache.commons.io.IOUtils; +import sun.misc.ProxyGenerator; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Proxy; + +/** + * 生成 JDK {@link Proxy} 的示例代码 + * + * 生成后,我们可以反编译查看具体的类 + */ +public class GenerateProxyMain { + + public static void main(String[] args) throws IOException { + // 生成字节码 + byte[] classFile = ProxyGenerator.generateProxyClass("$Proxy11", UserServiceImpl.class.getInterfaces()); + // 写入到磁盘 + IOUtils.write(classFile, new FileOutputStream("/Users/yunai/ls/$Proxy11.class")); + } + +} diff --git a/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java new file mode 100644 index 000000000..b67f63793 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/TestProxyMain.java @@ -0,0 +1,26 @@ +package cn.iocoder.springboot.labs.lab69; + +import cn.iocoder.springboot.labs.lab69.handler.UserServiceHandler; +import cn.iocoder.springboot.labs.lab69.service.UserService; +import cn.iocoder.springboot.labs.lab69.service.UserServiceImpl; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; + +/** + * 使用 JDK {@link Proxy} 实现一个动态代理的示例 + */ +public class TestProxyMain { + + public static void main(String[] args) { + // 创建 UserService 对象 + UserService userService = new UserServiceImpl(); + // JDK 处理器 + InvocationHandler handler = new UserServiceHandler(userService); + // 创建代理 + UserService userServiceProxy = (UserService) Proxy.newProxyInstance(TestProxyMain.class.getClassLoader(), userService.getClass().getInterfaces(), handler); + // 执行 + userServiceProxy.create("yunai", "buzhidao"); + } + +} diff --git a/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/handler/UserServiceHandler.java b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/handler/UserServiceHandler.java new file mode 100644 index 000000000..06d62cb19 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/handler/UserServiceHandler.java @@ -0,0 +1,24 @@ +package cn.iocoder.springboot.labs.lab69.handler; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; + +public class UserServiceHandler implements InvocationHandler { + + /** + * 被代理的对象 + */ + private final Object object; + + public UserServiceHandler(Object object) { + this.object = object; + } + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + System.out.println("before invoke"); + Object ret = method.invoke(object, args); + System.out.println("after invoke"); + return ret; + } + +} diff --git a/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserService.java b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserService.java new file mode 100644 index 000000000..234b5dc48 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserService.java @@ -0,0 +1,7 @@ +package cn.iocoder.springboot.labs.lab69.service; + +public interface UserService { + + void create(String username, String password); + +} diff --git a/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java new file mode 100644 index 000000000..7bab724d2 --- /dev/null +++ b/lab-69-proxy/lab-69-proxy-jdk/src/main/java/cn/iocoder/springboot/labs/lab69/service/UserServiceImpl.java @@ -0,0 +1,9 @@ +package cn.iocoder.springboot.labs.lab69.service; + +public class UserServiceImpl implements UserService { + + public void create(String username, String password) { + System.out.println(String.format("登陆的用户名(%s) 密码(%s)", username, password)); + } + +} diff --git a/lab-69-proxy/pom.xml b/lab-69-proxy/pom.xml new file mode 100644 index 000000000..45f9b82d9 --- /dev/null +++ b/lab-69-proxy/pom.xml @@ -0,0 +1,20 @@ + + + + labs-parent + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-69 + pom + + lab-69-proxy-jdk + lab-69-proxy-cglib + + + + diff --git a/pom.xml b/pom.xml index 1127eda64..e9c2abdde 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,8 @@ + lab-69-proxy + From 7770689bea7fb70a575a439f64f27d506ba5fcc2 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 21 Nov 2020 12:48:08 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Swagger=20Dubbo=20?= =?UTF-8?q?=E5=88=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + .../pom.xml | 60 +++++++++++++++++++ .../springdatarediswithjedis/Application.java | 8 +++ .../config/RedisConfiguration.java | 39 ++++++++++++ .../util/JSONUtil.java | 22 +++++++ .../src/main/resources/application.yml | 11 ++++ .../src/main/resources/redisson.yml | 0 .../springdatarediswithjedis/Test01.java | 47 +++++++++++++++ .../config/TestRedisConfiguration.java | 34 +++++++++++ lab-11-spring-data-redis/pom.xml | 1 + ...37\345\205\245\351\227\250\343\200\213.md" | 1 + pom.xml | 3 +- 12 files changed, 226 insertions(+), 2 deletions(-) create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/pom.xml create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Application.java create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/RedisConfiguration.java create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/util/JSONUtil.java create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/application.yml create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/redisson.yml create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Test01.java create mode 100644 lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/TestRedisConfiguration.java create mode 100644 "lab-30/\343\200\212\350\212\213\351\201\223 Dubbo Swagger \345\277\253\351\200\237\345\205\245\351\227\250\343\200\213.md" diff --git a/README.md b/README.md index 9ee72fd2c..4211ecb18 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ * [《芋道 Spring Cloud 服务网关 Spring Cloud Gateway 入门》](http://www.iocoder.cn/Spring-Cloud/Spring-Cloud-Gateway/?github) 对应 [labx-08-spring-cloud-gateway](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-08-spring-cloud-gateway) * [《芋道 Spring Cloud 链路追踪 SkyWalking 入门》](http://www.iocoder.cn/Spring-Cloud/SkyWalking/?github) 对应 [labx-14](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-14) * [《芋道 Dubbo Admin 快速入门》](http://www.iocoder.cn/Dubbo/Admin/?github) +* [《芋道 Dubbo Swagger 快速入门》](http://www.iocoder.cn/Dubbo/Swagger/?github) 对应 [swagger-dubbo](https://github.com/YunaiV/swagger-dubbo) # Spring Cloud 专栏 @@ -274,6 +275,7 @@ * [《芋道 Spring Boot Dubbo 入门》](http://www.iocoder.cn/Spring-Boot/Dubbo/?github) 对应 [lab-30](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-30) * [《芋道 Spring Cloud Alibaba 服务调用 Dubbo 入门》](http://www.iocoder.cn/Spring-Cloud-Alibaba/Dubbo/?github) 对应 [labx-07-spring-cloud-alibaba-dubbo](https://github.com/YunaiV/SpringBoot-Labs/tree/master/labx-07-spring-cloud-alibaba-dubbo) * [《性能测试 —— Dubbo 基准测试》](http://www.iocoder.cn/Performance-Testing/Dubbo-benchmark/?github) +* [《芋道 Dubbo Swagger 快速入门》](http://www.iocoder.cn/Dubbo/Swagger/?github) 对应 [swagger-dubbo](https://github.com/YunaiV/swagger-dubbo) ## 注册中心 diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/pom.xml b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/pom.xml new file mode 100644 index 000000000..2d50408c4 --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/pom.xml @@ -0,0 +1,60 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + 4.0.0 + + lab-07-spring-data-redis-unit-test + + + + + + org.redisson + redisson-spring-boot-starter + 3.11.3 + + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + com.alibaba + fastjson + 1.2.61 + + + + + com.fasterxml.jackson.core + jackson-databind + + + + commons-io + commons-io + 2.6 + + + + + it.ozimov + embedded-redis + 0.7.2 + test + + + + + diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Application.java b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Application.java new file mode 100644 index 000000000..ac6c60ce3 --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Application.java @@ -0,0 +1,8 @@ +package cn.iocoder.springboot.labs.lab10.springdatarediswithjedis; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +//@EnableTransactionManagement +public class Application { +} diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/RedisConfiguration.java b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/RedisConfiguration.java new file mode 100644 index 000000000..a78920725 --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/RedisConfiguration.java @@ -0,0 +1,39 @@ +package cn.iocoder.springboot.labs.lab10.springdatarediswithjedis.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.RedisSerializer; + +@Configuration +public class RedisConfiguration { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + // 创建 RedisTemplate 对象 + RedisTemplate template = new RedisTemplate<>(); + + // 设置开启事务支持 + template.setEnableTransactionSupport(true); + + // 设置 RedisConnection 工厂。😈 它就是实现多种 Java Redis 客户端接入的秘密工厂。感兴趣的胖友,可以自己去撸下。 + template.setConnectionFactory(factory); + + // 使用 String 序列化方式,序列化 KEY 。 + template.setKeySerializer(RedisSerializer.string()); + + // 使用 JSON 序列化方式(库是 Jackson ),序列化 VALUE 。 + template.setValueSerializer(RedisSerializer.json()); + return template; + } + + // Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); +// ObjectMapper objectMapper = new ObjectMapper();// <1> +//// objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); +//// objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); +// +// jackson2JsonRedisSerializer.setObjectMapper(objectMapper); +// template.setValueSerializer(jackson2JsonRedisSerializer); + +} diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/util/JSONUtil.java b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/util/JSONUtil.java new file mode 100644 index 000000000..cea22f21a --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/util/JSONUtil.java @@ -0,0 +1,22 @@ +package cn.iocoder.springboot.labs.lab10.springdatarediswithjedis.util; + +import com.alibaba.fastjson.JSON; + +/** + * JSON 工具类 + */ +public class JSONUtil { + + public static T parseObject(String text, Class clazz) { + return JSON.parseObject(text, clazz); + } + + public static String toJSONString(Object javaObject) { + return JSON.toJSONString(javaObject); + } + + public static byte[] toJSONBytes(Object javaObject) { + return JSON.toJSONBytes(javaObject); + } + +} diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/application.yml b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/application.yml new file mode 100644 index 000000000..742b2ad31 --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + # 对应 RedisProperties 类 + redis: + host: 127.0.0.1 + port: 6379 +# password: # Redis 服务器密码,默认为空。生产中,一定要设置 Redis 密码! + database: 0 # Redis 数据库号,默认为 0 。 + timeout: 0 # Redis 连接超时时间,单位:毫秒。 + # 对应 RedissonProperties 类 +# redisson: +# config: classpath:redisson.yml # 具体的每个配置项,见 org.redisson.config.Config 类。 diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/redisson.yml b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/main/resources/redisson.yml new file mode 100644 index 000000000..e69de29bb diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Test01.java b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Test01.java new file mode 100644 index 000000000..98f573d2f --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/Test01.java @@ -0,0 +1,47 @@ +package cn.iocoder.springboot.labs.lab10.springdatarediswithjedis; + +import cn.iocoder.springboot.labs.lab10.springdatarediswithjedis.config.TestRedisConfiguration; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.dao.DataAccessException; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestRedisConfiguration.class) +public class Test01 { + + @Autowired + private StringRedisTemplate stringRedisTemplate; + + @Autowired + private RedisTemplate redisTemplate; + +// @Autowired +// private RedisServer server; + + @Test + public void test01() { + // 写入 + stringRedisTemplate.opsForValue().set("yunai", "shuai"); + // 读取 + String value = stringRedisTemplate.opsForValue().get("yunai"); + Assert.assertEquals("值不匹配", "shuai", value); + + // 测试重启后读取 + redisTemplate.execute(new RedisCallback() { + @Override + public Object doInRedis(RedisConnection connection) throws DataAccessException { + connection.flushDb(); + return ""; + } + }); + } + +} diff --git a/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/TestRedisConfiguration.java b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/TestRedisConfiguration.java new file mode 100644 index 000000000..32086eef1 --- /dev/null +++ b/lab-11-spring-data-redis/lab-07-spring-data-redis-unit-test/src/test/java/cn/iocoder/springboot/labs/lab10/springdatarediswithjedis/config/TestRedisConfiguration.java @@ -0,0 +1,34 @@ +package cn.iocoder.springboot.labs.lab10.springdatarediswithjedis.config; + +import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +import org.springframework.boot.test.context.TestConfiguration; +import redis.embedded.RedisServer; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +@TestConfiguration +public class TestRedisConfiguration { + + private RedisServer redisServer; + + public TestRedisConfiguration(RedisProperties redisProperties) { + this.redisServer = new RedisServer(redisProperties.getPort()); + } + +// @Bean +// public RedisServer redisServer() { +// return redisServer; +// } + + @PostConstruct + public void postConstruct() { + redisServer.start(); + } + + @PreDestroy + public void preDestroy() { + redisServer.stop(); + } + +} diff --git a/lab-11-spring-data-redis/pom.xml b/lab-11-spring-data-redis/pom.xml index 7c6441236..4eb256c83 100644 --- a/lab-11-spring-data-redis/pom.xml +++ b/lab-11-spring-data-redis/pom.xml @@ -14,6 +14,7 @@ lab-07-spring-data-redis-with-jedis lab-07-spring-data-redis-with-redisson + lab-07-spring-data-redis-unit-test diff --git "a/lab-30/\343\200\212\350\212\213\351\201\223 Dubbo Swagger \345\277\253\351\200\237\345\205\245\351\227\250\343\200\213.md" "b/lab-30/\343\200\212\350\212\213\351\201\223 Dubbo Swagger \345\277\253\351\200\237\345\205\245\351\227\250\343\200\213.md" new file mode 100644 index 000000000..4be20bd8b --- /dev/null +++ "b/lab-30/\343\200\212\350\212\213\351\201\223 Dubbo Swagger \345\277\253\351\200\237\345\205\245\351\227\250\343\200\213.md" @@ -0,0 +1 @@ + diff --git a/pom.xml b/pom.xml index e9c2abdde..941039a93 100644 --- a/pom.xml +++ b/pom.xml @@ -76,8 +76,7 @@ - lab-69-proxy - + From 17a49ddae2b1ca0b8a3533d04b1bd1ba89db4cde Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 21 Nov 2020 16:37:47 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20JApiDocs=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-24/lab-24-apidoc-japidocs/pom.xml | 31 +++++++++++ .../iocoder/springboot/lab24/Application.java | 13 +++++ .../springboot/lab24/TestJApiDocs.java | 22 ++++++++ .../lab24/controller/UserController.java | 52 +++++++++++++++++++ .../springboot/lab24/vo/UserCreateReqVO.java | 17 ++++++ .../springboot/lab24/vo/UserListReqVO.java | 13 +++++ .../springboot/lab24/vo/UserRespVO.java | 21 ++++++++ lab-24/pom.xml | 1 + pom.xml | 2 +- 9 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 lab-24/lab-24-apidoc-japidocs/pom.xml create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/Application.java create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/TestJApiDocs.java create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserCreateReqVO.java create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserListReqVO.java create mode 100644 lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserRespVO.java diff --git a/lab-24/lab-24-apidoc-japidocs/pom.xml b/lab-24/lab-24-apidoc-japidocs/pom.xml new file mode 100644 index 000000000..f1a946f4f --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/pom.xml @@ -0,0 +1,31 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + 4.0.0 + + lab-24-apidoc-japidocs + + + + + org.springframework.boot + spring-boot-starter-web + + + + + io.github.yedaxia + japidocs + 1.4.4 + + + + + diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/Application.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/Application.java new file mode 100644 index 000000000..cc795da46 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/Application.java @@ -0,0 +1,13 @@ +package cn.iocoder.springboot.lab24; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/TestJApiDocs.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/TestJApiDocs.java new file mode 100644 index 000000000..fdeab6e54 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/TestJApiDocs.java @@ -0,0 +1,22 @@ +package cn.iocoder.springboot.lab24; + +import io.github.yedaxia.apidocs.Docs; +import io.github.yedaxia.apidocs.DocsConfig; +import io.github.yedaxia.apidocs.plugin.markdown.MarkdownDocPlugin; + +public class TestJApiDocs { + + public static void main(String[] args) { + // 1. 创建生成文档的配置 + DocsConfig config = new DocsConfig(); + config.setProjectPath("/Users/yunai/Java/SpringBoot-Labs/lab-24/lab-24-apidoc-japidocs"); // 项目所在目录 + config.setDocsPath("/Users/yunai/Downloads/"); // 生成 HTML 接口文档的目标目录 + config.setAutoGenerate(true); // 是否给所有 Controller 生成接口文档 + config.setProjectName("示例项目"); // 项目名 + config.setApiVersion("V1.0"); // API 版本号 + config.addPlugin(new MarkdownDocPlugin()); // 使用 MD 插件,额外生成 MD 格式的接口文档 + // 2. 执行生成 HTML 接口文档 + Docs.buildHtmlDocs(config); + } + +} diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java new file mode 100644 index 000000000..da67b9808 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java @@ -0,0 +1,52 @@ +package cn.iocoder.springboot.lab24.controller; + +import cn.iocoder.springboot.lab24.vo.UserCreateReqVO; +import cn.iocoder.springboot.lab24.vo.UserListReqVO; +import cn.iocoder.springboot.lab24.vo.UserRespVO; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * 用户 API + */ +@RestController +@RequestMapping("/api/user/") +public class UserController { + + + /** + * 获得用户列表 + * + * @param listReqVO 列表筛选条件 + * @return 用户列表 + */ + @GetMapping("list") + public List list(UserListReqVO listReqVO){ + return null; + } + + /** + * 保存用户 + * + * @param createReqVO 创建用户信息 + * @return 用户编号 + */ + @PostMapping("save") + public Integer saveUser(@RequestBody UserCreateReqVO createReqVO){ + return 1; + } + + /** + * 删除指定编号的用户 + * + * @param id 用户编号 + * @return 是否成功 + */ + @DeleteMapping("delete") + public Boolean deleteUser(@RequestParam Long id){ + return true; + } + + +} diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserCreateReqVO.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserCreateReqVO.java new file mode 100644 index 000000000..c5e82c8f8 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserCreateReqVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.springboot.lab24.vo; + +/** + * 用户创建请求 VO + */ +public class UserCreateReqVO { + + /** + * 昵称 + */ + private String nickname; + /** + * 年龄 + */ + private Integer age; + +} diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserListReqVO.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserListReqVO.java new file mode 100644 index 000000000..cb0f28624 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserListReqVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.springboot.lab24.vo; + +/** + * 用户列表请求 VO + */ +public class UserListReqVO { + + /** + * 昵称,模糊匹配 + */ + private String nickname; + +} diff --git a/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserRespVO.java b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserRespVO.java new file mode 100644 index 000000000..2dda156c4 --- /dev/null +++ b/lab-24/lab-24-apidoc-japidocs/src/main/java/cn/iocoder/springboot/lab24/vo/UserRespVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.springboot.lab24.vo; + +/** + * 用户响应 VO + */ +public class UserRespVO { + + /** + * 用户编号 + */ + private Integer id; + /** + * 昵称 + */ + private String nickname; + /** + * 年龄 + */ + private Integer age; + +} diff --git a/lab-24/pom.xml b/lab-24/pom.xml index e312a1268..1c5c69a04 100644 --- a/lab-24/pom.xml +++ b/lab-24/pom.xml @@ -14,6 +14,7 @@ lab-24-apidoc-swagger lab-24-apidoc-swagger-knife4j + lab-24-apidoc-japidocs diff --git a/pom.xml b/pom.xml index 941039a93..e37f78976 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ - + lab-24 From ce180d38f8fa80446f609c4e1567df092fc4f77b Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 21 Nov 2020 21:29:26 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20JApiDocs=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + ...346\241\243 JApiDocs \345\205\245\351\227\250\343\200\213.md" | 1 + 2 files changed, 2 insertions(+) create mode 100644 "lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 JApiDocs \345\205\245\351\227\250\343\200\213.md" diff --git a/README.md b/README.md index 4211ecb18..e5be0dddf 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ * [《芋道 Spring Boot WebSocket 入门》](http://www.iocoder.cn/Spring-Boot/WebSocket/?github) 对应 [lab-25](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-25) * [《性能测试 —— Tomcat、Jetty、Undertow 基准测试》](http://www.iocoder.cn/Performance-Testing/Tomcat-Jetty-Undertow-benchmark/?github) 对应 [lab-05-benchmark-tomcat-jetty-undertow](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-05-benchmark-tomcat-jetty-undertow) * [《性能测试 —— SpringMVC、Webflux 基准测试》](http://www.iocoder.cn/Performance-Testing/SpringMVC-Webflux-benchmark/?github) 对应 [lab-06](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-06) +* [《芋道 Spring Boot API 接口文档 JApiDocs 入门》](http://www.iocoder.cn/Spring-Boot/JApiDocs/?github) 对应 [lab-24](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-24) ## RPC 开发 diff --git "a/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 JApiDocs \345\205\245\351\227\250\343\200\213.md" "b/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 JApiDocs \345\205\245\351\227\250\343\200\213.md" new file mode 100644 index 000000000..c502e16b4 --- /dev/null +++ "b/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 JApiDocs \345\205\245\351\227\250\343\200\213.md" @@ -0,0 +1 @@ + From c39d559f528182b12ef16521d9ea74c19b922943 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 28 Nov 2020 10:47:28 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Swagger=20Starter=20?= =?UTF-8?q?=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-24/lab-24-apidoc-swagger-starter/pom.xml | 30 ++++++++ .../iocoder/springboot/lab24/Application.java | 13 ++++ .../lab24/config/SwaggerConfiguration.java | 41 +++++++++++ .../lab24/controller/UserController.java | 68 +++++++++++++++++++ .../springboot/lab24/dto/UserAddDTO.java | 32 +++++++++ .../springboot/lab24/dto/UserUpdateDTO.java | 43 ++++++++++++ .../iocoder/springboot/lab24/vo/UserVO.java | 32 +++++++++ .../src/main/resources/application.yaml | 5 ++ lab-24/pom.xml | 1 + 9 files changed, 265 insertions(+) create mode 100644 lab-24/lab-24-apidoc-swagger-starter/pom.xml create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/Application.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserAddDTO.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserUpdateDTO.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/vo/UserVO.java create mode 100644 lab-24/lab-24-apidoc-swagger-starter/src/main/resources/application.yaml diff --git a/lab-24/lab-24-apidoc-swagger-starter/pom.xml b/lab-24/lab-24-apidoc-swagger-starter/pom.xml new file mode 100644 index 000000000..91dbbee69 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/pom.xml @@ -0,0 +1,30 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.2.11.RELEASE + + + 4.0.0 + + lab-24-apidoc-swagger-starter + + + + + org.springframework.boot + spring-boot-starter-web + + + + + io.springfox + springfox-boot-starter + 3.0.0 + + + + diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/Application.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/Application.java new file mode 100644 index 000000000..cc795da46 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/Application.java @@ -0,0 +1,13 @@ +package cn.iocoder.springboot.lab24; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java new file mode 100644 index 000000000..1cc1fddd4 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java @@ -0,0 +1,41 @@ +package cn.iocoder.springboot.lab24.config; + +import org.springframework.context.annotation.Bean; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; + +//@Configuration +// @EnableSwagger2 无需使用该注解 +public class SwaggerConfiguration { + + @Bean + public Docket createRestApi() { + // 创建 Docket 对象 + return new Docket(DocumentationType.SWAGGER_2) // 文档类型,使用 Swagger2 + .apiInfo(this.apiInfo()) // 设置 API 信息 + // 扫描 Controller 包路径,获得 API 接口 + .select() + .apis(RequestHandlerSelectors.basePackage("cn.iocoder.springboot.lab24.controller")) + .paths(PathSelectors.any()) + // 构建出 Docket 对象 + .build(); + } + + /** + * 创建 API 信息 + */ + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("测试接口文档示例") + .description("我是一段描述") + .version("1.0.0") // 版本号 + .contact(new Contact("芋艿", "http://www.iocoder.cn", "zhijiantianya@gmail.com")) // 联系人 + .build(); + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java new file mode 100644 index 000000000..6ed0a76f4 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/controller/UserController.java @@ -0,0 +1,68 @@ +package cn.iocoder.springboot.lab24.controller; + +import cn.iocoder.springboot.lab24.dto.UserAddDTO; +import cn.iocoder.springboot.lab24.dto.UserUpdateDTO; +import cn.iocoder.springboot.lab24.vo.UserVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@RestController +@RequestMapping("/users") +@Api(tags = "用户 API 接口") +public class UserController { + + @GetMapping("/list") + @ApiOperation(value = "查询用户列表", notes = "目前仅仅是作为测试,所以返回用户全列表") + public List list() { + // 查询列表 + List result = new ArrayList<>(); + result.add(new UserVO().setId(1).setUsername("yudaoyuanma")); + result.add(new UserVO().setId(2).setUsername("woshiyutou")); + result.add(new UserVO().setId(3).setUsername("chifanshuijiao")); + // 返回列表 + return result; + } + + @GetMapping("/get") + @ApiOperation("获得指定用户编号的用户") + @ApiImplicitParam(name = "id", value = "用户编号", paramType = "query", dataTypeClass = Integer.class, required = true, example = "1024") + public UserVO get(@RequestParam("id") Integer id) { + // 查询并返回用户 + return new UserVO().setId(id).setUsername(UUID.randomUUID().toString()); + } + + @PostMapping("add") + @ApiOperation("添加用户") + public Integer add(UserAddDTO addDTO) { + // 插入用户记录,返回编号 + Integer returnId = UUID.randomUUID().hashCode(); + // 返回用户编号 + return returnId; + } + + @PostMapping("/update") + @ApiOperation("更新指定用户编号的用户") + public Boolean update(UserUpdateDTO updateDTO) { + // 更新用户记录 + Boolean success = true; + // 返回更新是否成功 + return success; + } + + @PostMapping("/delete") + @ApiOperation(value = "删除指定用户编号的用户") + @ApiImplicitParam(name = "id", value = "用户编号", paramType = "query", dataTypeClass = Integer.class, required = true, example = "1024") + public Boolean delete(@RequestParam("id") Integer id) { + // 删除用户记录 + Boolean success = false; + // 返回是否更新成功 + return success; + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserAddDTO.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserAddDTO.java new file mode 100644 index 000000000..af181e690 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserAddDTO.java @@ -0,0 +1,32 @@ +package cn.iocoder.springboot.lab24.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("用户添加 DTO") +public class UserAddDTO { + + @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") + private String username; + @ApiModelProperty(value = "密码", required = true, example = "nicai") + private String password; + + public String getUsername() { + return username; + } + + public UserAddDTO setUsername(String username) { + this.username = username; + return this; + } + + public String getPassword() { + return password; + } + + public UserAddDTO setPassword(String password) { + this.password = password; + return this; + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserUpdateDTO.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserUpdateDTO.java new file mode 100644 index 000000000..3c92aeb8b --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/dto/UserUpdateDTO.java @@ -0,0 +1,43 @@ +package cn.iocoder.springboot.lab24.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("用户更新 DTO") +public class UserUpdateDTO { + + @ApiModelProperty(value = "用户编号", required = true, example = "1024") + private Integer id; + @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") + private String username; + @ApiModelProperty(value = "密码", required = true, example = "nicai") + private String password; + + public Integer getId() { + return id; + } + + public UserUpdateDTO setId(Integer id) { + this.id = id; + return this; + } + + public String getUsername() { + return username; + } + + public UserUpdateDTO setUsername(String username) { + this.username = username; + return this; + } + + public String getPassword() { + return password; + } + + public UserUpdateDTO setPassword(String password) { + this.password = password; + return this; + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/vo/UserVO.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/vo/UserVO.java new file mode 100644 index 000000000..4917916d9 --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/vo/UserVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.springboot.lab24.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel("用户 VO") +public class UserVO { + + @ApiModelProperty(value = "用户编号", required = true, example = "1024") + private Integer id; + @ApiModelProperty(value = "账号", required = true, example = "yudaoyuanma") + private String username; + + public Integer getId() { + return id; + } + + public UserVO setId(Integer id) { + this.id = id; + return this; + } + + public String getUsername() { + return username; + } + + public UserVO setUsername(String username) { + this.username = username; + return this; + } + +} diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/resources/application.yaml b/lab-24/lab-24-apidoc-swagger-starter/src/main/resources/application.yaml new file mode 100644 index 000000000..c4573845e --- /dev/null +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/resources/application.yaml @@ -0,0 +1,5 @@ +# 对应 SpringfoxConfigurationProperties 配置类 +springfox: + documentation: + swagger-ui: + enabled: true # 是否开启 Swagger UI 功能。默认为 true diff --git a/lab-24/pom.xml b/lab-24/pom.xml index 1c5c69a04..7d0bf03c5 100644 --- a/lab-24/pom.xml +++ b/lab-24/pom.xml @@ -15,6 +15,7 @@ lab-24-apidoc-swagger lab-24-apidoc-swagger-knife4j lab-24-apidoc-japidocs + lab-24-apidoc-swagger-starter From b8e503e4a319d6033524f82910b7f6493c994659 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 28 Nov 2020 19:02:58 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Swagger=20Starter=20?= =?UTF-8?q?=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + .../iocoder/springboot/lab24/config/SwaggerConfiguration.java | 3 ++- ...43 Swagger Starter \345\205\245\351\227\250\343\200\213.md" | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 "lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 Swagger Starter \345\205\245\351\227\250\343\200\213.md" diff --git a/README.md b/README.md index e5be0dddf..d04471af9 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ * [《芋道 Spring Boot WebFlux 入门》](http://www.iocoder.cn/Spring-Boot/WebFlux/?github) 对应 [lab-27](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-27) * [《芋道 Spring Boot 分布式 Session 入门》](http://www.iocoder.cn/Spring-Boot/Distributed-Session/?github) 对应 [lab-26](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-26) * [《芋道 Spring Boot API 接口文档 Swagger 入门》](http://www.iocoder.cn/Spring-Boot/Swagger/?github) 对应 [lab-24](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-24) +* [《芋道 Spring Boot API 接口文档 Swagger Starter 入门》](http://www.iocoder.cn/Spring-Boot/Swagger-Starter/?github) 对应 [lab-24](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-24) * [《芋道 Spring Boot 参数校验 Validation 入门》](http://www.iocoder.cn/Spring-Boot/Validation/?github) 对应 [lab-22](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-22) * [《芋道 Spring Boot WebSocket 入门》](http://www.iocoder.cn/Spring-Boot/WebSocket/?github) 对应 [lab-25](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-25) * [《性能测试 —— Tomcat、Jetty、Undertow 基准测试》](http://www.iocoder.cn/Performance-Testing/Tomcat-Jetty-Undertow-benchmark/?github) 对应 [lab-05-benchmark-tomcat-jetty-undertow](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-05-benchmark-tomcat-jetty-undertow) diff --git a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java index 1cc1fddd4..5ddcef502 100644 --- a/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java +++ b/lab-24/lab-24-apidoc-swagger-starter/src/main/java/cn/iocoder/springboot/lab24/config/SwaggerConfiguration.java @@ -1,6 +1,7 @@ package cn.iocoder.springboot.lab24.config; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; @@ -9,7 +10,7 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -//@Configuration +@Configuration // @EnableSwagger2 无需使用该注解 public class SwaggerConfiguration { diff --git "a/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 Swagger Starter \345\205\245\351\227\250\343\200\213.md" "b/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 Swagger Starter \345\205\245\351\227\250\343\200\213.md" new file mode 100644 index 000000000..e080075c0 --- /dev/null +++ "b/lab-24/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\346\226\207\346\241\243 Swagger Starter \345\205\245\351\227\250\343\200\213.md" @@ -0,0 +1 @@ + From 7ceb2933f5cd8bb4db4f16d2442b0c8dd6359a3f Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 12 Dec 2020 11:59:56 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20screw=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml | 37 ++++++++ .../src/main/java/ScrewMain.java | 84 +++++++++++++++++++ lab-70-db-doc/pom.xml | 19 +++++ pom.xml | 3 +- 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml create mode 100644 lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java create mode 100644 lab-70-db-doc/pom.xml diff --git a/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml b/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml new file mode 100644 index 000000000..16c284de1 --- /dev/null +++ b/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml @@ -0,0 +1,37 @@ + + + + lab-70-db-doc + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-70-db-doc-screw-01 + + + + + + + cn.smallbun.screw + screw-core + 1.0.5 + + + + + com.zaxxer + HikariCP + 3.4.5 + + + mysql + mysql-connector-java + 8.0.22 + + + + diff --git a/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java b/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java new file mode 100644 index 000000000..64b11c354 --- /dev/null +++ b/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java @@ -0,0 +1,84 @@ +import cn.smallbun.screw.core.Configuration; +import cn.smallbun.screw.core.engine.EngineConfig; +import cn.smallbun.screw.core.engine.EngineFileType; +import cn.smallbun.screw.core.engine.EngineTemplateType; +import cn.smallbun.screw.core.execute.DocumentationExecute; +import cn.smallbun.screw.core.process.ProcessConfig; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +import javax.sql.DataSource; +import java.util.Arrays; +import java.util.Collections; + +public class ScrewMain { + + private static final String DB_URL = "jdbc:mysql://400-infra.server.iocoder.cn:3306"; + private static final String DB_NAME = "mall_system"; + private static final String DB_USERNAME = "root"; + private static final String DB_PASSWORD = "3WLiVUBEwTbvAfsh"; + + private static final String FILE_OUTPUT_DIR = "/Users/yunai/screw_test"; + private static final EngineFileType FILE_OUTPUT_TYPE = EngineFileType.HTML; // 可以设置 WORD 或者 Markdown 格式 + private static final String DOC_FILE_NAME = "数据库文档"; + private static final String DOC_VERSION = "1.0.0"; + private static final String DOC_DESCRIPTION = "文档描述"; + + public static void main(String[] args) { + // 创建 screw 的配置 + Configuration config = Configuration.builder() + .version(DOC_VERSION) // 版本 + .description(DOC_DESCRIPTION) // 描述 + .dataSource(buildDataSource()) // 数据源 + .engineConfig(buildEngineConfig()) // 引擎配置 + .produceConfig(buildProcessConfig()) // 处理配置 + .build(); + + // 执行 screw,生成数据库文档 + new DocumentationExecute(config).execute(); + } + + /** + * 创建数据源 + */ + private static DataSource buildDataSource() { + // 创建 HikariConfig 配置类 + HikariConfig hikariConfig = new HikariConfig(); + hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); + hikariConfig.setJdbcUrl(DB_URL + "/" + DB_NAME); + hikariConfig.setUsername(DB_USERNAME); + hikariConfig.setPassword(DB_PASSWORD); + hikariConfig.addDataSourceProperty("useInformationSchema", "true"); // 设置可以获取 tables remarks 信息 + // 创建数据源 + return new HikariDataSource(hikariConfig); + } + + /** + * 创建 screw 的引擎配置 + */ + private static EngineConfig buildEngineConfig() { + return EngineConfig.builder() + .fileOutputDir(FILE_OUTPUT_DIR) // 生成文件路径 + .openOutputDir(false) // 打开目录 + .fileType(FILE_OUTPUT_TYPE) // 文件类型 + .produceType(EngineTemplateType.freemarker) // 文件类型 + .fileName(DOC_FILE_NAME) // 自定义文件名称 + .build(); + } + + /** + * 创建 screw 的处理配置,一般可忽略 + * 指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置 + */ + private static ProcessConfig buildProcessConfig() { + return ProcessConfig.builder() + .designatedTableName(Collections.emptyList()) // 根据名称指定表生成 + .designatedTablePrefix(Collections.emptyList()) //根据表前缀生成 + .designatedTableSuffix(Collections.emptyList()) // 根据表后缀生成 + .ignoreTableName(Arrays.asList("test_user", "test_group")) // 忽略表名 + .ignoreTablePrefix(Collections.singletonList("test_")) // 忽略表前缀 + .ignoreTableSuffix(Collections.singletonList("_test")) // 忽略表后缀 + .build(); + } + +} diff --git a/lab-70-db-doc/pom.xml b/lab-70-db-doc/pom.xml new file mode 100644 index 000000000..926091822 --- /dev/null +++ b/lab-70-db-doc/pom.xml @@ -0,0 +1,19 @@ + + + + labs-parent + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-70-db-doc + pom + + + lab-70-db-doc-screw-01 + + + diff --git a/pom.xml b/pom.xml index e37f78976..29ec927c3 100644 --- a/pom.xml +++ b/pom.xml @@ -31,7 +31,7 @@ - lab-24 + @@ -77,6 +77,7 @@ + lab-70-db-doc From ab27b89a71011809bb0d5c58b23b8bf8dbf8a5be Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 12 Dec 2020 20:07:52 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20screw=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml | 2 - .../src/main/java/ScrewMain.java | 2 +- lab-70-db-doc/lab-70-db-doc-screw-02/pom.xml | 60 +++++++++++++++++++ lab-70-db-doc/pom.xml | 1 + 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 lab-70-db-doc/lab-70-db-doc-screw-02/pom.xml diff --git a/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml b/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml index 16c284de1..9274e03a5 100644 --- a/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml +++ b/lab-70-db-doc/lab-70-db-doc-screw-01/pom.xml @@ -11,8 +11,6 @@ lab-70-db-doc-screw-01 - - diff --git a/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java b/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java index 64b11c354..9066c7a65 100644 --- a/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java +++ b/lab-70-db-doc/lab-70-db-doc-screw-01/src/main/java/ScrewMain.java @@ -19,7 +19,7 @@ public class ScrewMain { private static final String DB_PASSWORD = "3WLiVUBEwTbvAfsh"; private static final String FILE_OUTPUT_DIR = "/Users/yunai/screw_test"; - private static final EngineFileType FILE_OUTPUT_TYPE = EngineFileType.HTML; // 可以设置 WORD 或者 Markdown 格式 + private static final EngineFileType FILE_OUTPUT_TYPE = EngineFileType.HTML; // 可以设置 Word 或者 Markdown 格式 private static final String DOC_FILE_NAME = "数据库文档"; private static final String DOC_VERSION = "1.0.0"; private static final String DOC_DESCRIPTION = "文档描述"; diff --git a/lab-70-db-doc/lab-70-db-doc-screw-02/pom.xml b/lab-70-db-doc/lab-70-db-doc-screw-02/pom.xml new file mode 100644 index 000000000..1cbcc0718 --- /dev/null +++ b/lab-70-db-doc/lab-70-db-doc-screw-02/pom.xml @@ -0,0 +1,60 @@ + + + + lab-70-db-doc + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-70-db-doc-screw-02 + + + + + cn.smallbun.screw + screw-maven-plugin + 1.0.5 + + + + com.zaxxer + HikariCP + 3.4.5 + + + mysql + mysql-connector-java + 8.0.22 + + + + + com.mysql.cj.jdbc.Driver + jdbc:mysql://400-infra.server.iocoder.cn:3306/mall_system + root + 3WLiVUBEwTbvAfsh + + HTML + 数据库文档 + 测试文档名称 + 数据库文档生成 + ${project.version} + false + freemarker + + + + compile + + run + + + + + + + + diff --git a/lab-70-db-doc/pom.xml b/lab-70-db-doc/pom.xml index 926091822..1efc92b6f 100644 --- a/lab-70-db-doc/pom.xml +++ b/lab-70-db-doc/pom.xml @@ -14,6 +14,7 @@ lab-70-db-doc-screw-01 + lab-70-db-doc-screw-02 From 86723d75a99f43b6b671f2dd9fa207b3d40ef5f1 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 12 Dec 2020 22:04:57 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20screw=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=8E=A5=E5=8F=A3=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-70-db-doc/lab-70-db-doc-screw-03/pom.xml | 40 +++++++++++ .../src/main/java/ScrewMain.java | 72 +++++++++++++++++++ lab-70-db-doc/pom.xml | 1 + 3 files changed, 113 insertions(+) create mode 100644 lab-70-db-doc/lab-70-db-doc-screw-03/pom.xml create mode 100644 lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java diff --git a/lab-70-db-doc/lab-70-db-doc-screw-03/pom.xml b/lab-70-db-doc/lab-70-db-doc-screw-03/pom.xml new file mode 100644 index 000000000..bdeee8947 --- /dev/null +++ b/lab-70-db-doc/lab-70-db-doc-screw-03/pom.xml @@ -0,0 +1,40 @@ + + + + lab-70-db-doc + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-70-db-doc-screw-03 + + + + + cn.smallbun.screw + screw-core + 1.0.5 + + + cn.smallbun.screw + screw-extension + 1.0.5 + + + + + com.zaxxer + HikariCP + 3.4.5 + + + mysql + mysql-connector-java + 8.0.22 + + + + diff --git a/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java b/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java new file mode 100644 index 000000000..3a144630f --- /dev/null +++ b/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java @@ -0,0 +1,72 @@ +import cn.smallbun.screw.core.Configuration; +import cn.smallbun.screw.core.engine.EngineConfig; +import cn.smallbun.screw.core.engine.EngineFileType; +import cn.smallbun.screw.core.engine.EngineTemplateType; +import cn.smallbun.screw.core.execute.DocumentationExecute; +import cn.smallbun.screw.core.process.ProcessConfig; +import cn.smallbun.screw.extension.pojo.PojoConfiguration; +import cn.smallbun.screw.extension.pojo.execute.PojoExecute; +import cn.smallbun.screw.extension.pojo.strategy.HumpNameStrategy; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; + +import javax.sql.DataSource; +import java.util.Arrays; +import java.util.Collections; + +public class ScrewMain { + + private static final String DB_URL = "jdbc:mysql://400-infra.server.iocoder.cn:3306"; + private static final String DB_NAME = "mall_system"; + private static final String DB_USERNAME = "root"; + private static final String DB_PASSWORD = "3WLiVUBEwTbvAfsh"; + + private static final String FILE_OUTPUT_DIR = "/Users/yunai/screw_test"; + private static final String JAVA_CLASS_PACKAGE = "cn.iocoder.dataobject"; + + public static void main(String[] args) { + // 创建 screw 的配置 + PojoConfiguration config = PojoConfiguration.builder() + .path(FILE_OUTPUT_DIR) // 生成 POJO 相关的目录 + .packageName(JAVA_CLASS_PACKAGE) // 包名 + .nameStrategy(new HumpNameStrategy()) // 包名策略 + .useLombok(false) // 是否使用 Lombok + .dataSource(buildDataSource()) // 数据源 + .processConfig(buildProcessConfig()) // 处理配置 + .build(); + + // 执行 screw,生成 POJO 实体类 + new PojoExecute(config).execute(); + } + + /** + * 创建数据源 + */ + private static DataSource buildDataSource() { + // 创建 HikariConfig 配置类 + HikariConfig hikariConfig = new HikariConfig(); + hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver"); + hikariConfig.setJdbcUrl(DB_URL + "/" + DB_NAME); + hikariConfig.setUsername(DB_USERNAME); + hikariConfig.setPassword(DB_PASSWORD); + hikariConfig.addDataSourceProperty("useInformationSchema", "true"); // 设置可以获取 tables remarks 信息 + // 创建数据源 + return new HikariDataSource(hikariConfig); + } + + /** + * 创建 screw 的处理配置,一般可忽略 + * 指定生成逻辑、当存在指定表、指定表前缀、指定表后缀时,将生成指定表,其余表不生成、并跳过忽略表配置 + */ + private static ProcessConfig buildProcessConfig() { + return ProcessConfig.builder() + .designatedTableName(Collections.emptyList()) // 根据名称指定表生成 + .designatedTablePrefix(Collections.emptyList()) //根据表前缀生成 + .designatedTableSuffix(Collections.emptyList()) // 根据表后缀生成 + .ignoreTableName(Arrays.asList("test_user", "test_group")) // 忽略表名 + .ignoreTablePrefix(Collections.singletonList("test_")) // 忽略表前缀 + .ignoreTableSuffix(Collections.singletonList("_test")) // 忽略表后缀 + .build(); + } + +} diff --git a/lab-70-db-doc/pom.xml b/lab-70-db-doc/pom.xml index 1efc92b6f..55f7b46cf 100644 --- a/lab-70-db-doc/pom.xml +++ b/lab-70-db-doc/pom.xml @@ -15,6 +15,7 @@ lab-70-db-doc-screw-01 lab-70-db-doc-screw-02 + lab-70-db-doc-screw-03 From 8652a4c4f511fc84595c75abb81684bf132ace28 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 12 Dec 2020 22:58:13 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E3=80=8A=E8=8A=8B=E9=81=93=20Spring=20Bo?= =?UTF-8?q?ot=20=E6=95=B0=E6=8D=AE=E8=A1=A8=E7=BB=93=E6=9E=84=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + .../lab-70-db-doc-screw-03/src/main/java/ScrewMain.java | 5 ----- ...3\223\346\236\204\346\226\207\346\241\243\343\200\213.md" | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 "lab-70-db-doc/\343\200\212\350\212\213\351\201\223 Spring Boot \346\225\260\346\215\256\350\241\250\347\273\223\346\236\204\346\226\207\346\241\243\343\200\213.md" diff --git a/README.md b/README.md index d04471af9..be9cac702 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ * [《芋道 Spring Boot 多数据源(读写分离)入门》](http://www.iocoder.cn/Spring-Boot/dynamic-datasource/?github) 对应 [lab-17](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-17) * [《芋道 Spring Boot 分库分表入门》](http://www.iocoder.cn/Spring-Boot/sharding-datasource/?github) 对应 [lab-18](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-18) * [《芋道 Spring Boot 数据库版本管理入门》](http://www.iocoder.cn/Spring-Boot/database-version-control/?github) 对应 [lab-20](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-20) +* [《芋道 Spring Boot 数据表结构文档》](http://www.iocoder.cn/Spring-Boot/DB-Doc-screw/?github) 对应 [lab-70-db-doc](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-70-db-doc) **非关系数据库** diff --git a/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java b/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java index 3a144630f..ddc65ef89 100644 --- a/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java +++ b/lab-70-db-doc/lab-70-db-doc-screw-03/src/main/java/ScrewMain.java @@ -1,8 +1,3 @@ -import cn.smallbun.screw.core.Configuration; -import cn.smallbun.screw.core.engine.EngineConfig; -import cn.smallbun.screw.core.engine.EngineFileType; -import cn.smallbun.screw.core.engine.EngineTemplateType; -import cn.smallbun.screw.core.execute.DocumentationExecute; import cn.smallbun.screw.core.process.ProcessConfig; import cn.smallbun.screw.extension.pojo.PojoConfiguration; import cn.smallbun.screw.extension.pojo.execute.PojoExecute; diff --git "a/lab-70-db-doc/\343\200\212\350\212\213\351\201\223 Spring Boot \346\225\260\346\215\256\350\241\250\347\273\223\346\236\204\346\226\207\346\241\243\343\200\213.md" "b/lab-70-db-doc/\343\200\212\350\212\213\351\201\223 Spring Boot \346\225\260\346\215\256\350\241\250\347\273\223\346\236\204\346\226\207\346\241\243\343\200\213.md" new file mode 100644 index 000000000..b8566f54e --- /dev/null +++ "b/lab-70-db-doc/\343\200\212\350\212\213\351\201\223 Spring Boot \346\225\260\346\215\256\350\241\250\347\273\223\346\236\204\346\226\207\346\241\243\343\200\213.md" @@ -0,0 +1 @@ + From bfc48cf06e81801b66c723cb591fd6231cf6d198 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 19 Dec 2020 20:03:29 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20IDEA=20HTTP=20Client?= =?UTF-8?q?=20=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab-71-idea-http-client/pom.xml | 23 +++++++++ .../iocoder/springboot/lab71/Application.java | 13 +++++ .../lab71/controller/UserController.http | 18 +++++++ .../lab71/controller/UserController.java | 50 +++++++++++++++++++ .../springboot/lab71/vo/UserUpdateVO.java | 43 ++++++++++++++++ lab-71-http-debug/pom.xml | 18 +++++++ pom.xml | 3 +- 7 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 lab-71-http-debug/lab-71-idea-http-client/pom.xml create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/Application.java create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/vo/UserUpdateVO.java create mode 100644 lab-71-http-debug/pom.xml diff --git a/lab-71-http-debug/lab-71-idea-http-client/pom.xml b/lab-71-http-debug/lab-71-idea-http-client/pom.xml new file mode 100644 index 000000000..04b29abd9 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/pom.xml @@ -0,0 +1,23 @@ + + + + org.springframework.boot + spring-boot-starter-parent + 2.2.1.RELEASE + + + 4.0.0 + + lab-71-idea-http-client + + + + + org.springframework.boot + spring-boot-starter-web + + + + diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/Application.java b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/Application.java new file mode 100644 index 000000000..ba31cf786 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/Application.java @@ -0,0 +1,13 @@ +package cn.iocoder.springboot.lab71; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http new file mode 100644 index 000000000..0b6862587 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http @@ -0,0 +1,18 @@ +### 测试 /user/login:登陆成功 +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +### 测试 /user/get-current:获取成功 +GET http://127.0.0.1:8080/user/get-current +Authorization: token001 + +### 测试 /user/update:更新成功 +POST http://127.0.0.1:8080/user/update +Content-Type: application/json + +{ + "nickname": "我是昵称", + "gender": 1 +} diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java new file mode 100644 index 000000000..48c994511 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java @@ -0,0 +1,50 @@ +package cn.iocoder.springboot.lab71.controller; + +import cn.iocoder.springboot.lab71.vo.UserUpdateVO; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * 用户 Controller + * + * 示例代码,纯粹为了演示。 + */ +@RestController +public class UserController { + + private final Logger logger = LoggerFactory.getLogger(getClass()); + + @PostMapping("/user/login") + public Map login(@RequestParam("username") String username, + @RequestParam("password") String password) { + if ("yudaoyuanma".equals(username) && "123456".equals(password)) { + Map tokenMap = new HashMap<>(); + tokenMap.put("userId", 1); + tokenMap.put("token", "token001"); + return tokenMap; + } + throw new RuntimeException("小朋友,你的账号密码不正确哟!"); + } + + @GetMapping("/user/get-current") + public Map getCurrentUser(@RequestHeader("Authorization") String authorization) { + if ("token001".equals(authorization)) { + Map userInfo = new HashMap<>(); + userInfo.put("id", 1); + userInfo.put("gender", 1); + return userInfo; + } + throw new RuntimeException("小朋友,你没有登录哟!"); + } + + @PostMapping("/user/update") + public Boolean update(@RequestBody UserUpdateVO updateVO) { + logger.info("[update][收到更新请求:{}]", updateVO.toString()); + return true; + } + +} diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/vo/UserUpdateVO.java b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/vo/UserUpdateVO.java new file mode 100644 index 000000000..49eee053f --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/vo/UserUpdateVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.springboot.lab71.vo; + +/** + * 用户更新 VO + */ +public class UserUpdateVO { + + /** + * 昵称 + */ + private String nickname; + /** + * 性别 + */ + private Integer gender; + + public String getNickname() { + return nickname; + } + + public UserUpdateVO setNickname(String nickname) { + this.nickname = nickname; + return this; + } + + public Integer getGender() { + return gender; + } + + public UserUpdateVO setGender(Integer gender) { + this.gender = gender; + return this; + } + + @Override + public String toString() { + return "UserUpdateVO{" + + "nickname='" + nickname + '\'' + + ", gender=" + gender + + '}'; + } + +} diff --git a/lab-71-http-debug/pom.xml b/lab-71-http-debug/pom.xml new file mode 100644 index 000000000..74afc145f --- /dev/null +++ b/lab-71-http-debug/pom.xml @@ -0,0 +1,18 @@ + + + + labs-parent + cn.iocoder.springboot.labs + 1.0-SNAPSHOT + + 4.0.0 + + lab-71-http-debug + pom + + lab-71-idea-http-client + + + diff --git a/pom.xml b/pom.xml index 29ec927c3..c976242b6 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ - lab-70-db-doc + @@ -111,6 +111,7 @@ + lab-71-http-debug From 5c3eb270018b9b95563f0eb55070fb473a4b80b6 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sun, 20 Dec 2020 02:31:58 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20IDEA=20HTTP=20Client?= =?UTF-8?q?=20=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + httpRequests/2020-12-20T004250.200.json | 4 + httpRequests/2020-12-20T004328.500.json | 7 + httpRequests/2020-12-20T004337.200.json | 4 + httpRequests/2020-12-20T004347.200.json | 4 + httpRequests/2020-12-20T004347.500.json | 7 + httpRequests/2020-12-20T004358.200.json | 4 + httpRequests/2020-12-20T004358.500.json | 7 + httpRequests/2020-12-20T004401.200.json | 4 + httpRequests/2020-12-20T004401.500.json | 7 + httpRequests/2020-12-20T004538.200.json | 4 + httpRequests/2020-12-20T004547.500.json | 7 + httpRequests/2020-12-20T004638.500.json | 7 + httpRequests/2020-12-20T004645.500.json | 7 + httpRequests/2020-12-20T004809.200.json | 4 + httpRequests/2020-12-20T004813.500.json | 7 + httpRequests/2020-12-20T010724.200.json | 4 + httpRequests/2020-12-20T010738.200.json | 4 + httpRequests/2020-12-20T010809.200.json | 4 + httpRequests/2020-12-20T010823.500.json | 7 + httpRequests/2020-12-20T010840.200.json | 4 + httpRequests/2020-12-20T011020.500.json | 7 + httpRequests/2020-12-20T011347.500.json | 7 + httpRequests/2020-12-20T011526.200.json | 4 + httpRequests/2020-12-20T011530.200.json | 5 + httpRequests/2020-12-20T011541.400.json | 7 + httpRequests/2020-12-20T011551.500.json | 7 + httpRequests/2020-12-20T011556.200.json | 5 + httpRequests/2020-12-20T011628-1.200.json | 5 + httpRequests/2020-12-20T011628.200.json | 4 + httpRequests/2020-12-20T011646.200.json | 4 + httpRequests/2020-12-20T011650.200.json | 4 + httpRequests/2020-12-20T011653.500.json | 7 + httpRequests/2020-12-20T011818.200.json | 4 + httpRequests/2020-12-20T011843.200.json | 4 + httpRequests/2020-12-20T011847.500.json | 7 + httpRequests/2020-12-20T012507.200.json | 4 + httpRequests/2020-12-20T012510.200.json | 5 + httpRequests/2020-12-20T012527.200.json | 5 + httpRequests/2020-12-20T012540.400.json | 7 + httpRequests/2020-12-20T012544.200.json | 5 + httpRequests/2020-12-20T012703.500.json | 7 + httpRequests/2020-12-20T012708.200.json | 4 + httpRequests/2020-12-20T012710.200.json | 5 + httpRequests/2020-12-20T013544.200.json | 5 + httpRequests/2020-12-20T013552.200.json | 4 + httpRequests/2020-12-20T013558.500.json | 7 + httpRequests/2020-12-20T013845.200.json | 4 + httpRequests/2020-12-20T014019.200.json | 5 + httpRequests/2020-12-20T021415.200.json | 4 + httpRequests/http-client.cookies | 1 + httpRequests/http-requests-log.http | 410 ++++++++++++++++++ ...\346\241\243\345\220\215\347\247\260.html" | 21 + .../http-client.env.json | 8 + .../http-client.private.env.json | 12 + .../lab71/controller/UserController.http | 3 +- .../lab71/controller/UserController.java | 9 +- .../lab71/controller/UserController2.http | 19 + .../lab71/controller/UserController3.http | 25 ++ .../lab71/controller/UserController4.http | 13 + ...\350\257\225 IDEA HTTP Client\343\200\213" | 1 + 61 files changed, 779 insertions(+), 3 deletions(-) create mode 100644 httpRequests/2020-12-20T004250.200.json create mode 100644 httpRequests/2020-12-20T004328.500.json create mode 100644 httpRequests/2020-12-20T004337.200.json create mode 100644 httpRequests/2020-12-20T004347.200.json create mode 100644 httpRequests/2020-12-20T004347.500.json create mode 100644 httpRequests/2020-12-20T004358.200.json create mode 100644 httpRequests/2020-12-20T004358.500.json create mode 100644 httpRequests/2020-12-20T004401.200.json create mode 100644 httpRequests/2020-12-20T004401.500.json create mode 100644 httpRequests/2020-12-20T004538.200.json create mode 100644 httpRequests/2020-12-20T004547.500.json create mode 100644 httpRequests/2020-12-20T004638.500.json create mode 100644 httpRequests/2020-12-20T004645.500.json create mode 100644 httpRequests/2020-12-20T004809.200.json create mode 100644 httpRequests/2020-12-20T004813.500.json create mode 100644 httpRequests/2020-12-20T010724.200.json create mode 100644 httpRequests/2020-12-20T010738.200.json create mode 100644 httpRequests/2020-12-20T010809.200.json create mode 100644 httpRequests/2020-12-20T010823.500.json create mode 100644 httpRequests/2020-12-20T010840.200.json create mode 100644 httpRequests/2020-12-20T011020.500.json create mode 100644 httpRequests/2020-12-20T011347.500.json create mode 100644 httpRequests/2020-12-20T011526.200.json create mode 100644 httpRequests/2020-12-20T011530.200.json create mode 100644 httpRequests/2020-12-20T011541.400.json create mode 100644 httpRequests/2020-12-20T011551.500.json create mode 100644 httpRequests/2020-12-20T011556.200.json create mode 100644 httpRequests/2020-12-20T011628-1.200.json create mode 100644 httpRequests/2020-12-20T011628.200.json create mode 100644 httpRequests/2020-12-20T011646.200.json create mode 100644 httpRequests/2020-12-20T011650.200.json create mode 100644 httpRequests/2020-12-20T011653.500.json create mode 100644 httpRequests/2020-12-20T011818.200.json create mode 100644 httpRequests/2020-12-20T011843.200.json create mode 100644 httpRequests/2020-12-20T011847.500.json create mode 100644 httpRequests/2020-12-20T012507.200.json create mode 100644 httpRequests/2020-12-20T012510.200.json create mode 100644 httpRequests/2020-12-20T012527.200.json create mode 100644 httpRequests/2020-12-20T012540.400.json create mode 100644 httpRequests/2020-12-20T012544.200.json create mode 100644 httpRequests/2020-12-20T012703.500.json create mode 100644 httpRequests/2020-12-20T012708.200.json create mode 100644 httpRequests/2020-12-20T012710.200.json create mode 100644 httpRequests/2020-12-20T013544.200.json create mode 100644 httpRequests/2020-12-20T013552.200.json create mode 100644 httpRequests/2020-12-20T013558.500.json create mode 100644 httpRequests/2020-12-20T013845.200.json create mode 100644 httpRequests/2020-12-20T014019.200.json create mode 100644 httpRequests/2020-12-20T021415.200.json create mode 100644 httpRequests/http-client.cookies create mode 100644 httpRequests/http-requests-log.http create mode 100644 "lab-70-db-doc/lab-70-db-doc-screw-02/doc/\346\265\213\350\257\225\346\226\207\346\241\243\345\220\215\347\247\260.html" create mode 100644 lab-71-http-debug/lab-71-idea-http-client/http-client.env.json create mode 100644 lab-71-http-debug/lab-71-idea-http-client/http-client.private.env.json create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController2.http create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController3.http create mode 100644 lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController4.http create mode 100644 "lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" diff --git a/README.md b/README.md index be9cac702..d0fa02e16 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ * [《性能测试 —— Tomcat、Jetty、Undertow 基准测试》](http://www.iocoder.cn/Performance-Testing/Tomcat-Jetty-Undertow-benchmark/?github) 对应 [lab-05-benchmark-tomcat-jetty-undertow](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-05-benchmark-tomcat-jetty-undertow) * [《性能测试 —— SpringMVC、Webflux 基准测试》](http://www.iocoder.cn/Performance-Testing/SpringMVC-Webflux-benchmark/?github) 对应 [lab-06](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-06) * [《芋道 Spring Boot API 接口文档 JApiDocs 入门》](http://www.iocoder.cn/Spring-Boot/JApiDocs/?github) 对应 [lab-24](https://github.com/YunaiV/SpringBoot-Labs/tree/master/lab-24) +* [《芋道 Spring Boot API 接口调试 IDEA HTTP Client》](http://www.iocoder.cn/Spring-Boot/IDEA-HTTP-Client/?github) 对应 [lab-71-http-debug](https://github.com/YunaiV/SpringBoot-Labs/blob/master/lab-71-http-debug/) ## RPC 开发 diff --git a/httpRequests/2020-12-20T004250.200.json b/httpRequests/2020-12-20T004250.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004250.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004328.500.json b/httpRequests/2020-12-20T004328.500.json new file mode 100644 index 000000000..644fcf6ad --- /dev/null +++ b/httpRequests/2020-12-20T004328.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:43:28.332+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004337.200.json b/httpRequests/2020-12-20T004337.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004337.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004347.200.json b/httpRequests/2020-12-20T004347.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004347.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004347.500.json b/httpRequests/2020-12-20T004347.500.json new file mode 100644 index 000000000..cf826d14a --- /dev/null +++ b/httpRequests/2020-12-20T004347.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:43:47.777+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004358.200.json b/httpRequests/2020-12-20T004358.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004358.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004358.500.json b/httpRequests/2020-12-20T004358.500.json new file mode 100644 index 000000000..0a04daa9d --- /dev/null +++ b/httpRequests/2020-12-20T004358.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:43:58.210+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004401.200.json b/httpRequests/2020-12-20T004401.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004401.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004401.500.json b/httpRequests/2020-12-20T004401.500.json new file mode 100644 index 000000000..6b8986c38 --- /dev/null +++ b/httpRequests/2020-12-20T004401.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:44:01.275+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004538.200.json b/httpRequests/2020-12-20T004538.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004538.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004547.500.json b/httpRequests/2020-12-20T004547.500.json new file mode 100644 index 000000000..a13aef28a --- /dev/null +++ b/httpRequests/2020-12-20T004547.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:45:47.364+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004638.500.json b/httpRequests/2020-12-20T004638.500.json new file mode 100644 index 000000000..6c69c53ad --- /dev/null +++ b/httpRequests/2020-12-20T004638.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:46:38.505+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004645.500.json b/httpRequests/2020-12-20T004645.500.json new file mode 100644 index 000000000..ff38c72d9 --- /dev/null +++ b/httpRequests/2020-12-20T004645.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:46:45.875+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T004809.200.json b/httpRequests/2020-12-20T004809.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T004809.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T004813.500.json b/httpRequests/2020-12-20T004813.500.json new file mode 100644 index 000000000..c1b0a3eb3 --- /dev/null +++ b/httpRequests/2020-12-20T004813.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T16:48:13.674+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T010724.200.json b/httpRequests/2020-12-20T010724.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T010724.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T010738.200.json b/httpRequests/2020-12-20T010738.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T010738.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T010809.200.json b/httpRequests/2020-12-20T010809.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T010809.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T010823.500.json b/httpRequests/2020-12-20T010823.500.json new file mode 100644 index 000000000..731dc2e72 --- /dev/null +++ b/httpRequests/2020-12-20T010823.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:08:23.036+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T010840.200.json b/httpRequests/2020-12-20T010840.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T010840.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011020.500.json b/httpRequests/2020-12-20T011020.500.json new file mode 100644 index 000000000..f503745d6 --- /dev/null +++ b/httpRequests/2020-12-20T011020.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:10:20.615+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你的账号密码不正确哟!", + "path": "/user/login" +} diff --git a/httpRequests/2020-12-20T011347.500.json b/httpRequests/2020-12-20T011347.500.json new file mode 100644 index 000000000..9cfba0e4c --- /dev/null +++ b/httpRequests/2020-12-20T011347.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:13:47.777+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T011526.200.json b/httpRequests/2020-12-20T011526.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011526.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011530.200.json b/httpRequests/2020-12-20T011530.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T011530.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T011541.400.json b/httpRequests/2020-12-20T011541.400.json new file mode 100644 index 000000000..15edabcae --- /dev/null +++ b/httpRequests/2020-12-20T011541.400.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:15:40.992+0000", + "status": 400, + "error": "Bad Request", + "message": "Missing request header 'Authorization' for method parameter of type String", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T011551.500.json b/httpRequests/2020-12-20T011551.500.json new file mode 100644 index 000000000..5d2c5e84d --- /dev/null +++ b/httpRequests/2020-12-20T011551.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:15:51.919+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T011556.200.json b/httpRequests/2020-12-20T011556.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T011556.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T011628-1.200.json b/httpRequests/2020-12-20T011628-1.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T011628-1.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T011628.200.json b/httpRequests/2020-12-20T011628.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011628.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011646.200.json b/httpRequests/2020-12-20T011646.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011646.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011650.200.json b/httpRequests/2020-12-20T011650.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011650.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011653.500.json b/httpRequests/2020-12-20T011653.500.json new file mode 100644 index 000000000..0e2e8459f --- /dev/null +++ b/httpRequests/2020-12-20T011653.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:16:53.489+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T011818.200.json b/httpRequests/2020-12-20T011818.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011818.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011843.200.json b/httpRequests/2020-12-20T011843.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T011843.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T011847.500.json b/httpRequests/2020-12-20T011847.500.json new file mode 100644 index 000000000..722c8464d --- /dev/null +++ b/httpRequests/2020-12-20T011847.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:18:47.862+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T012507.200.json b/httpRequests/2020-12-20T012507.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T012507.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T012510.200.json b/httpRequests/2020-12-20T012510.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T012510.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T012527.200.json b/httpRequests/2020-12-20T012527.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T012527.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T012540.400.json b/httpRequests/2020-12-20T012540.400.json new file mode 100644 index 000000000..98226c043 --- /dev/null +++ b/httpRequests/2020-12-20T012540.400.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:25:40.604+0000", + "status": 400, + "error": "Bad Request", + "message": "Missing request header 'Authorization' for method parameter of type String", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T012544.200.json b/httpRequests/2020-12-20T012544.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T012544.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T012703.500.json b/httpRequests/2020-12-20T012703.500.json new file mode 100644 index 000000000..02fa3b6db --- /dev/null +++ b/httpRequests/2020-12-20T012703.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:27:03.272+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T012708.200.json b/httpRequests/2020-12-20T012708.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T012708.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T012710.200.json b/httpRequests/2020-12-20T012710.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T012710.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T013544.200.json b/httpRequests/2020-12-20T013544.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T013544.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T013552.200.json b/httpRequests/2020-12-20T013552.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T013552.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T013558.500.json b/httpRequests/2020-12-20T013558.500.json new file mode 100644 index 000000000..2f50b5a68 --- /dev/null +++ b/httpRequests/2020-12-20T013558.500.json @@ -0,0 +1,7 @@ +{ + "timestamp": "2020-12-19T17:35:58.033+0000", + "status": 500, + "error": "Internal Server Error", + "message": "小朋友,你没有登录哟!", + "path": "/user/get-current" +} diff --git a/httpRequests/2020-12-20T013845.200.json b/httpRequests/2020-12-20T013845.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T013845.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/2020-12-20T014019.200.json b/httpRequests/2020-12-20T014019.200.json new file mode 100644 index 000000000..fadf0411e --- /dev/null +++ b/httpRequests/2020-12-20T014019.200.json @@ -0,0 +1,5 @@ +{ + "gender": 1, + "nickname": "芋道源码", + "id": 1 +} diff --git a/httpRequests/2020-12-20T021415.200.json b/httpRequests/2020-12-20T021415.200.json new file mode 100644 index 000000000..2f407b874 --- /dev/null +++ b/httpRequests/2020-12-20T021415.200.json @@ -0,0 +1,4 @@ +{ + "userId": 1, + "token": "token001" +} diff --git a/httpRequests/http-client.cookies b/httpRequests/http-client.cookies new file mode 100644 index 000000000..edfe326f9 --- /dev/null +++ b/httpRequests/http-client.cookies @@ -0,0 +1 @@ +# domain path name value date diff --git a/httpRequests/http-requests-log.http b/httpRequests/http-requests-log.http new file mode 100644 index 000000000..0c9102bef --- /dev/null +++ b/httpRequests/http-requests-log.http @@ -0,0 +1,410 @@ +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T021415.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T014019.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T013845.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: 1 + +<> 2020-12-20T013558.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T013552.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T013544.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T012710.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T012708.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: {{token_from_server}} + +<> 2020-12-20T012703.500.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: {{token_from_server}} + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T012544.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true + +<> 2020-12-20T012540.400.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T012527.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T012510.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T012507.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: 1 + +<> 2020-12-20T011847.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011843.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011818.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: 0 + +<> 2020-12-20T011653.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011650.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011646.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T011628-1.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011628.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T011556.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: {{token_from_server1}} + +<> 2020-12-20T011551.500.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true + +<> 2020-12-20T011541.400.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token001 + +<> 2020-12-20T011530.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T011526.200.json + +### + +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: token002 + +<> 2020-12-20T011347.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T011020.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T010840.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T010823.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T010809.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T010738.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T010724.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004813.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004809.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004645.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004638.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004547.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004538.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004401.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004401.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004358.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004358.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004347.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004347.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004337.200.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +<> 2020-12-20T004328.500.json + +### + +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +<> 2020-12-20T004250.200.json + +### + diff --git "a/lab-70-db-doc/lab-70-db-doc-screw-02/doc/\346\265\213\350\257\225\346\226\207\346\241\243\345\220\215\347\247\260.html" "b/lab-70-db-doc/lab-70-db-doc-screw-02/doc/\346\265\213\350\257\225\346\226\207\346\241\243\345\220\215\347\247\260.html" new file mode 100644 index 000000000..a85a67aa7 --- /dev/null +++ "b/lab-70-db-doc/lab-70-db-doc-screw-02/doc/\346\265\213\350\257\225\346\226\207\346\241\243\345\220\215\347\247\260.html" @@ -0,0 +1,21 @@ +数据库文档

数据库文档

数据库名:mall_system
文档版本:1.0-SNAPSHOT
文档描述:数据库文档生成
序号表名说明
1admin管理员
2admin_department部门
3oauth2_access_token访问令牌
4oauth2_refresh_token刷新令牌
5permission_admin_role管理员角色
6permission_resource资源
7permission_role角色
8permission_role_resource角色资源
9system_access_log系统访问日志
10system_data_dict数据字典
11system_error_code错误码
12system_exception_log系统异常日志
13_operation_log操作日志
返回目录表名:admin
说明:管理员
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY管理员编号
2namevarchar100NN真实名字
3avatarvarchar2550YN头像
4department_idint100YN部门id
5statustinyint40NN在职状态
6usernamevarchar160NN登陆账号
7passwordvarchar2550NN加密后的密码
8password_saltvarchar640NN密码的盐
9create_admin_idint100NN创建管理员编号
10create_ipvarchar320NN创建 IP
11create_timedatetime190NNCURRENT_TIMESTAMP创建时间
12update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
返回目录表名:admin_department
说明:部门
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY部门编号
2namevarchar1000NN部门名称
3sortint100NN0排序字段
4pidint100NN0父级部门编号
5create_timetimestamp190NNCURRENT_TIMESTAMP创建时间
6update_timetimestamp190NNCURRENT_TIMESTAMP更新时间
7deletedbit10NNb'0'删除标记
返回目录表名:oauth2_access_token
说明:访问令牌
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idvarchar320NY访问令牌
2user_idint100NN用户编号
3user_typetinyint40NN用户类型
4refresh_tokenvarchar320NN刷新令牌
5expires_timedatetime190NN过期时间
6create_ipvarchar320NN创建 IP
7create_timedatetime190NNCURRENT_TIMESTAMP创建时间
8update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
9deletedbit10NNb'0'是否删除
返回目录表名:oauth2_refresh_token
说明:刷新令牌
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idvarchar320NY编号,刷新令牌
2user_idint100NN用户编号
3user_typetinyint40NN用户类型
4expires_timedatetime190NN过期时间
5create_ipvarchar320NN创建 IP
6create_timedatetime190NNCURRENT_TIMESTAMP创建时间
7update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
8deletedbit10NNb'0'是否删除
返回目录表名:permission_admin_role
说明:管理员角色
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2admin_idint100NN管理员编号
3role_idint100NN角色编号
4create_timedatetime190NNCURRENT_TIMESTAMP创建时间
5update_timedatetime190NNCURRENT_TIMESTAMP更新时间
6deletedbit10YNb'0'是否删除
返回目录表名:permission_resource
说明:资源
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY资源编号
2namevarchar500NN菜单名
3permissionvarchar2550YN权限标识
4typeint100NN资源类型
5sortint100NN排序
6pidint100NN0父级资源编号(外键:{@link ResourceDO#id})
7routevarchar500YN前端路由
8iconvarchar500YN菜单图标
9viewvarchar500YN前端界面
10create_admin_idint100NN创建管理员编号
11create_timedatetime190NNCURRENT_TIMESTAMP添加时间
12update_timedatetime190NNCURRENT_TIMESTAMP更新时间
13deletedbit10NNb'0'是否删除
返回目录表名:permission_role
说明:角色
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY角色编号
2namevarchar500NN角色名
3codevarchar500YN角色编码
4typetinyint40NN角色类型
5create_admin_idint100NN创建管理员编号
6create_timedatetime190NNCURRENT_TIMESTAMP创建时间
7update_timedatetime190YNCURRENT_TIMESTAMP最后更新时间
8deletedbit10NNb'0'是否删除
返回目录表名:permission_role_resource
说明:角色资源
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2role_idint100NN-1角色编号(外键:{@link RoleDO}
3resource_idint100NN-1资源编号
4create_timedatetime190NNCURRENT_TIMESTAMP创建时间
5update_timedatetime190NNCURRENT_TIMESTAMP更新时间
6deletedbit10NNb'0'是否删除
返回目录表名:system_access_log
说明:系统访问日志
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2user_idint100YN用户编号
3user_typetinyint40YN用户类型
4trace_idvarchar640YN链路追踪编号
5application_namevarchar500NN应用名
6urivarchar40960NN访问地址
7query_stringvarchar40960NN参数
8methodvarchar500NNhttp 方法
9user_agentvarchar10240NNuserAgent
10ipvarchar500NNip
11start_timedatetime190NN请求时间
12response_timeint100NN响应时长 -- 毫秒级
13error_codeint100NN错误码
14error_messagevarchar5120YN错误提示
15create_timedatetime190NNCURRENT_TIMESTAMP创建时间
16update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
返回目录表名:system_data_dict
说明:数据字典
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2enum_valuevarchar500NN大类枚举值
3valuevarchar500NN小类数值
4display_namevarchar500NN展示名
5sortint100NN-1排序值
6memovarchar500YN备注
7create_timedatetime190NNCURRENT_TIMESTAMP创建时间
8update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
9deletedbit10NNb'0'是否删除
返回目录表名:system_error_code
说明:错误码
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY错误码编号
2codeint100NN0错误码编码
3messagevarchar2550NN错误码错误提示
4typetinyint40NN错误码类型
5groupvarchar640NN错误码分组
6memovarchar2550YN错误码备注
7create_timedatetime190NNCURRENT_TIMESTAMP创建时间
8update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
9deletedbit10NNb'0'是否删除
返回目录表名:system_exception_log
说明:系统异常日志
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2user_idint100YN用户编号
3user_typetinyint40YN用户类型
4trace_idvarchar640NN链路追踪编号 + * + * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。
5application_namevarchar500NN应用名 + * + * 目前读取 spring.application.name
6urivarchar40960NN访问地址
7query_stringvarchar40960NN参数
8methodvarchar500NNhttp 方法
9user_agentvarchar10240NNuserAgent
10ipvarchar500NNip
11exception_timedatetime190NN异常发生时间
12exception_namevarchar1280NN异常名 + * + * {@link Throwable#getClass()} 的类全名
13exception_messagetext655350NN异常导致的消息 + * + * {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}
14exception_root_cause_messagetext655350NN异常导致的根消息 + * + * {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}
15exception_stack_tracetext655350NN异常的栈轨迹 + * + * {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}
16exception_class_namevarchar5120NN异常发生的类全名 + * + * {@link StackTraceElement#getClassName()}
17exception_file_namevarchar5120NN异常发生的类文件 + * + * {@link StackTraceElement#getFileName()}
18exception_method_namevarchar5120NN异常发生的方法名 + * + * {@link StackTraceElement#getMethodName()}
19exception_line_numberint100NN异常发生的方法所在行 + * + * {@link StackTraceElement#getLineNumber()}
20process_statustinyint40NN0处理状态
21process_timedatetime190YN处理时间
22process_admin_idint100YN处理管理员编号
23create_timedatetime190NNCURRENT_TIMESTAMP创建时间
24update_timedatetime190NNCURRENT_TIMESTAMP最后更新时间
返回目录表名:_operation_log
说明:操作日志
数据列:
序号名称数据类型长度小数位允许空值主键默认值说明
1idint100NY编号
2trace_idvarchar640YN链路追踪编号
3account_idint100NN-1账号编号
4application_namevarchar500YN应用名
5urivarchar40960NN访问地址
6paramsvarchar40960NN参数
7methodvarchar500NNhttp 方法
8user_agentvarchar10240NNuserAgent
9ipvarchar500NNip
10start_timedatetime190NN请求时间
11response_timeint100NN响应时长 -- 毫秒级
12msgvarchar2550YN日志消息
13statusbit10NN操作状态
14operatorvarchar640YN创建者
15create_timedatetime190NN创建时间
\ No newline at end of file diff --git a/lab-71-http-debug/lab-71-idea-http-client/http-client.env.json b/lab-71-http-debug/lab-71-idea-http-client/http-client.env.json new file mode 100644 index 000000000..f35e8548b --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/http-client.env.json @@ -0,0 +1,8 @@ +{ + "local": { + "baseUrl": "http://127.0.0.1:8080" + }, + "dev": { + "baseUrl": "http://192.168.100.200:8080" + } +} diff --git a/lab-71-http-debug/lab-71-idea-http-client/http-client.private.env.json b/lab-71-http-debug/lab-71-idea-http-client/http-client.private.env.json new file mode 100644 index 000000000..813df3c93 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/http-client.private.env.json @@ -0,0 +1,12 @@ +{ + "local": { + "username": "yudaoyuanma", + "password": "123456", + "token": "token001" + }, + "dev": { + "username": "yutou", + "password": "buzhidao", + "token": "aoteman" + } +} diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http index 0b6862587..ecbc592b8 100644 --- a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.http @@ -5,7 +5,7 @@ Content-Type: application/x-www-form-urlencoded username=yudaoyuanma&password=123456 ### 测试 /user/get-current:获取成功 -GET http://127.0.0.1:8080/user/get-current +GET http://127.0.0.1:8080/user/get-current?full=true Authorization: token001 ### 测试 /user/update:更新成功 @@ -16,3 +16,4 @@ Content-Type: application/json "nickname": "我是昵称", "gender": 1 } + diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java index 48c994511..549868bfd 100644 --- a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController.java @@ -31,11 +31,16 @@ public Map login(@RequestParam("username") String username, } @GetMapping("/user/get-current") - public Map getCurrentUser(@RequestHeader("Authorization") String authorization) { + public Map getCurrentUser(@RequestHeader("Authorization") String authorization, + @RequestParam("full") boolean full) { if ("token001".equals(authorization)) { Map userInfo = new HashMap<>(); userInfo.put("id", 1); - userInfo.put("gender", 1); + // full 为 true 时,获得完整信息 + if (full) { + userInfo.put("nickname", "芋道源码"); + userInfo.put("gender", 1); + } return userInfo; } throw new RuntimeException("小朋友,你没有登录哟!"); diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController2.http b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController2.http new file mode 100644 index 000000000..69d2cd561 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController2.http @@ -0,0 +1,19 @@ +### 测试 /user/login:登陆成功 +POST {{baseUrl}}/user/login +Content-Type: application/x-www-form-urlencoded + +username={{username}}&password={{password}} + +### 测试 /user/get-current:获取成功 +GET {{baseUrl}}/user/get-current?full=true +Authorization: {{token}} + +### 测试 /user/update:更新成功 +POST {{baseUrl}}/user/update +Content-Type: application/json + +{ + "nickname": "我是昵称", + "gender": 1 +} + diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController3.http b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController3.http new file mode 100644 index 000000000..79a3dee0d --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController3.http @@ -0,0 +1,25 @@ +### 001 测试 /user/login:登陆成功 +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +> {% +client.test("验证登陆成功", function (){ + client.assert(response.status === 200, "响应状态应该是 200,结果是 " + response.status) + client.assert(response.body.userId === 1, "响应的 userId 应该是 1,结果是 " + response.body.userId) + client.assert(response.body.token === "token001", "响应的 token 应该是 token001,记过是 " + response.body.token) +}); +%} + +### 002 测试 /user/login:登陆失败,密码不正确 +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=buzhidao + +> {% +client.test("验证登陆失败", function (){ + client.assert(response.status === 200, "响应状态应该是 200,结果是 " + response.status) +}); +%} diff --git a/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController4.http b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController4.http new file mode 100644 index 000000000..ae43973f3 --- /dev/null +++ b/lab-71-http-debug/lab-71-idea-http-client/src/main/java/cn/iocoder/springboot/lab71/controller/UserController4.http @@ -0,0 +1,13 @@ +### 测试 /user/login:登陆成功 +POST http://127.0.0.1:8080/user/login +Content-Type: application/x-www-form-urlencoded + +username=yudaoyuanma&password=123456 + +> {% +client.global.set("token_from_server", response.body.token) +%} + +### 测试 /user/get-current:获取成功 +GET http://127.0.0.1:8080/user/get-current?full=true +Authorization: {{token_from_server}} diff --git "a/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" "b/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" new file mode 100644 index 000000000..c0b4e4a68 --- /dev/null +++ "b/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" @@ -0,0 +1 @@ +http://www.iocoder.cn/Spring-Boot/IDEA-HTTP-Client/?github From 81755e2ce7fac3a5f7d73481aa782790d0dab55e Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sun, 20 Dec 2020 02:47:22 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20IDEA=20HTTP=20Client?= =?UTF-8?q?=20=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" | 1 - ...\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213.md" | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 "lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" create mode 100644 "lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213.md" diff --git "a/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" "b/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" deleted file mode 100644 index c0b4e4a68..000000000 --- "a/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213" +++ /dev/null @@ -1 +0,0 @@ -http://www.iocoder.cn/Spring-Boot/IDEA-HTTP-Client/?github diff --git "a/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213.md" "b/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213.md" new file mode 100644 index 000000000..05d591744 --- /dev/null +++ "b/lab-71-http-debug/\343\200\212\350\212\213\351\201\223 Spring Boot API \346\216\245\345\217\243\350\260\203\350\257\225 IDEA HTTP Client\343\200\213.md" @@ -0,0 +1 @@ + From 1f04682c16801665ced72d76e831bb42dee5b75f Mon Sep 17 00:00:00 2001 From: zhanghonghao <287232522@qq.com> Date: Fri, 2 Apr 2021 15:47:40 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=8F=90=E4=BA=A4pom=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-04-rabbitmq/lab-04-rabbitmq-native/pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lab-04-rabbitmq/lab-04-rabbitmq-native/pom.xml b/lab-04-rabbitmq/lab-04-rabbitmq-native/pom.xml index 9ed25eafe..9129e03ad 100644 --- a/lab-04-rabbitmq/lab-04-rabbitmq-native/pom.xml +++ b/lab-04-rabbitmq/lab-04-rabbitmq-native/pom.xml @@ -3,9 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - lab-04 - cn.iocoder.springboot.labs - 1.0-SNAPSHOT + org.springframework.boot + spring-boot-starter-parent + 2.2.1.RELEASE + 4.0.0