-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.7.x'
# Conflicts: # .github/workflows/publish-snapshot.yml # CHANGELOG.md # README.md # README_EN.md # build.gradle # deploy.sh # gradle.properties # mica-activerecord/build.gradle # mica-bom/build.gradle # mica-captcha/build.gradle # mica-captcha/src/main/java/net/dreamlu/mica/captcha/config/MicaCaptchaAutoConfiguration.java # mica-ip2region/build.gradle # mica-ip2region/src/main/java/net/dreamlu/mica/ip2region/core/IpAddress.java # mica-redis/src/main/java/net/dreamlu/mica/redis/cache/MicaRedisCache.java # mica-xss/src/main/java/net/dreamlu/mica/xss/core/DefaultXssCleaner.java
- Loading branch information
Showing
22 changed files
with
1,705 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
mica-core/src/test/java/net/dreamlu/mica/test/utils/JsonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package net.dreamlu.mica.test.utils; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.Data; | ||
import net.dreamlu.mica.core.result.R; | ||
import net.dreamlu.mica.core.utils.JsonUtil; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* json 测试 | ||
* | ||
* @author L.cm | ||
*/ | ||
class JsonTest { | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
public static class Views { | ||
public static class Public { } | ||
public static class Internal extends Public { } | ||
} | ||
|
||
@Data | ||
public static class User { | ||
@JsonView(Views.Public.class) | ||
private Long id; | ||
|
||
@JsonView(Views.Public.class) | ||
private String name; | ||
|
||
@JsonView(Views.Internal.class) | ||
private String email; | ||
} | ||
|
||
@Test | ||
void test1() throws JsonProcessingException { | ||
User user = new User(); | ||
user.setId(System.currentTimeMillis()); | ||
user.setName("张三"); | ||
user.setEmail("[email protected]"); | ||
String json1 = objectMapper.writeValueAsString(user); | ||
Assertions.assertTrue(json1.contains("zhangsan")); | ||
String json2 = objectMapper.writerWithView(Views.Public.class).writeValueAsString(user); | ||
Assertions.assertFalse(json2.contains("zhangsan")); | ||
} | ||
|
||
@Test | ||
void test2() { | ||
User user = new User(); | ||
user.setId(System.currentTimeMillis()); | ||
user.setName("张三"); | ||
user.setEmail("[email protected]"); | ||
String json1 = JsonUtil.toJson(user); | ||
Assertions.assertTrue(json1.contains("zhangsan")); | ||
String json2 = JsonUtil.toJsonWithView(user, Views.Public.class); | ||
Assertions.assertFalse(json2.contains("zhangsan")); | ||
} | ||
|
||
@Test | ||
void testR() { | ||
User user = new User(); | ||
user.setId(System.currentTimeMillis()); | ||
user.setName("张三"); | ||
user.setEmail("[email protected]"); | ||
String json1 = JsonUtil.toJson(R.success(user)); | ||
Assertions.assertTrue(json1.contains("zhangsan")); | ||
String json2 = JsonUtil.toJsonWithView(R.success(user), Views.Public.class); | ||
Assertions.assertFalse(json2.contains("zhangsan")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## mica-nats(高性能、轻量级消息队列) | ||
|
||
nats 封装,更改方便 Spring boot 下使用。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dependencies { | ||
api project(":mica-core") | ||
api "io.nats:jnats:2.16.13" | ||
implementation "jakarta.validation:jakarta.validation-api" | ||
implementation "org.springframework.boot:spring-boot-starter" | ||
compileOnly "org.springframework.cloud:spring-cloud-context" | ||
compileOnly "net.dreamlu:mica-auto:${micaAutoVersion}" | ||
annotationProcessor "net.dreamlu:mica-auto:${micaAutoVersion}" | ||
} |
45 changes: 45 additions & 0 deletions
45
mica-nats/src/main/java/net/dreamlu/mica/nats/annotation/NatsListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 ([email protected] & www.dreamlu.net). | ||
* <p> | ||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.gnu.org/licenses/lgpl.html | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dreamlu.mica.nats.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* nats 监听器 | ||
* | ||
* @author L.cm | ||
*/ | ||
@Documented | ||
@Inherited | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NatsListener { | ||
|
||
/** | ||
* 主题 subject | ||
* | ||
* @return subject | ||
*/ | ||
String value(); | ||
|
||
/** | ||
* 队列 | ||
* @return 队列名称 | ||
*/ | ||
String queue() default ""; | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
mica-nats/src/main/java/net/dreamlu/mica/nats/annotation/NatsStreamListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) 2019-2029, Dreamlu 卢春梦 ([email protected] & www.dreamlu.net). | ||
* <p> | ||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0; | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* http://www.gnu.org/licenses/lgpl.html | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dreamlu.mica.nats.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** | ||
* nats stream 监听器注解 | ||
* | ||
* @author L.cm | ||
*/ | ||
@Documented | ||
@Inherited | ||
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NatsStreamListener { | ||
|
||
/** | ||
* 主题 subject | ||
* | ||
* @return subject | ||
*/ | ||
String value(); | ||
|
||
/** | ||
* 队列 | ||
* @return 队列名称 | ||
*/ | ||
String queue() default ""; | ||
|
||
/** | ||
* 交付主题 | ||
*/ | ||
String deliverSubject() default ""; | ||
|
||
/** | ||
* 交付组 | ||
*/ | ||
String deliverGroup() default ""; | ||
|
||
} |
Oops, something went wrong.