优化代码
This commit is contained in:
parent
6cb4ad95a7
commit
8db1cff376
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mdd.admin.controller.decorate;
|
package com.mdd.admin.controller.decorate;
|
||||||
|
|
||||||
import com.mdd.admin.service.decorate.IDecorateDataService;
|
import com.mdd.admin.service.decorate.IDecorateDataService;
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateDataArticleVo;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
@ -9,7 +10,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装修数据管理
|
* 装修数据管理
|
||||||
|
|
@ -30,7 +30,7 @@ public class DataController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/article")
|
@GetMapping("/article")
|
||||||
public AjaxResult article(@RequestParam(defaultValue = "10") Integer limit) {
|
public AjaxResult article(@RequestParam(defaultValue = "10") Integer limit) {
|
||||||
List<Map<String, Object>> list = iDecorateDataService.article(limit);
|
List<DecorateDataArticleVo> list = iDecorateDataService.article(limit);
|
||||||
return AjaxResult.success(list);
|
return AjaxResult.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.mdd.admin.controller.decorate;
|
||||||
import com.mdd.admin.config.aop.Log;
|
import com.mdd.admin.config.aop.Log;
|
||||||
import com.mdd.admin.service.decorate.IDecoratePageService;
|
import com.mdd.admin.service.decorate.IDecoratePageService;
|
||||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||||
|
import com.mdd.admin.vo.decorate.DecoratePageVo;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.validator.annotation.IDMust;
|
import com.mdd.common.validator.annotation.IDMust;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
@ -30,8 +31,8 @@ public class PagesController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public AjaxResult detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
public AjaxResult detail(@Validated @IDMust() @RequestParam("id") Integer id) {
|
||||||
Map<String, Object> map = iDecoratePageService.detail(id);
|
DecoratePageVo vo = iDecoratePageService.detail(id);
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
package com.mdd.admin.controller.decorate;
|
package com.mdd.admin.controller.decorate;
|
||||||
|
|
||||||
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateTabbarVo;
|
||||||
import com.mdd.common.core.AjaxResult;
|
import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.utils.ArrayUtil;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,8 +26,8 @@ public class TabbarController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
public AjaxResult detail() {
|
public AjaxResult detail() {
|
||||||
Map<String, Object> detail = iDecorateTabbarService.detail();
|
DecorateTabbarVo vo = iDecorateTabbarService.detail();
|
||||||
return AjaxResult.success(detail);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package com.mdd.admin.service.decorate;
|
package com.mdd.admin.service.decorate;
|
||||||
|
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateDataArticleVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装修数据服务接口类
|
* 装修数据服务接口类
|
||||||
|
|
@ -13,8 +14,8 @@ public interface IDecorateDataService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param limit 条数
|
* @param limit 条数
|
||||||
* @return List<Map<String, Object>>
|
* @return List<DecorateArticleDataVo>
|
||||||
*/
|
*/
|
||||||
List<Map<String, Object>> article(Integer limit);
|
List<DecorateDataArticleVo> article(Integer limit);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.mdd.admin.service.decorate;
|
package com.mdd.admin.service.decorate;
|
||||||
|
|
||||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||||
|
import com.mdd.admin.vo.decorate.DecoratePageVo;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -11,9 +12,9 @@ public interface IDecoratePageService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
* @return Map<String, Object>
|
* @return DecoratePageVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> detail(Integer id);
|
DecoratePageVo detail(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 页面装修保存
|
* 页面装修保存
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.mdd.admin.service.decorate;
|
package com.mdd.admin.service.decorate;
|
||||||
|
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateTabbarVo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -12,9 +14,9 @@ public interface IDecorateTabbarService {
|
||||||
* 底部导航详情
|
* 底部导航详情
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @return Map<String, Object>
|
* @return DecorateTabbarVo
|
||||||
*/
|
*/
|
||||||
Map<String, Object> detail();
|
DecorateTabbarVo detail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 底部导航保存
|
* 底部导航保存
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,17 @@ package com.mdd.admin.service.decorate.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.mdd.admin.service.decorate.IDecorateDataService;
|
import com.mdd.admin.service.decorate.IDecorateDataService;
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateDataArticleVo;
|
||||||
import com.mdd.common.entity.article.Article;
|
import com.mdd.common.entity.article.Article;
|
||||||
import com.mdd.common.mapper.article.ArticleMapper;
|
import com.mdd.common.mapper.article.ArticleMapper;
|
||||||
import com.mdd.common.utils.TimeUtil;
|
import com.mdd.common.utils.TimeUtil;
|
||||||
import com.mdd.common.utils.UrlUtil;
|
import com.mdd.common.utils.UrlUtil;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装修数据服务实现类
|
* 装修数据服务实现类
|
||||||
|
|
@ -28,30 +28,26 @@ public class DecorateDataServiceImpl implements IDecorateDataService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param limit 条数
|
* @param limit 条数
|
||||||
* @return List<Map<String, Object>>
|
* @return List<DecorateArticleDataVo>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> article(Integer limit) {
|
public List<DecorateDataArticleVo> article(Integer limit) {
|
||||||
List<Map<String, Object>> articleList = new LinkedList<>();
|
|
||||||
List<Article> articles = articleMapper.selectList(new QueryWrapper<Article>()
|
List<Article> articles = articleMapper.selectList(new QueryWrapper<Article>()
|
||||||
.eq("is_show", 1)
|
.eq("is_show", 1)
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.orderByDesc("id")
|
.orderByDesc("id")
|
||||||
.last("limit " + limit));
|
.last("limit " + limit));
|
||||||
|
|
||||||
|
List<DecorateDataArticleVo> list = new LinkedList<>();
|
||||||
for (Article article : articles) {
|
for (Article article : articles) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
DecorateDataArticleVo vo = new DecorateDataArticleVo();
|
||||||
map.put("id", article.getId());
|
BeanUtils.copyProperties(article, vo);
|
||||||
map.put("title", article.getTitle());
|
vo.setImage(UrlUtil.toAbsoluteUrl(article.getImage()));
|
||||||
map.put("intro", article.getIntro());
|
vo.setCreateTime(TimeUtil.timestampToDate(article.getCreateTime()));
|
||||||
map.put("summary", article.getSummary());
|
list.add(vo);
|
||||||
map.put("image", UrlUtil.toAbsoluteUrl(article.getImage()));
|
|
||||||
map.put("author", article.getAuthor());
|
|
||||||
map.put("visit", article.getVisit());
|
|
||||||
map.put("createTime", TimeUtil.timestampToDate(article.getCreateTime()));
|
|
||||||
articleList.add(map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return articleList;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||||
import com.mdd.admin.service.decorate.IDecoratePageService;
|
import com.mdd.admin.service.decorate.IDecoratePageService;
|
||||||
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
import com.mdd.admin.validate.decorate.DecoratePageParam;
|
||||||
|
import com.mdd.admin.vo.decorate.DecoratePageVo;
|
||||||
import com.mdd.common.entity.decorate.DecoratePage;
|
import com.mdd.common.entity.decorate.DecoratePage;
|
||||||
import com.mdd.common.mapper.decorate.DecoratePageMapper;
|
import com.mdd.common.mapper.decorate.DecoratePageMapper;
|
||||||
import com.mdd.common.utils.ToolsUtil;
|
import com.mdd.common.utils.ToolsUtil;
|
||||||
|
|
@ -24,18 +25,18 @@ public class DecoratePageServiceImpl implements IDecoratePageService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param id 主键
|
* @param id 主键
|
||||||
* @return Map<String, Object>
|
* @return DecoratePageVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> detail(Integer id) {
|
public DecoratePageVo detail(Integer id) {
|
||||||
DecoratePage decoratePage = decoratePageMapper.selectById(id);
|
DecoratePage decoratePage = decoratePageMapper.selectById(id);
|
||||||
Assert.notNull(decoratePage, "数据不存在!");
|
Assert.notNull(decoratePage, "数据不存在!");
|
||||||
|
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
DecoratePageVo vo = new DecoratePageVo();
|
||||||
map.put("id", decoratePage.getId());
|
vo.setId(decoratePage.getId());
|
||||||
map.put("pageType", decoratePage.getPageType());
|
vo.setPageType(vo.getPageType());
|
||||||
map.put("pageData", decoratePage.getPageData());
|
vo.setPageData(decoratePage.getPageData());
|
||||||
return map;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.mdd.admin.service.decorate.impl;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
import com.mdd.admin.service.decorate.IDecorateTabbarService;
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateTabObjVo;
|
||||||
|
import com.mdd.admin.vo.decorate.DecorateTabbarVo;
|
||||||
import com.mdd.common.entity.decorate.DecorateTabbar;
|
import com.mdd.common.entity.decorate.DecorateTabbar;
|
||||||
import com.mdd.common.mapper.decorate.DecorateTabbarMapper;
|
import com.mdd.common.mapper.decorate.DecorateTabbarMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
|
|
@ -28,31 +30,33 @@ public class DecorateTabbarServiceImpl implements IDecorateTabbarService {
|
||||||
* 底部导航详情
|
* 底部导航详情
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @return Map<String, Object>
|
* @return DecorateTabbarVo
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> detail() {
|
public DecorateTabbarVo detail() {
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
|
||||||
List<DecorateTabbar> list = decorateTabbarMapper.selectList(
|
List<DecorateTabbar> list = decorateTabbarMapper.selectList(
|
||||||
new QueryWrapper<DecorateTabbar>()
|
new QueryWrapper<DecorateTabbar>()
|
||||||
.orderByAsc("id"));
|
.orderByAsc("id"));
|
||||||
|
|
||||||
List<Map<String, Object>> tabList = new LinkedList<>();
|
List<DecorateTabObjVo> tabList = new LinkedList<>();
|
||||||
for (DecorateTabbar tab: list) {
|
for (DecorateTabbar tab: list) {
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
DecorateTabObjVo vo = new DecorateTabObjVo();
|
||||||
map.put("id", tab.getId());
|
vo.setId(tab.getId());
|
||||||
map.put("name", tab.getName());
|
vo.setName(tab.getName());
|
||||||
map.put("selected", UrlUtil.toAbsoluteUrl(tab.getSelected()));
|
vo.setSelected(UrlUtil.toAbsoluteUrl(tab.getSelected()));
|
||||||
map.put("unselected", UrlUtil.toAbsoluteUrl(tab.getUnselected()));
|
vo.setUnselected(UrlUtil.toAbsoluteUrl(tab.getUnselected()));
|
||||||
map.put("link", tab.getLink());
|
vo.setLink(tab.getLink());
|
||||||
map.put("createTime", TimeUtil.timestampToDate(tab.getCreateTime()));
|
vo.setCreateTime(TimeUtil.timestampToDate(tab.getCreateTime()));
|
||||||
map.put("updateTime", TimeUtil.timestampToDate(tab.getUpdateTime()));
|
vo.setUnselected(TimeUtil.timestampToDate(tab.getUpdateTime()));
|
||||||
tabList.add(map);
|
tabList.add(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
String tabbar = ConfigUtil.get("tabbar", "style", "{}");
|
String tabbar = ConfigUtil.get("tabbar", "style", "{}");
|
||||||
response.put("style", ToolsUtil.jsonToMap(tabbar));
|
|
||||||
response.put("list", tabList);
|
DecorateTabbarVo response = new DecorateTabbarVo();
|
||||||
|
response.setStyle(ToolsUtil.jsonToMap(tabbar));
|
||||||
|
response.setList(tabList);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mdd.admin.vo.decorate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DecorateDataArticleVo {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String title;
|
||||||
|
private String intro;
|
||||||
|
private String summary;
|
||||||
|
private String image;
|
||||||
|
private String author;
|
||||||
|
private Integer visit;
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mdd.admin.vo.decorate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DecoratePageVo {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private Integer pageType;
|
||||||
|
private String pageData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.mdd.admin.vo.decorate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DecorateTabObjVo {
|
||||||
|
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private String selected;
|
||||||
|
private String unselected;
|
||||||
|
private String link;
|
||||||
|
private String createTime;
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.mdd.admin.vo.decorate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DecorateTabbarVo {
|
||||||
|
|
||||||
|
private Map<String, String> style;
|
||||||
|
private List<DecorateTabObjVo> list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -29,8 +29,6 @@ public class UploadController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/image")
|
@PostMapping("/image")
|
||||||
public Object image(HttpServletRequest request) {
|
public Object image(HttpServletRequest request) {
|
||||||
|
|
||||||
System.out.println(request.getParameter("dir"));
|
|
||||||
MultipartFile multipartFile;
|
MultipartFile multipartFile;
|
||||||
try {
|
try {
|
||||||
multipartFile = ((MultipartRequest) request).getFile("file");
|
multipartFile = ((MultipartRequest) request).getFile("file");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue