✨ 主机终端主题从字典中获取.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.orion.visor.module.infra.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典配置值 对外服务
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/7/4 18:54
|
||||
*/
|
||||
public interface DictValueApi {
|
||||
|
||||
/**
|
||||
* 查询字典配置值
|
||||
*
|
||||
* @param key key
|
||||
* @return rows
|
||||
*/
|
||||
List<JSONObject> getDictValue(String key);
|
||||
|
||||
/**
|
||||
* 查询字典配置值
|
||||
*
|
||||
* @param keys keys
|
||||
* @return rows
|
||||
*/
|
||||
Map<String, List<JSONObject>> getDictValueList(List<String> keys);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.orion.visor.module.infra.api.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.orion.visor.module.infra.api.DictValueApi;
|
||||
import com.orion.visor.module.infra.service.DictValueService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 字典配置值 对外服务实现类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/7/4 18:55
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DictValueApiImpl implements DictValueApi {
|
||||
|
||||
@Resource
|
||||
private DictValueService dictValueService;
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getDictValue(String key) {
|
||||
return dictValueService.getDictValue(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<JSONObject>> getDictValueList(List<String> keys) {
|
||||
return dictValueService.getDictValueList(keys);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,8 +25,8 @@ public class DictValueOperatorType extends InitializingOperatorTypes {
|
||||
@Override
|
||||
public OperatorType[] types() {
|
||||
return new OperatorType[]{
|
||||
new OperatorType(L, CREATE, "创建字典配置值 <sb>${keyName}</sb>: <sb>${label}</sb> | <sb>${value}</sb>"),
|
||||
new OperatorType(M, UPDATE, "更新字典配置值 <sb>${keyName}</sb>: <sb>${label}</sb> | <sb>${value}</sb>"),
|
||||
new OperatorType(L, CREATE, "创建字典配置值 <sb>${keyName}</sb> - <sb>${label}</sb> | <sb>${value}</sb>"),
|
||||
new OperatorType(M, UPDATE, "更新字典配置值 <sb>${keyName}</sb> - <sb>${label}</sb> | <sb>${value}</sb>"),
|
||||
new OperatorType(H, DELETE, "删除字典配置值 <sb>${value}</sb>"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.orion.visor.module.infra.enums;
|
||||
|
||||
import com.orion.lang.utils.convert.Converts;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
@@ -53,7 +51,7 @@ public enum DictValueTypeEnum {
|
||||
@Override
|
||||
public Object parse(String s) {
|
||||
try {
|
||||
return Converts.toBoolean(s);
|
||||
return Boolean.valueOf(s);
|
||||
} catch (Exception e) {
|
||||
return super.parse(s);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,14 @@ public interface DictValueService {
|
||||
*/
|
||||
Integer rollbackDictValueById(DictValueRollbackRequest request);
|
||||
|
||||
/**
|
||||
* 查询字典配置值
|
||||
*
|
||||
* @param key key
|
||||
* @return rows
|
||||
*/
|
||||
List<JSONObject> getDictValue(String key);
|
||||
|
||||
/**
|
||||
* 查询字典配置值
|
||||
*
|
||||
|
||||
@@ -73,7 +73,7 @@ public class DictValueServiceImpl implements DictValueService {
|
||||
// 查询数据是否冲突
|
||||
this.checkDictValuePresent(record);
|
||||
// 插入
|
||||
OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey);
|
||||
OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey.getKeyName());
|
||||
record.setKeyName(key);
|
||||
int effect = dictValueDAO.insert(record);
|
||||
Long id = record.getId();
|
||||
@@ -98,7 +98,7 @@ public class DictValueServiceImpl implements DictValueService {
|
||||
// 查询数据是否冲突
|
||||
this.checkDictValuePresent(updateRecord);
|
||||
// 更新
|
||||
OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey);
|
||||
OperatorLogs.add(OperatorLogs.KEY_NAME, dictKey.getKeyName());
|
||||
OperatorLogs.add(OperatorLogs.VALUE, this.getDictValueJson(updateRecord));
|
||||
updateRecord.setKeyName(key);
|
||||
int effect = dictValueDAO.updateById(updateRecord);
|
||||
@@ -142,6 +142,18 @@ public class DictValueServiceImpl implements DictValueService {
|
||||
return effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getDictValue(String key) {
|
||||
// 查询字典值
|
||||
Map<String, List<JSONObject>> values = this.getDictValueList(Lists.singleton(key));
|
||||
List<JSONObject> value = values.get(key);
|
||||
if (value == null) {
|
||||
return Lists.newList();
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<JSONObject>> getDictValueList(List<String> keys) {
|
||||
Map<String, List<JSONObject>> result = new HashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user