【7.2.5】【rule】标记枚举,设置可直接和mp交互

pull/37/head
fengshuonan 2022-09-07 16:38:34 +08:00
parent 6bde52fcfb
commit b3b8948531
3 changed files with 26 additions and 3 deletions

View File

@ -17,6 +17,17 @@
<dependencies> <dependencies>
<!-- 通用注解 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>${mp.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<!-- spring boot --> <!-- spring boot -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -25,6 +25,7 @@
package cn.stylefeng.roses.kernel.rule.enums; package cn.stylefeng.roses.kernel.rule.enums;
import cn.stylefeng.roses.kernel.rule.base.ReadableEnum; import cn.stylefeng.roses.kernel.rule.base.ReadableEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter; import lombok.Getter;
/** /**
@ -46,6 +47,7 @@ public enum StatusEnum implements ReadableEnum {
*/ */
DISABLE(2, "禁用"); DISABLE(2, "禁用");
@EnumValue
private final Integer code; private final Integer code;
private final String message; private final String message;

View File

@ -25,6 +25,8 @@
package cn.stylefeng.roses.kernel.rule.enums; package cn.stylefeng.roses.kernel.rule.enums;
import cn.stylefeng.roses.kernel.rule.base.ReadableEnum; import cn.stylefeng.roses.kernel.rule.base.ReadableEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter; import lombok.Getter;
/** /**
@ -39,20 +41,28 @@ public enum YesOrNotEnum implements ReadableEnum {
/** /**
* *
*/ */
Y("Y", "是"), Y("Y", "是", true),
/** /**
* *
*/ */
N("N", "否"); N("N", "否", false);
/**
* 使@EnumValuemybatis-plus使code
*/
@EnumValue
private final String code; private final String code;
private final String message; private final String message;
YesOrNotEnum(String code, String message) { @JsonValue
private final Boolean boolFlag;
YesOrNotEnum(String code, String message, Boolean boolFlag) {
this.code = code; this.code = code;
this.message = message; this.message = message;
this.boolFlag = boolFlag;
} }
@Override @Override