调整全局配置接口

This commit is contained in:
TinyAnts 2022-08-11 15:40:40 +08:00
parent 5c63190f1c
commit b45df0d2ea
2 changed files with 19 additions and 11 deletions

View File

@ -5,9 +5,7 @@ import com.hxkj.admin.service.common.IIndexService;
import com.hxkj.common.config.GlobalConfig; import com.hxkj.common.config.GlobalConfig;
import com.hxkj.common.entity.article.Article; import com.hxkj.common.entity.article.Article;
import com.hxkj.common.mapper.article.ArticleMapper; import com.hxkj.common.mapper.article.ArticleMapper;
import com.hxkj.common.utils.ConfigUtil; import com.hxkj.common.utils.*;
import com.hxkj.common.utils.TimeUtil;
import com.hxkj.common.utils.UrlUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -73,21 +71,15 @@ public class IndexServiceImpl implements IIndexService {
@Override @Override
public Map<String, Object> config() { public Map<String, Object> config() {
Map<String, String> website = ConfigUtil.get("website"); Map<String, String> website = ConfigUtil.get("website");
Map<String, String> copyright = ConfigUtil.get("copyright"); String copyright = ConfigUtil.get("website", "copyright", "");
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("lawPrivilege", copyright.getOrDefault("privilege", ""));
map.put("lawIcpNumber", copyright.getOrDefault("icpNumber", ""));
map.put("lawIcpLink", copyright.getOrDefault("icpLink", ""));
map.put("lawGaNumber", copyright.getOrDefault("gaNumber", ""));
map.put("lawGaLink", copyright.getOrDefault("gaLink", ""));
map.put("webName", website.getOrDefault("name", "")); map.put("webName", website.getOrDefault("name", ""));
map.put("webLogo", UrlUtil.toAbsoluteUrl(website.getOrDefault("logo", ""))); map.put("webLogo", UrlUtil.toAbsoluteUrl(website.getOrDefault("logo", "")));
map.put("webFavicon", UrlUtil.toAbsoluteUrl(website.getOrDefault("favicon", ""))); map.put("webFavicon", UrlUtil.toAbsoluteUrl(website.getOrDefault("favicon", "")));
map.put("webBackdrop", UrlUtil.toAbsoluteUrl(website.getOrDefault("backdrop", ""))); map.put("webBackdrop", UrlUtil.toAbsoluteUrl(website.getOrDefault("backdrop", "")));
map.put("ossDomain", UrlUtil.domain()); map.put("ossDomain", UrlUtil.domain());
map.put("copyright", ArrayUtil.stringToListAsMapStr(copyright));
return map; return map;
} }

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Array;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.*; import java.util.*;
@ -239,6 +240,9 @@ public class ArrayUtil {
* @return Map<String, Object> * @return Map<String, Object>
*/ */
public static List<Map<String, Object>> stringToListAsMapObj(String s) { public static List<Map<String, Object>> stringToListAsMapObj(String s) {
if (StringUtil.isEmpty(s)) {
return Collections.emptyList();
}
Type type = new TypeToken<List<Map<String, Object>>>() {}.getType(); Type type = new TypeToken<List<Map<String, Object>>>() {}.getType();
return JSON.parseObject(s, type); return JSON.parseObject(s, type);
} }
@ -251,6 +255,9 @@ public class ArrayUtil {
* @return Map<String, String> * @return Map<String, String>
*/ */
public static List<Map<String, String>> stringToListAsMapStr(String s) { public static List<Map<String, String>> stringToListAsMapStr(String s) {
if (StringUtil.isEmpty(s)) {
return Collections.emptyList();
}
Type type = new TypeToken<List<Map<String, String>>>() {}.getType(); Type type = new TypeToken<List<Map<String, String>>>() {}.getType();
return JSON.parseObject(s, type); return JSON.parseObject(s, type);
} }
@ -263,6 +270,9 @@ public class ArrayUtil {
* @return List<Long> * @return List<Long>
*/ */
public static List<Integer> objectToListAsLong(Object object) { public static List<Integer> objectToListAsLong(Object object) {
if (StringUtil.isNull(object)) {
return Collections.emptyList();
}
Type type = new TypeToken<List<Long>>() {}.getType(); Type type = new TypeToken<List<Long>>() {}.getType();
return JSON.parseObject(JSONObject.toJSONString(object), type); return JSON.parseObject(JSONObject.toJSONString(object), type);
} }
@ -275,6 +285,9 @@ public class ArrayUtil {
* @return List<Integer> * @return List<Integer>
*/ */
public static List<Integer> objectToListAsInt(Object object) { public static List<Integer> objectToListAsInt(Object object) {
if (StringUtil.isNull(object)) {
return Collections.emptyList();
}
Type type = new TypeToken<List<Integer>>() {}.getType(); Type type = new TypeToken<List<Integer>>() {}.getType();
return JSON.parseObject(JSONObject.toJSONString(object), type); return JSON.parseObject(JSONObject.toJSONString(object), type);
} }
@ -287,6 +300,9 @@ public class ArrayUtil {
* @return List<String> * @return List<String>
*/ */
public static List<Integer> objectToListAsStr(Object object) { public static List<Integer> objectToListAsStr(Object object) {
if (StringUtil.isNull(object)) {
return Collections.emptyList();
}
Type type = new TypeToken<List<String>>() {}.getType(); Type type = new TypeToken<List<String>>() {}.getType();
return JSON.parseObject(JSONObject.toJSONString(object), type); return JSON.parseObject(JSONObject.toJSONString(object), type);
} }