调整接口

This commit is contained in:
TinyAnts 2022-09-07 14:43:07 +08:00
parent 4dc75a0459
commit 82f2a92dfd
2 changed files with 25 additions and 21 deletions

View File

@ -17,7 +17,7 @@ import java.util.Map;
public class IndexController {
@Resource
IIndexService IIndexService;
IIndexService iIndexService;
/**
* 首页
@ -27,7 +27,7 @@ public class IndexController {
*/
@GetMapping("/index")
public Object index() {
Map<String, Object> detail = IIndexService.index();
Map<String, Object> detail = iIndexService.index();
return AjaxResult.success(detail);
}
@ -40,7 +40,7 @@ public class IndexController {
*/
@GetMapping("/decorate")
public Object decorate(@Validated @IDMust() @RequestParam("id") Integer id) {
Map<String, Object> detail = IIndexService.decorate(id);
Map<String, Object> detail = iIndexService.decorate(id);
return AjaxResult.success(detail);
}
@ -52,6 +52,8 @@ public class IndexController {
*/
@GetMapping("/config")
public Object config() {
return AjaxResult.success();
Map<String, Object> map = iIndexService.config();
return AjaxResult.success(map);
}
}

View File

@ -39,28 +39,13 @@ public class IndexServiceImpl implements IIndexService {
@Override
public Map<String, Object> index() {
Map<String, Object> response = new LinkedHashMap<>();
DecoratePage decoratePage = decoratePageMapper.selectOne(
new QueryWrapper<DecoratePage>()
.eq("id", 1)
.last("limit 1"));
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", UrlUtil.toAbsoluteUrl(tab.getSelected()));
map.put("unselected", UrlUtil.toAbsoluteUrl(tab.getUnselected()));
map.put("link", tab.getLink());
tabs.add(map);
}
String tabbarStyle = ConfigUtil.get("tabbar", "style", "{}");
response.put("domain", UrlUtil.domain());
response.put("pages", decoratePage.getPageData());
response.put("style", ToolsUtil.jsonToMap(tabbarStyle));
response.put("tabbar", tabs);
return response;
}
@ -95,7 +80,24 @@ public class IndexServiceImpl implements IIndexService {
*/
@Override
public Map<String, Object> config() {
return null;
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", UrlUtil.toAbsoluteUrl(tab.getSelected()));
map.put("unselected", UrlUtil.toAbsoluteUrl(tab.getUnselected()));
map.put("link", tab.getLink());
tabs.add(map);
}
String tabbarStyle = ConfigUtil.get("tabbar", "style", "{}");
response.put("domain", UrlUtil.domain());
response.put("style", ToolsUtil.jsonToMap(tabbarStyle));
response.put("tabbar", tabs);
return response;
}
}