增加公共配置接口
This commit is contained in:
parent
d9c9f27530
commit
b46ef62d58
|
|
@ -16,7 +16,8 @@ public class AdminConfig {
|
|||
|
||||
// 免登录验证
|
||||
public static String[] notLoginUri = new String[]{
|
||||
"/api/system/login"
|
||||
"/api/system/login",
|
||||
"/api/index/config",
|
||||
};
|
||||
|
||||
// 免权限验证
|
||||
|
|
|
|||
|
|
@ -33,4 +33,16 @@ public class IndexController {
|
|||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*
|
||||
* @author fzr
|
||||
* @return Object
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
public Object config() {
|
||||
Map<String, Object> map = iIndexService.config();
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,9 @@ public interface IIndexService {
|
|||
*/
|
||||
Map<String, Object> console();
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*/
|
||||
Map<String, Object> config();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class BasicsServiceImpl implements IBasicsService {
|
|||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("name", config.getOrDefault("name", ""));
|
||||
map.put("logo", UrlUtil.toAbsoluteUrl(config.getOrDefault("logo", "")));
|
||||
map.put("favicon", UrlUtil.toAbsoluteUrl(config.getOrDefault("favicon", "")));
|
||||
map.put("backdrop", UrlUtil.toAbsoluteUrl(config.getOrDefault("backdrop", "")));
|
||||
return map;
|
||||
}
|
||||
|
|
@ -43,10 +44,10 @@ public class BasicsServiceImpl implements IBasicsService {
|
|||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("privilege", config.getOrDefault("privilege", ""));
|
||||
map.put("icp_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("icp_number", "")));
|
||||
map.put("icp_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("icp_link", "")));
|
||||
map.put("ga_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("ga_number", "")));
|
||||
map.put("ga_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("ga_link", "")));
|
||||
map.put("icp_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("icpNumber", "")));
|
||||
map.put("icp_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("icpLink", "")));
|
||||
map.put("ga_number", UrlUtil.toAbsoluteUrl(config.getOrDefault("gaNumber", "")));
|
||||
map.put("ga_link", UrlUtil.toAbsoluteUrl(config.getOrDefault("gaLink", "")));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ public class BasicsServiceImpl implements IBasicsService {
|
|||
public void setWebsite(Map<String, String> params) {
|
||||
ConfigUtil.set("website", "name", params.getOrDefault("name", ""));
|
||||
ConfigUtil.set("website", "logo", UrlUtil.toRelativeUrl(params.getOrDefault("logo", "")));
|
||||
ConfigUtil.set("website", "favicon", UrlUtil.toRelativeUrl(params.getOrDefault("favicon", "")));
|
||||
ConfigUtil.set("website", "backdrop", UrlUtil.toRelativeUrl(params.getOrDefault("backdrop", "")));
|
||||
}
|
||||
|
||||
|
|
@ -72,10 +74,10 @@ public class BasicsServiceImpl implements IBasicsService {
|
|||
@Override
|
||||
public void setCopyright(Map<String, String> params) {
|
||||
ConfigUtil.set("copyright", "privilege", params.getOrDefault("privilege", ""));
|
||||
ConfigUtil.set("copyright", "icp_number", params.getOrDefault("icp_number", ""));
|
||||
ConfigUtil.set("copyright", "icp_link", params.getOrDefault("icp_link", ""));
|
||||
ConfigUtil.set("copyright", "ga_number", params.getOrDefault("ga_number", ""));
|
||||
ConfigUtil.set("copyright", "ga_link", params.getOrDefault("ga_link", ""));
|
||||
ConfigUtil.set("copyright", "icpNumber", params.getOrDefault("icpNumber", ""));
|
||||
ConfigUtil.set("copyright", "icpLink", params.getOrDefault("icpLink", ""));
|
||||
ConfigUtil.set("copyright", "gaNumber", params.getOrDefault("gaNumber", ""));
|
||||
ConfigUtil.set("copyright", "gaLink", params.getOrDefault("gaLink", ""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.hxkj.admin.service.IIndexService;
|
||||
import com.hxkj.common.entity.Article;
|
||||
import com.hxkj.common.mapper.ArticleMapper;
|
||||
import com.hxkj.common.utils.ConfigUtil;
|
||||
import com.hxkj.common.utils.TimeUtil;
|
||||
import com.hxkj.common.utils.UrlUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -62,4 +64,32 @@ public class IndexServiceImpl implements IIndexService {
|
|||
return console;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共配置
|
||||
*
|
||||
* @author fzr
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> config() {
|
||||
Map<String, String> website = ConfigUtil.get("website");
|
||||
Map<String, String> copyright = ConfigUtil.get("copyright");
|
||||
|
||||
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("webLogo", UrlUtil.toAbsoluteUrl(website.getOrDefault("logo", "")));
|
||||
map.put("webFavicon", UrlUtil.toAbsoluteUrl(website.getOrDefault("favicon", "")));
|
||||
map.put("webBackdrop", UrlUtil.toAbsoluteUrl(website.getOrDefault("backdrop", "")));
|
||||
|
||||
map.put("ossDomain", UrlUtil.domain());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,20 @@ public class UrlUtil {
|
|||
return url.replace(config.get("domain") + "/" + uploadPrefix + "/", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取存储域名
|
||||
*
|
||||
* @author fzr
|
||||
* @return String
|
||||
*/
|
||||
public static String domain() {
|
||||
String engine = ConfigUtil.get("storage", "default", "local");
|
||||
if (engine.equals("local")) {
|
||||
return HttpUtil.domain() + "/";
|
||||
}
|
||||
|
||||
Map<String, String> config = ConfigUtil.getMap("storage", engine);
|
||||
return config.get("domain") + "/";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue