Merge branch 'develop' of https://gitee.com/likeadmin/likeadmin_java into develop
This commit is contained in:
commit
96ce0b284c
|
|
@ -30,6 +30,7 @@ public class FrontConfig {
|
||||||
"/api/article/list",
|
"/api/article/list",
|
||||||
"/api/pc/getConfig",
|
"/api/pc/getConfig",
|
||||||
"/api/pc/index",
|
"/api/pc/index",
|
||||||
|
"/api/pc/articleCenter",
|
||||||
"/api/pc/articleDetail",
|
"/api/pc/articleDetail",
|
||||||
"/api/login/getScanCode",
|
"/api/login/getScanCode",
|
||||||
"/api/login/scanLogin",
|
"/api/login/scanLogin",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.mdd.common.validator.annotation.IDMust;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IArticleService;
|
import com.mdd.front.service.IArticleService;
|
||||||
import com.mdd.front.validate.ArticleCollectValidate;
|
import com.mdd.front.validate.ArticleCollectValidate;
|
||||||
|
import com.mdd.front.validate.ArticleSearchValidate;
|
||||||
import com.mdd.front.validate.commons.PageValidate;
|
import com.mdd.front.validate.commons.PageValidate;
|
||||||
import com.mdd.front.vo.article.ArticleCateVo;
|
import com.mdd.front.vo.article.ArticleCateVo;
|
||||||
import com.mdd.front.vo.article.ArticleCollectVo;
|
import com.mdd.front.vo.article.ArticleCollectVo;
|
||||||
|
|
@ -47,6 +48,7 @@ public class ArticleController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public AjaxResult<PageResult<ArticleListedVo>> list(@Validated PageValidate pageValidate,
|
public AjaxResult<PageResult<ArticleListedVo>> list(@Validated PageValidate pageValidate,
|
||||||
|
@Validated ArticleSearchValidate searchValidate,
|
||||||
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
@RequestParam(value = "cid", defaultValue = "0") Integer cid) {
|
||||||
Integer userId = LikeFrontThreadLocal.getUserId();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
PageResult<ArticleListedVo> list = iArticleService.list(pageValidate, cid, userId);
|
PageResult<ArticleListedVo> list = iArticleService.list(pageValidate, cid, userId);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.mdd.common.core.AjaxResult;
|
||||||
import com.mdd.common.validator.annotation.IDMust;
|
import com.mdd.common.validator.annotation.IDMust;
|
||||||
import com.mdd.front.LikeFrontThreadLocal;
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IPcService;
|
import com.mdd.front.service.IPcService;
|
||||||
|
import com.mdd.front.vo.PcArticleCenterVo;
|
||||||
import com.mdd.front.vo.PcArticleDetailVo;
|
import com.mdd.front.vo.PcArticleDetailVo;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,6 +49,18 @@ public class PcController {
|
||||||
return AjaxResult.success(config);
|
return AjaxResult.success(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯中心
|
||||||
|
*
|
||||||
|
* @author fzr
|
||||||
|
* @return AjaxResult<List<PcArticleCenterVo>>
|
||||||
|
*/
|
||||||
|
@GetMapping("/articleCenter")
|
||||||
|
public AjaxResult<List<PcArticleCenterVo>> articleCenter() {
|
||||||
|
List<PcArticleCenterVo> list = iPcService.articleCenter();
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章详情
|
* 文章详情
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.mdd.front.service;
|
package com.mdd.front.service;
|
||||||
|
|
||||||
|
import com.mdd.front.vo.PcArticleCenterVo;
|
||||||
import com.mdd.front.vo.PcArticleDetailVo;
|
import com.mdd.front.vo.PcArticleDetailVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface IPcService {
|
public interface IPcService {
|
||||||
|
|
@ -20,12 +22,20 @@ public interface IPcService {
|
||||||
*/
|
*/
|
||||||
Map<String, Object> getConfig();
|
Map<String, Object> getConfig();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯中心
|
||||||
|
*
|
||||||
|
* @authro fzr
|
||||||
|
* @return PcArticleCenterVo
|
||||||
|
*/
|
||||||
|
List<PcArticleCenterVo> articleCenter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章详情
|
* 文章详情
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param id 文章主键
|
* @param id 文章主键
|
||||||
* @return Object
|
* @return PcArticleDetailVo
|
||||||
*/
|
*/
|
||||||
PcArticleDetailVo articleDetail(Integer id, Integer userId);
|
PcArticleDetailVo articleDetail(Integer id, Integer userId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.mdd.common.mapper.article.ArticleCollectMapper;
|
||||||
import com.mdd.common.mapper.article.ArticleMapper;
|
import com.mdd.common.mapper.article.ArticleMapper;
|
||||||
import com.mdd.common.util.*;
|
import com.mdd.common.util.*;
|
||||||
import com.mdd.front.service.IPcService;
|
import com.mdd.front.service.IPcService;
|
||||||
|
import com.mdd.front.vo.PcArticleCenterVo;
|
||||||
import com.mdd.front.vo.PcArticleDetailVo;
|
import com.mdd.front.vo.PcArticleDetailVo;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -164,6 +165,42 @@ public class PcServiceImpI implements IPcService {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PcArticleCenterVo> articleCenter() {
|
||||||
|
List<ArticleCategory> articleCategoryList = articleCategoryMapper.selectList(
|
||||||
|
new QueryWrapper<ArticleCategory>()
|
||||||
|
.eq("is_show", 1)
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.orderByDesc(Arrays.asList("sort", "id")));
|
||||||
|
|
||||||
|
List<PcArticleCenterVo> list = new LinkedList<>();
|
||||||
|
for (ArticleCategory articleCategory : articleCategoryList) {
|
||||||
|
List<Article> articleList = articleMapper.selectList(new QueryWrapper<Article>()
|
||||||
|
.eq("cid", articleCategory.getId())
|
||||||
|
.eq("is_show", 1)
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.orderByDesc(Arrays.asList("sort", "id"))
|
||||||
|
.last("limit 10"));
|
||||||
|
|
||||||
|
List<Map<String, Object>> articles = new LinkedList<>();
|
||||||
|
for (Article article : articleList) {
|
||||||
|
Map<String, Object> a = new LinkedHashMap<>();
|
||||||
|
a.put("id", article.getId());
|
||||||
|
a.put("title", article.getTitle());
|
||||||
|
a.put("image", UrlUtils.toAbsoluteUrl(article.getImage()));
|
||||||
|
articles.add(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
PcArticleCenterVo vo = new PcArticleCenterVo();
|
||||||
|
vo.setId(articleCategory.getId());
|
||||||
|
vo.setName(articleCategory.getName());
|
||||||
|
vo.setArticle(articles);
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文章详情
|
* 文章详情
|
||||||
*
|
*
|
||||||
|
|
@ -191,12 +228,12 @@ public class PcServiceImpI implements IPcService {
|
||||||
// 分类名称
|
// 分类名称
|
||||||
ArticleCategory articleCategory = articleCategoryMapper.selectOne(
|
ArticleCategory articleCategory = articleCategoryMapper.selectOne(
|
||||||
new QueryWrapper<ArticleCategory>()
|
new QueryWrapper<ArticleCategory>()
|
||||||
.eq("id", article.getId())
|
.eq("id", article.getCid())
|
||||||
.eq("is_delete", 0));
|
.eq("is_delete", 0));
|
||||||
|
|
||||||
// 上一条记录
|
// 上一条记录
|
||||||
Article prev = articleMapper.selectOne(new QueryWrapper<Article>()
|
Article prev = articleMapper.selectOne(new QueryWrapper<Article>()
|
||||||
.select()
|
.select("id,title")
|
||||||
.lt("id", id)
|
.lt("id", id)
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.orderByDesc(Arrays.asList("sort", "id"))
|
.orderByDesc(Arrays.asList("sort", "id"))
|
||||||
|
|
@ -217,6 +254,25 @@ public class PcServiceImpI implements IPcService {
|
||||||
.eq("is_delete", 0)
|
.eq("is_delete", 0)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
|
||||||
|
// 最新资讯
|
||||||
|
List<Article> news = articleMapper.selectList(new QueryWrapper<Article>()
|
||||||
|
.select("id,title,image,create_time,update_time")
|
||||||
|
.eq("cid", article.getCid())
|
||||||
|
.eq("is_delete", 0)
|
||||||
|
.orderByDesc("id")
|
||||||
|
.last("limit 8"));
|
||||||
|
|
||||||
|
List<Map<String, Object>> newsList = new LinkedList<>();
|
||||||
|
for (Article newArticle : news) {
|
||||||
|
Map<String, Object> newsMap = new LinkedHashMap<>();
|
||||||
|
newsMap.put("id", newArticle.getId());
|
||||||
|
newsMap.put("title", newArticle.getTitle());
|
||||||
|
newsMap.put("image", UrlUtils.toAbsoluteUrl(newArticle.getImage()));
|
||||||
|
newsMap.put("createTime", TimeUtils.timestampToDate(newArticle.getCreateTime()));
|
||||||
|
newsMap.put("updateTime", TimeUtils.timestampToDate(newArticle.getUpdateTime()));
|
||||||
|
newsList.add(newsMap);
|
||||||
|
}
|
||||||
|
|
||||||
// 处理数据
|
// 处理数据
|
||||||
PcArticleDetailVo vo = new PcArticleDetailVo();
|
PcArticleDetailVo vo = new PcArticleDetailVo();
|
||||||
BeanUtils.copyProperties(article, vo);
|
BeanUtils.copyProperties(article, vo);
|
||||||
|
|
@ -224,6 +280,7 @@ public class PcServiceImpI implements IPcService {
|
||||||
vo.setUpdateTime(TimeUtils.timestampToDate(vo.getUpdateTime()));
|
vo.setUpdateTime(TimeUtils.timestampToDate(vo.getUpdateTime()));
|
||||||
vo.setCategory(StringUtils.isNotNull(articleCategory) ? articleCategory.getName() : "");
|
vo.setCategory(StringUtils.isNotNull(articleCategory) ? articleCategory.getName() : "");
|
||||||
vo.setIsCollect(StringUtils.isNotNull(collect) ? 1 : 0);
|
vo.setIsCollect(StringUtils.isNotNull(collect) ? 1 : 0);
|
||||||
|
vo.setNews(newsList);
|
||||||
vo.setPrev(null);
|
vo.setPrev(null);
|
||||||
vo.setNext(null);
|
vo.setNext(null);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.mdd.front.validate;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章搜索参数
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ArticleSearchValidate implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mdd.front.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯中心数据
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PcArticleCenterVo implements Serializable {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String name;
|
||||||
|
private Object article;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,7 @@ public class PcArticleDetailVo implements Serializable {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private Integer cid;
|
private Integer cid;
|
||||||
private String category;
|
private String category;
|
||||||
|
private String title;
|
||||||
private String intro;
|
private String intro;
|
||||||
private String summary;
|
private String summary;
|
||||||
private String image;
|
private String image;
|
||||||
|
|
@ -25,6 +26,6 @@ public class PcArticleDetailVo implements Serializable {
|
||||||
private String updateTime;
|
private String updateTime;
|
||||||
private Object prev;
|
private Object prev;
|
||||||
private Object next;
|
private Object next;
|
||||||
|
private Object news;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue