From 9f504e7f7971f4504a5ce10fa67dbef6e4ecaddb Mon Sep 17 00:00:00 2001 From: kings <963987632@qq.com> Date: Sat, 2 Nov 2019 14:14:32 +0800 Subject: [PATCH] =?UTF-8?q?1.0.3:=E5=9D=90=E6=A0=87=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ISSUE_TEMPLATE/-bug.md | 2 +- CONTRIBUTING.md | 4 +- README.md | 65 ++++--------------- pom.xml | 2 +- .../rap2/generator}/config/ParseConfig.java | 2 +- .../generator}/config/ResponseResultData.java | 2 +- .../generator}/config/ResponseResultType.java | 2 +- .../config/ResponseTemplateConfig.java | 2 +- .../rap2/generator}/config/Summary.java | 2 +- .../rap2/generator}/core/Rap2Generator.java | 6 +- .../rap2/generator}/model/Rap2Response.java | 2 +- .../generator}/util/ParseConfigJsonUtil.java | 4 +- 12 files changed, 27 insertions(+), 68 deletions(-) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/config/ParseConfig.java (97%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/config/ResponseResultData.java (96%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/config/ResponseResultType.java (93%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/config/ResponseTemplateConfig.java (91%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/config/Summary.java (95%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/core/Rap2Generator.java (99%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/model/Rap2Response.java (70%) rename src/main/java/{com/kings/rap => io/github/kings1990/rap2/generator}/util/ParseConfigJsonUtil.java (90%) diff --git a/.github/ISSUE_TEMPLATE/-bug.md b/.github/ISSUE_TEMPLATE/-bug.md index e7e50ab..182a28b 100644 --- a/.github/ISSUE_TEMPLATE/-bug.md +++ b/.github/ISSUE_TEMPLATE/-bug.md @@ -11,7 +11,7 @@ assignees: kings1990 -### 该问题是怎么引起的?**([最新版](https://search.maven.org/search?q=kings-rap2-generator)上已修复的会直接**close**掉)** +### 该问题是怎么引起的?**([最新版](https://search.maven.org/search?q=rap2-generator)上已修复的会直接**close**掉)** diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b3ae99..728344e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,12 +11,12 @@ 本地测试打包请把maven GPG插件去除 # 测试 -测试demo地址:[https://github.com/kings1990/kings-rap2-generator-demo](https://github.com/kings1990/kings-rap2-generator-demo),请发起测试代码的pull request,测试形式以junit的形式执行。 +测试demo地址:[https://github.com/kings1990/rap2-generator-demo](https://github.com/kings1990/rap2-generator-demo),请发起测试代码的pull request,测试形式以junit的形式执行。 提交代码需要新增一个rap2仓库,并且命名好仓库名称,请在新增的仓库里面做测试。 # 提交更改 -请发送一个[pull request](https://github.com/kings1990/kings-rap2-generator/pulls),并附上你所做的事情的清晰列表。当你发送一个拉请求,最好是带上测试程序。我们总是可以使用更多的测试覆盖率。请遵循我们的编码约定(如下),并确保所有提交都是原子性的(每次提交一个特性)。 +请发送一个[pull request](https://github.com/kings1990/rap2-generator/pulls),并附上你所做的事情的清晰列表。当你发送一个拉请求,最好是带上测试程序。我们总是可以使用更多的测试覆盖率。请遵循我们的编码约定(如下),并确保所有提交都是原子性的(每次提交一个特性)。 请申明你是在哪个版本的基础上改的 始终为您的提交编写一个清晰的日志消息。单行消息适用于小的更改,但是较大的更改应该如下所示: diff --git a/README.md b/README.md index fc50ac1..79ee5c6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# kings-rap2-generator +# rap2-generator ## 最新版本 ``` @@ -33,7 +33,7 @@ public class KingsBankCard { ## 2.使用 ### 2.0 maven引入 -最新版本([search.maven.org](https://search.maven.org/search?q=kings-rap2-generator)搜索坐标kings-rap2-generator) +最新版本([search.maven.org](https://search.maven.org/search?q=rap2-generator)搜索坐标rap2-generator) ``` io.github.kings1990 @@ -118,7 +118,7 @@ body参数格式,支持4种格式: 自定义响应模板路径,第3节有详细配置 -注意:`responseResultType`、`responseResultData属性可参考`[json参数帮助向导.md](https://github.com/kings1990/kings-rap2-generator/blob/master/json参数帮助向导.md) +注意:`responseResultType`、`responseResultData属性可参考`[json参数帮助向导.md](https://github.com/kings1990/rap2-generator/blob/master/json参数帮助向导.md) > demojson @@ -131,7 +131,7 @@ body参数格式,支持4种格式: "sig": "APDaceKunTDlPWdw0Solb6PiqeU", "repositoryId":235211, "interfaceId": 1349715, - "packageName": "com.kings.rap2.test.model", + "packageName": "io.github.kings1990.rap2.generator.test.model", "requestJavaClassname": "KingsQueryVo", "responseJavaClassname": "KingsHobby", "bodyOption": "FORM_DATA", @@ -148,53 +148,12 @@ body参数格式,支持4种格式: ### 2.2 执行 >a.使用json配置的形式执行(推荐) ``` -import com.kings.rap.config.ParseConfig; -import com.kings.rap.core.KingsRap2; -import com.kings.rap.util.ParseConfigJsonUtil; - -public class TestByJson { - public static void main(String[] args) throws Exception{ - ParseConfig parseConfig = ParseConfigJsonUtil.parseByFile("TestByJson.json"); - KingsRap2 kingsRap2 = new KingsRap2(); - kingsRap2.setParseConfig(parseConfig); - kingsRap2.doRap2(); - } -} -``` - ->b.使用代码的形式执行(不推荐) -``` -import com.kings.rap.config.ParseConfig; -import com.kings.rap.config.ResponseResultData; -import com.kings.rap.config.ResponseResultType; -import com.kings.rap.config.Summary; -import com.kings.rap.core.KingsRap2; - -public class Test4ModelWithAuthor { - - public static void main(String[] args) throws Exception{ - String domainAndPortUrl = "http://101.37.66.104:8077"; - //rap2 cookie - String sid = "c_IMAbZgZPFavzpFSxIK8BMmdQbXQUK2"; - String sig = "UML5gNS9BqnkwCKlF7Gu2XJU-RM"; - //接口itf参数 - int interfaceId = 282; - //java类路径 - String packageName = "com.kings.rap.demomodel"; - //request和response类名 不带java - String requestJavaClassname = "ModelWithAuthor"; - String responseJavaClassname = "KingsQueryVo"; - - Summary.BodyOption bodyOption = Summary.BodyOption.FORM_DATA; - Summary.RequestParamsType requestParamsType = Summary.RequestParamsType.QUERY_PARAMS; - ResponseResultType responseResultType = ResponseResultType.Array; - ResponseResultData responseResultData = new ResponseResultData(ResponseResultData.ResponseResultDataType.Object,"KingsQueryVo"); - - ParseConfig parseConfig = new ParseConfig(domainAndPortUrl,sid,sig,interfaceId,packageName,requestJavaClassname,responseJavaClassname,bodyOption,requestParamsType,responseResultType,responseResultData); - KingsRap2 kingsRap2 = new KingsRap2(); - kingsRap2.setParseConfig(parseConfig); - kingsRap2.doRap2(); - } +@Test +public void testCustomResponseTemplate() throws Exception { + ParseConfig parseConfig = ParseConfigJsonUtil.parseByJsonFile("自定义响应模板.json"); + Rap2Generator rap2Generator = new Rap2Generator(); + rap2Generator.setParseConfig(parseConfig); + rap2Generator.generate(); } ``` @@ -263,7 +222,7 @@ eclipse用户参考此文[https://blog.csdn.net/wangxiaotongfan/article/details/ 基于[淘宝rap2](http://rap2.taobao.org/)的自动化导入,请看演示.mp4 ## 6.demo小程序 -[https://github.com/kings1990/kings-rap2-generator-demo](https://github.com/kings1990/kings-rap2-generator-demo) +[https://github.com/kings1990/rap2-generator-demo](https://github.com/kings1990/rap2-generator-demo) 淘宝rap2插件测试地址(请勿乱删数据) ``` @@ -274,5 +233,5 @@ eclipse用户参考此文[https://blog.csdn.net/wangxiaotongfan/article/details/ ``` ## 7.如何贡献代码 -请查看[CONTRIBUTING.md](https://github.com/kings1990/kings-rap2-generator/blob/master/CONTRIBUTING.md) +请查看[CONTRIBUTING.md](https://github.com/kings1990/rap2-generator/blob/master/CONTRIBUTING.md) 我们非常欢迎你提交好的优质代码和建议 \ No newline at end of file diff --git a/pom.xml b/pom.xml index c0d897a..096790f 100644 --- a/pom.xml +++ b/pom.xml @@ -152,6 +152,6 @@ 项目的版本管理地址<--> - https://github.com/kings1990/kings-rap2-generator.git + https://github.com/kings1990/rap2-generator.git \ No newline at end of file diff --git a/src/main/java/com/kings/rap/config/ParseConfig.java b/src/main/java/io/github/kings1990/rap2/generator/config/ParseConfig.java similarity index 97% rename from src/main/java/com/kings/rap/config/ParseConfig.java rename to src/main/java/io/github/kings1990/rap2/generator/config/ParseConfig.java index 6d88062..dc2c0bc 100644 --- a/src/main/java/com/kings/rap/config/ParseConfig.java +++ b/src/main/java/io/github/kings1990/rap2/generator/config/ParseConfig.java @@ -1,4 +1,4 @@ -package com.kings.rap.config; +package io.github.kings1990.rap2.generator.config; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/kings/rap/config/ResponseResultData.java b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultData.java similarity index 96% rename from src/main/java/com/kings/rap/config/ResponseResultData.java rename to src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultData.java index 45d05fa..b3df15c 100644 --- a/src/main/java/com/kings/rap/config/ResponseResultData.java +++ b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultData.java @@ -1,4 +1,4 @@ -package com.kings.rap.config; +package io.github.kings1990.rap2.generator.config; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/kings/rap/config/ResponseResultType.java b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultType.java similarity index 93% rename from src/main/java/com/kings/rap/config/ResponseResultType.java rename to src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultType.java index d59d89a..dd4b65e 100644 --- a/src/main/java/com/kings/rap/config/ResponseResultType.java +++ b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseResultType.java @@ -1,4 +1,4 @@ -package com.kings.rap.config; +package io.github.kings1990.rap2.generator.config; /** *

diff --git a/src/main/java/com/kings/rap/config/ResponseTemplateConfig.java b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseTemplateConfig.java similarity index 91% rename from src/main/java/com/kings/rap/config/ResponseTemplateConfig.java rename to src/main/java/io/github/kings1990/rap2/generator/config/ResponseTemplateConfig.java index f38d48d..3e96995 100644 --- a/src/main/java/com/kings/rap/config/ResponseTemplateConfig.java +++ b/src/main/java/io/github/kings1990/rap2/generator/config/ResponseTemplateConfig.java @@ -1,4 +1,4 @@ -package com.kings.rap.config; +package io.github.kings1990.rap2.generator.config; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/kings/rap/config/Summary.java b/src/main/java/io/github/kings1990/rap2/generator/config/Summary.java similarity index 95% rename from src/main/java/com/kings/rap/config/Summary.java rename to src/main/java/io/github/kings1990/rap2/generator/config/Summary.java index 9a33335..b49a205 100644 --- a/src/main/java/com/kings/rap/config/Summary.java +++ b/src/main/java/io/github/kings1990/rap2/generator/config/Summary.java @@ -1,4 +1,4 @@ -package com.kings.rap.config; +package io.github.kings1990.rap2.generator.config; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/src/main/java/com/kings/rap/core/Rap2Generator.java b/src/main/java/io/github/kings1990/rap2/generator/core/Rap2Generator.java similarity index 99% rename from src/main/java/com/kings/rap/core/Rap2Generator.java rename to src/main/java/io/github/kings1990/rap2/generator/core/Rap2Generator.java index 6c254dd..1f8a35c 100644 --- a/src/main/java/com/kings/rap/core/Rap2Generator.java +++ b/src/main/java/io/github/kings1990/rap2/generator/core/Rap2Generator.java @@ -1,11 +1,11 @@ -package com.kings.rap.core; +package io.github.kings1990.rap2.generator.core; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; -import com.kings.rap.config.*; -import com.kings.rap.model.Rap2Response; +import io.github.kings1990.rap2.generator.config.*; +import io.github.kings1990.rap2.generator.model.Rap2Response; import okhttp3.*; import org.apache.commons.lang3.StringUtils; import org.springframework.format.annotation.DateTimeFormat; diff --git a/src/main/java/com/kings/rap/model/Rap2Response.java b/src/main/java/io/github/kings1990/rap2/generator/model/Rap2Response.java similarity index 70% rename from src/main/java/com/kings/rap/model/Rap2Response.java rename to src/main/java/io/github/kings1990/rap2/generator/model/Rap2Response.java index e750392..75acb63 100644 --- a/src/main/java/com/kings/rap/model/Rap2Response.java +++ b/src/main/java/io/github/kings1990/rap2/generator/model/Rap2Response.java @@ -1,4 +1,4 @@ -package com.kings.rap.model; +package io.github.kings1990.rap2.generator.model; import lombok.Data; diff --git a/src/main/java/com/kings/rap/util/ParseConfigJsonUtil.java b/src/main/java/io/github/kings1990/rap2/generator/util/ParseConfigJsonUtil.java similarity index 90% rename from src/main/java/com/kings/rap/util/ParseConfigJsonUtil.java rename to src/main/java/io/github/kings1990/rap2/generator/util/ParseConfigJsonUtil.java index 33e274e..2ffa32f 100644 --- a/src/main/java/com/kings/rap/util/ParseConfigJsonUtil.java +++ b/src/main/java/io/github/kings1990/rap2/generator/util/ParseConfigJsonUtil.java @@ -1,7 +1,7 @@ -package com.kings.rap.util; +package io.github.kings1990.rap2.generator.util; import com.alibaba.fastjson.JSONObject; -import com.kings.rap.config.ParseConfig; +import io.github.kings1990.rap2.generator.config.ParseConfig; import java.io.BufferedReader; import java.io.IOException;