refactor: 定义标准数据模型.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.orion.ops.framework.common.handler.data.model;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
* 标准数据模型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/20 22:07
|
||||
*/
|
||||
public interface GenericsDataModel {
|
||||
|
||||
/**
|
||||
* 序列化
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
default String serial() {
|
||||
return JSON.toJSONString(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.orion.ops.framework.common.handler.data.strategy;
|
||||
|
||||
import com.orion.ops.framework.common.handler.data.model.GenericsDataModel;
|
||||
|
||||
/**
|
||||
* 标准数据处理策略
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/20 22:09
|
||||
*/
|
||||
public interface GenericsDataStrategy<Config extends GenericsDataModel, View> {
|
||||
|
||||
/**
|
||||
* 获取默认值
|
||||
*
|
||||
* @return 默认值
|
||||
*/
|
||||
Config getDefault();
|
||||
|
||||
/**
|
||||
* 更新填充
|
||||
*
|
||||
* @param before 修改前配置
|
||||
* @param after 修改后配置
|
||||
*/
|
||||
void updateFill(Config before, Config after);
|
||||
|
||||
/**
|
||||
* 预校验参数
|
||||
*
|
||||
* @param config config
|
||||
*/
|
||||
void preValidConfig(Config config);
|
||||
|
||||
/**
|
||||
* 校验参数
|
||||
*
|
||||
* @param config config
|
||||
*/
|
||||
void validConfig(Config config);
|
||||
|
||||
/**
|
||||
* 转为视图配置
|
||||
*
|
||||
* @param config config
|
||||
* @return 视图配置
|
||||
*/
|
||||
View toView(String config);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.orion.ops.framework.common.handler.data.strategy;
|
||||
|
||||
import com.orion.ops.framework.common.handler.data.model.GenericsDataModel;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* map 数据处理策略
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/12/20 22:11
|
||||
*/
|
||||
public interface MapDataStrategy<Config extends GenericsDataModel> extends GenericsDataStrategy<Config, Map<String, Object>> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user