| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5977535 commit 7251ace
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -57,17 +57,18 @@ public static void main(String[] args) throws Exception { | |||
| 57 | 57 | @Bean | |
| 58 | 58 | public CorsFilter corsFilter() { | |
| 59 | 59 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | |
| 60 | - source.registerCorsConfiguration("/**", buildConfig()); // 4 | ||
| 60 | + source.registerCorsConfiguration("/**", buildConfig()); | ||
| 61 | 61 | return new CorsFilter(source); | |
| 62 | 62 | } | |
| 63 | 63 | /**CORS跨域配置 | |
| 64 | 64 | * @return | |
| 65 | 65 | */ | |
| 66 | 66 | private CorsConfiguration buildConfig() { | |
| 67 | 67 | CorsConfiguration corsConfiguration = new CorsConfiguration(); | |
| 68 | - corsConfiguration.addAllowedOrigin("*"); | ||
| 69 | - corsConfiguration.addAllowedHeader("*"); | ||
| 70 | - corsConfiguration.addAllowedMethod("*"); | ||
| 68 | + corsConfiguration.addAllowedOrigin("*"); //允许的域名或IP地址 | ||
| 69 | + corsConfiguration.addAllowedHeader("*"); //允许的请求头 | ||
| 70 | + corsConfiguration.addAllowedMethod("*"); //允许的HTTP请求方法 | ||
| 71 | + corsConfiguration.setAllowCredentials(true); //允许发送跨域凭据,前端Axios存取JSESSIONID必须要 | ||
| 71 | 72 | return corsConfiguration; | |
| 72 | 73 | } | |
| 73 | 74 | //支持JavaScript跨域请求 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,7 @@ public JSONRequest(String name, Object object) { | |||
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | 53 | public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest | |
| 54 | + public static final String KEY_VERSION = "version";//只在最外层,最外层用JSONRequest | ||
| 54 | 55 | ||
| 55 | 56 | /**set "tag":tag in outermost layer | |
| 56 | 57 | * for write operations | |
@@ -60,6 +61,14 @@ public JSONRequest(String name, Object object) { | |||
| 60 | 61 | public JSONRequest setTag(String tag) { | |
| 61 | 62 | return puts(KEY_TAG, tag); | |
| 62 | 63 | } | |
| 64 | + /**set "version":version in outermost layer | ||
| 65 | + * for target version of request | ||
| 66 | + * @param version | ||
| 67 | + * @return | ||
| 68 | + */ | ||
| 69 | + public JSONRequest setVersion(String version) { | ||
| 70 | + return puts(KEY_VERSION, version); | ||
| 71 | + } | ||
| 63 | 72 | ||
| 64 | 73 | ||
| 65 | 74 | //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -374,11 +374,12 @@ public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONOb | |||
| 374 | 374 | if (StringUtil.isNotEmpty(tag, true) == false) { | |
| 375 | 375 | throw new IllegalArgumentException("请设置tag!一般是Table名"); | |
| 376 | 376 | } | |
| 377 | + int version = request.getIntValue(JSONRequest.KEY_VERSION); | ||
| 377 | 378 | ||
| 378 | 379 | JSONObject object = null; | |
| 379 | 380 | String error = ""; | |
| 380 | 381 | try { | |
| 381 | - object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag); | ||
| 382 | + object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag, version); | ||
| 382 | 383 | } catch (Exception e) { | |
| 383 | 384 | error = e.getMessage(); | |
| 384 | 385 | } | |
@@ -396,6 +397,7 @@ public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONOb | |||
| 396 | 397 | //获取指定的JSON结构 >>>>>>>>>>>>>> | |
| 397 | 398 | ||
| 398 | 399 | request.remove(JSONRequest.KEY_TAG); | |
| 400 | + request.remove(JSONRequest.KEY_VERSION); | ||
| 399 | 401 | return Structure.parseRequest(method, "", (JSONObject) target.clone(), request); | |
| 400 | 402 | } | |
| 401 | 403 | ||
@@ -431,11 +433,12 @@ public static JSONObject getCorrectResponse(@NotNull final RequestMethod method | |||
| 431 | 433 | * @param table | |
| 432 | 434 | * @param key | |
| 433 | 435 | * @param value | |
| 436 | + * @param version | ||
| 434 | 437 | * @return | |
| 435 | 438 | * @throws Exception | |
| 436 | 439 | */ | |
| 437 | 440 | public static JSONObject getStructure(@NotNull final RequestMethod method, @NotNull String table, | |
| 438 | - String key, String value) throws Exception { | ||
| 441 | + String key, String value, int version) throws Exception { | ||
| 439 | 442 | //获取指定的JSON结构 <<<<<<<<<<<<<< | |
| 440 | 443 | SQLConfig config = new SQLConfig(GET, table); | |
| 441 | 444 | config.setColumn("structure"); | |
@@ -445,7 +448,12 @@ public static JSONObject getStructure(@NotNull final RequestMethod method, @NotN | |||
| 445 | 448 | if (key != null) { | |
| 446 | 449 | where.put(key, value); | |
| 447 | 450 | } | |
| 451 | + if (version > 0) { | ||
| 452 | + where.put(JSONRequest.KEY_VERSION + "{}", ">=" + version); | ||
| 453 | + } | ||
| 448 | 454 | config.setWhere(where); | |
| 455 | + config.setOrder(JSONRequest.KEY_VERSION + (version > 0 ? "+" : "-")); | ||
| 456 | + config.setCount(1); | ||
| 449 | 457 | ||
| 450 | 458 | SQLExecutor qh = new SQLExecutor(); | |
| 451 | 459 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ public class ApplicationTests { | |||
| 11 | 11 | ||
| 12 | 12 | @Test | |
| 13 | 13 | public void contextLoads() { | |
| 14 | + //TODO Test Case,包括GitHub README介绍和简版demo | ||
| 14 | 15 | } | |
| 15 | 16 | ||
| 16 | 17 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments