Skip to content

Commit

Permalink
fix: 去除DictBean实现Dict,导致json序列化时勿将DictBean序列化成code
Browse files Browse the repository at this point in the history
  • Loading branch information
Robot committed Jan 22, 2024
1 parent f40cf9d commit 90aee13
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ wrapper.eq(Student::sex, SexEnum.MALE);
```
> 源码参考:DictMybatisConfiguration
## 使用方式
导入依赖即自动生效(项目中必须已经依赖SpringBoot,但没有使用Mybatis不会有影响)
导入依赖即自动生效
```xml
<!-- Spring开发支持含核心功能、Json、Mybatis、SpringConverter) -->
<!-- Spring开发支持含核心功能、Json、SpringConverter(项目须依赖springWeb)和Mybatis(项目须依赖mybatis)-->
<dependency>
<groupId>io.github.luo-zhan</groupId>
<artifactId>easy-enum-for-spring</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</dependency>
```
如果你不需要Spring和Mybatis的支持,只需要Dict枚举的工具方法,可以只引入以下依赖
Expand All @@ -208,7 +208,7 @@ wrapper.eq(Student::sex, SexEnum.MALE);
<dependency>
<groupId>io.github.luo-zhan</groupId>
<artifactId>easy-enum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</dependency>
```
## 交流
Expand Down
39 changes: 33 additions & 6 deletions easy-enum-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.luo-zhan</groupId>
<artifactId>EasyEnum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</parent>

<artifactId>easy-enum-demo</artifactId>
Expand All @@ -15,12 +15,12 @@
<dependency>
<groupId>io.github.luo-zhan</groupId>
<artifactId>easy-enum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</dependency>
<dependency>
<groupId>io.github.luo-zhan</groupId>
<artifactId>easy-enum-for-spring</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</dependency>

<dependency>
Expand All @@ -31,13 +31,40 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.14</version>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.14</version>
<version>2.4.13</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4 changes: 2 additions & 2 deletions easy-enum-for-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.luo-zhan</groupId>
<artifactId>EasyEnum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</parent>

<artifactId>easy-enum-for-spring</artifactId>
Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>io.github.luo-zhan</groupId>
<artifactId>easy-enum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion easy-enum/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.github.luo-zhan</groupId>
<artifactId>EasyEnum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
</parent>

<artifactId>easy-enum</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions easy-enum/src/main/java/com/robot/dict/DictBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author R
*/
public class DictBean implements Dict<Object> {
public class DictBean {
/**
* 字典code
*/
Expand Down Expand Up @@ -34,17 +34,17 @@ public DictBean(Object code, String text, boolean isDeprecated) {
this.isDeprecated = isDeprecated;
}

@Override

public Object getCode() {
return code;
}

@Override

public String getText() {
return text;
}

public boolean getIsDeprecated() {
public boolean isDeprecated() {
return isDeprecated;
}

Expand Down
2 changes: 1 addition & 1 deletion easy-enum/src/main/java/com/robot/dict/DictPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static List<DictBean> getAll(Class<? extends Dict<?>> clazz, boolean isExcludeDe
clazz.getEnumConstants();
List<DictBean> dictBeans = DICT_CLASS_ITEMS_MAP.get(clazz);
if (isExcludeDeprecated) {
return dictBeans.stream().filter(dictBean -> !dictBean.getIsDeprecated()).collect(Collectors.toList());
return dictBeans.stream().filter(dictBean -> !dictBean.isDeprecated()).collect(Collectors.toList());
}
return dictBeans;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.luo-zhan</groupId>
<artifactId>EasyEnum</artifactId>
<version>1.3.0-RELEASE</version>
<version>1.3.1-RELEASE</version>
<name>EasyEnum</name>
<modules>
<module>easy-enum</module>
Expand Down

0 comments on commit 90aee13

Please sign in to comment.