优化:使用枚举存储性别、状态等信息(采用 MyBatis Plus#通用枚举扩展),常量类则专注于存储全局变量,例如:缓存键、默认值等

This commit is contained in:
2023-01-02 00:19:56 +08:00
parent 1d21019813
commit 21f5aceccf
9 changed files with 125 additions and 26 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 top.charles7c.cnadmin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.annotation.IEnum;
/**
* 启用/禁用状态枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum DisEnableStatusEnum implements IEnum<Integer> {
/** 启用 */
ENABLE(1, "启用"),
/** 禁用 */
DISABLE(2, "禁用"),;
private final Integer value;
private final String description;
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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 top.charles7c.cnadmin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.annotation.IEnum;
/**
* 性别枚举
*
* @author Charles7c
* @since 2022/12/29 21:59
*/
@Getter
@RequiredArgsConstructor
public enum GenderEnum implements IEnum<Integer> {
/** 未知 */
UNKNOWN(0, "未知"),
/** 男 */
MALE(1, ""),
/** 女 */
FEMALE(2, ""),;
private final Integer value;
private final String description;
}