feat 增加front 配置相关逻辑

This commit is contained in:
damonyuan 2024-10-14 00:35:03 +08:00
parent 11aa66ef8d
commit b8997b8062
4 changed files with 68 additions and 92 deletions

View File

@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@RestController @RestController
@RequestMapping("/api/pc") @RequestMapping("/api/index")
@Api(tags = "主页管理") @Api(tags = "主页管理")
public class IndexController { public class IndexController {

View File

@ -24,24 +24,24 @@ import java.util.Map;
@Api(tags = "电脑管理") @Api(tags = "电脑管理")
public class PcController { public class PcController {
// @Resource @Resource
// IPcService iPcService; IPcService iPcService;
//
// @NotLogin @NotLogin
// @GetMapping("/index") @GetMapping("/index")
// @ApiOperation(value="主页数据") @ApiOperation(value="主页数据")
// public AjaxResult<Map<String,Object>> index() { public AjaxResult<Map<String,Object>> index() {
// Map<String, Object> index = iPcService.index(); Map<String, Object> index = iPcService.index();
// return AjaxResult.success(index); return AjaxResult.success(index);
// } }
//
// @NotLogin @NotLogin
// @GetMapping("/getConfig") @GetMapping("/config")
// @ApiOperation(value="公共配置") @ApiOperation(value="公共配置")
// public AjaxResult<Map<String, Object>> getConfig() { public AjaxResult<Map<String, Object>> getConfig() {
// Map<String, Object> config = iPcService.getConfig(); Map<String, Object> config = iPcService.getConfig();
// return AjaxResult.success(config); return AjaxResult.success(config);
// } }
// //
// @NotLogin // @NotLogin
// @GetMapping("/articleCenter") // @GetMapping("/articleCenter")

View File

@ -109,52 +109,33 @@ public class IndexServiceImpl implements IIndexService {
public Map<String, Object> config() { public Map<String, Object> config() {
Map<String, Object> response = new LinkedHashMap<>(); Map<String, Object> response = new LinkedHashMap<>();
// 底部导航
List<Map<String, String>> tabs = new LinkedList<>();
List<DecorateTabbar> decorateTabbars = decorateTabbarMapper.selectList(new QueryWrapper<DecorateTabbar>().orderByAsc("id"));
for (DecorateTabbar tab: decorateTabbars) {
Map<String, String> map = new LinkedHashMap<>();
map.put("name", tab.getName());
map.put("selected", UrlUtils.toAbsoluteUrl(tab.getSelected()));
map.put("unselected", UrlUtils.toAbsoluteUrl(tab.getUnselected()));
map.put("link", tab.getLink());
tabs.add(map);
}
// 导航颜色
String tabbarStyle = ConfigUtils.get("tabbar", "style", "{}");
// 登录配置 // 登录配置
Map<String, Object> loginMap = new LinkedHashMap<>(); Map<String, Object> loginMap = new LinkedHashMap<>();
Map<String, String> loginConfig = ConfigUtils.get("login"); Map<String, String> loginConfig = ConfigUtils.get("login");
loginMap.put("loginWay", ListUtils.stringToListAsInt(loginConfig.getOrDefault("loginWay", ""), ",")); // 登录方式
loginMap.put("forceBindMobile", Integer.parseInt(loginConfig.getOrDefault("forceBindMobile", "0"))); loginMap.put("login_way", ListUtils.stringToListAsInt(loginConfig.getOrDefault("login_way", ""), ","));
loginMap.put("openAgreement", Integer.parseInt(loginConfig.getOrDefault("openAgreement", "0"))); // 注册强制绑定手机
loginMap.put("openOtherAuth", Integer.parseInt(loginConfig.getOrDefault("openOtherAuth", "0"))); loginMap.put("coerce_mobile", Integer.parseInt(loginConfig.getOrDefault("coerce_mobile", "0")));
loginMap.put("autoLoginAuth", ListUtils.stringToListAsInt(loginConfig.getOrDefault("autoLoginAuth", ""), ",")); // 政策协议
loginMap.put("login_agreement", Integer.parseInt(loginConfig.getOrDefault("login_agreement", "0")));
// 第三方登录 开关
loginMap.put("third_auth", Integer.parseInt(loginConfig.getOrDefault("third_auth", "0")));
// 微信授权登录
loginMap.put("wechat_auth", Integer.parseInt(loginConfig.getOrDefault("wechat_auth", "0")));
// qq授权登录
loginMap.put("qq_auth", Integer.parseInt(loginConfig.getOrDefault("qq_auth", "0")));
Map<String, String> websiteConfig = ConfigUtils.get("copyright");
String copyright = websiteConfig.getOrDefault("config", "[]");
List<Map<String, String>> copyrightMap = ListUtils.stringToListAsMapStr(copyright);
// 网址信息 // 网址信息
Map<String, Object> websiteMap = new LinkedHashMap<>();
Map<String, String> websiteConfig = ConfigUtils.get("website");
websiteMap.put("name", websiteConfig.getOrDefault("shopName", "LikeAdmin"));
websiteMap.put("logo", UrlUtils.toAbsoluteUrl(websiteConfig.getOrDefault("shopLogo", "")));
// H5配置 response.put("admin_url", "");
Map<String, Object> h5Map = new LinkedHashMap<>(); response.put("copyright", copyrightMap);
Map<String, String> h5Config = ConfigUtils.get("h5_channel");
h5Map.put("status", Integer.parseInt(h5Config.getOrDefault("status", "0")));
h5Map.put("close", Integer.parseInt(h5Config.getOrDefault("close", "0")));
h5Map.put("url", h5Config.getOrDefault("url", "0"));
h5Map.put("accessLink", RequestUtils.uri());
// 响应数据
response.put("version", GlobalConfig.version);
response.put("domain", UrlUtils.domain()); response.put("domain", UrlUtils.domain());
response.put("style", MapUtils.jsonToMap(tabbarStyle));
response.put("tabbar", tabs);
response.put("login", loginMap); response.put("login", loginMap);
response.put("website", websiteMap);
response.put("h5", h5Map);
return response; return response;
} }

View File

@ -1,5 +1,6 @@
package com.mdd.front.service.impl; package com.mdd.front.service.impl;
import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mdd.common.config.GlobalConfig; import com.mdd.common.config.GlobalConfig;
import com.mdd.common.entity.article.ArticleCate; import com.mdd.common.entity.article.ArticleCate;
@ -52,7 +53,7 @@ public class PcServiceImpI implements IPcService {
//全部资讯 //全部资讯
List<Article> articlesAll = articleMapper.selectList(new QueryWrapper<Article>() List<Article> articlesAll = articleMapper.selectList(new QueryWrapper<Article>()
.eq("is_show", 1) .eq("is_show", 1)
.eq("is_delete", 0) .isNull("delete_time")
.orderByDesc("sort") .orderByDesc("sort")
.orderByDesc("id") .orderByDesc("id")
.last("limit 5")); .last("limit 5"));
@ -74,7 +75,7 @@ public class PcServiceImpI implements IPcService {
//最新资讯 //最新资讯
List<Article> articlesNew = articleMapper.selectList(new QueryWrapper<Article>() List<Article> articlesNew = articleMapper.selectList(new QueryWrapper<Article>()
.eq("is_show", 1) .eq("is_show", 1)
.eq("is_delete", 0) .isNull("delete_time")
.orderByDesc("id") .orderByDesc("id")
.last("limit 7")); .last("limit 7"));
List<Map<String, Object>> articlesNewList = new LinkedList<>(); List<Map<String, Object>> articlesNewList = new LinkedList<>();
@ -95,8 +96,8 @@ public class PcServiceImpI implements IPcService {
//热门资讯 //热门资讯
List<Article> articlesHot = articleMapper.selectList(new QueryWrapper<Article>() List<Article> articlesHot = articleMapper.selectList(new QueryWrapper<Article>()
.eq("is_show", 1) .eq("is_show", 1)
.eq("is_delete", 0) .isNull("delete_time")
.orderByDesc("visit") .orderByDesc("click_actual")
.last("limit 7")); .last("limit 7"));
List<Map<String, Object>> articlesHostList = new LinkedList<>(); List<Map<String, Object>> articlesHostList = new LinkedList<>();
for (Article article : articlesHot) { for (Article article : articlesHot) {
@ -107,7 +108,7 @@ public class PcServiceImpI implements IPcService {
map.put("summary", article.getAbstractField()); map.put("summary", article.getAbstractField());
map.put("image", UrlUtils.toAbsoluteUrl(article.getImage())); map.put("image", UrlUtils.toAbsoluteUrl(article.getImage()));
map.put("author", article.getAuthor()); map.put("author", article.getAuthor());
map.put("visit", article.getClickActual()); map.put("click_actual", article.getClickActual());
map.put("sort", article.getSort()); map.put("sort", article.getSort());
map.put("createTime", TimeUtils.timestampToDate(article.getCreateTime())); map.put("createTime", TimeUtils.timestampToDate(article.getCreateTime()));
articlesHostList.add(map); articlesHostList.add(map);
@ -128,44 +129,38 @@ public class PcServiceImpI implements IPcService {
*/ */
@Override @Override
public Map<String, Object> getConfig() { public Map<String, Object> getConfig() {
Map<String, Object> config = new LinkedHashMap<>(); Map<String, Object> response = new LinkedHashMap<>();
// 登录配置 // 登录配置
Map<String, Object> loginMap = new LinkedHashMap<>(); Map<String, Object> loginMap = new LinkedHashMap<>();
Map<String, String> loginConfig = ConfigUtils.get("login"); Map<String, String> loginConfig = ConfigUtils.get("login");
loginMap.put("loginWay", ListUtils.stringToListAsInt(loginConfig.getOrDefault("loginWay", ""), ",")); // 登录方式
loginMap.put("forceBindMobile", Integer.parseInt(loginConfig.getOrDefault("forceBindMobile", "0"))); loginMap.put("login_way", JSONArray.parseArray(loginConfig.getOrDefault("login_way", "[]")));
loginMap.put("openOtherAuth", Integer.parseInt(loginConfig.getOrDefault("openOtherAuth", "0"))); // 注册强制绑定手机
loginMap.put("openAgreement", Integer.parseInt(loginConfig.getOrDefault("openAgreement", "0"))); loginMap.put("coerce_mobile", Integer.parseInt(loginConfig.getOrDefault("coerce_mobile", "0")));
loginMap.put("autoLoginAuth", ListUtils.stringToListAsInt(loginConfig.getOrDefault("autoLoginAuth", ""), ",")); // 政策协议
loginMap.put("login_agreement", Integer.parseInt(loginConfig.getOrDefault("login_agreement", "0")));
// 第三方登录 开关
loginMap.put("third_auth", Integer.parseInt(loginConfig.getOrDefault("third_auth", "0")));
// 微信授权登录
loginMap.put("wechat_auth", Integer.parseInt(loginConfig.getOrDefault("wechat_auth", "0")));
// qq授权登录
loginMap.put("qq_auth", Integer.parseInt(loginConfig.getOrDefault("qq_auth", "0")));
// 网址信息
Map<String, Object> websiteMap = new LinkedHashMap<>(); Map<String, String> websiteConfig = ConfigUtils.get("copyright");
Map<String, String> websiteConfig = ConfigUtils.get("website"); String copyright = websiteConfig.getOrDefault("config", "[]");
String copyright = websiteConfig.getOrDefault("copyright", "[]");
List<Map<String, String>> copyrightMap = ListUtils.stringToListAsMapStr(copyright); List<Map<String, String>> copyrightMap = ListUtils.stringToListAsMapStr(copyright);
websiteMap.put("shopName", websiteConfig.getOrDefault("shopName", "LikeAdmin")); // 网址信息
websiteMap.put("shopLogo", UrlUtils.toAbsoluteUrl(websiteConfig.getOrDefault("shopLogo", "")));
websiteMap.put("pcDesc", websiteConfig.getOrDefault("pcDesc", ""));
websiteMap.put("pcIco", UrlUtils.toAbsoluteUrl(websiteConfig.getOrDefault("pcIco", "")));
websiteMap.put("pcKeywords", websiteConfig.getOrDefault("pcKeywords", ""));
websiteMap.put("pcLogo", UrlUtils.toAbsoluteUrl(websiteConfig.getOrDefault("pcLogo", "")));
websiteMap.put("pcTitle", websiteConfig.getOrDefault("pcTitle", ""));
// 演示公众号和小程序二维码 response.put("admin_url", "");
Map<String,String> qrCodeMap = new LinkedHashMap<>(); response.put("copyright", copyrightMap);
qrCodeMap.put("mnp",UrlUtils.toAbsoluteUrl(ConfigUtils.get("mp_channel","qrCode"))); response.put("domain", UrlUtils.domain());
qrCodeMap.put("oa",UrlUtils.toAbsoluteUrl(ConfigUtils.get("oa_channel","qrCode"))); response.put("login", loginMap);
response.put("version", GlobalConfig.version);
// 返回数据 response.put("website", "xxxxx");
config.put("version", GlobalConfig.version); return response;
config.put("domain", UrlUtils.domain());
config.put("login", loginMap);
config.put("website", websiteMap);
config.put("copyright",copyrightMap);
config.put("qrcode",qrCodeMap);
return config;
} }
/** /**