|
@@ -1,6 +1,7 @@
|
|
|
package com.fjhx.xmhjc.service.column.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.xmhjc.entity.about.po.AboutUsCulture;
|
|
|
import com.fjhx.xmhjc.entity.column.dto.ColumnMenuSelectDto;
|
|
@@ -24,6 +25,7 @@ import com.fjhx.xmhjc.entity.column.dto.ColumnArticleDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -69,7 +71,7 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
|
|
|
@Override
|
|
|
public Page<ColumnArticleVo> getPage(ColumnArticleSelectDto dto) {
|
|
|
IWrapper<ColumnArticle> wrapper = getWrapper();
|
|
|
- wrapper.keyword(dto, new SqlField("ca", ColumnArticle::getSort));
|
|
|
+ wrapper.keyword(dto, new SqlField("ca", ColumnArticle::getTitle));
|
|
|
if(StrUtil.isNotBlank(dto.getStatus())){
|
|
|
wrapper.eq("ca", ColumnArticle::getStatus, dto.getStatus());
|
|
|
}
|
|
@@ -79,7 +81,7 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
|
|
|
if(Objects.nonNull(dto.getSubId())){
|
|
|
wrapper.eq("ca", ColumnArticle::getSubId, dto.getSubId());
|
|
|
}
|
|
|
- wrapper.orderByDesc("ca", ColumnArticle::getId);
|
|
|
+ wrapper.orderByAsc("ca", ColumnArticle::getSort);
|
|
|
Page<ColumnArticleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
|
|
|
Map<Long, String> map = columnMenuService.getList(new ColumnMenuSelectDto()).stream().collect(Collectors.toMap(ColumnMenuVo::getId, ColumnMenuVo::getName));
|
|
@@ -123,4 +125,63 @@ public class ColumnArticleServiceImpl extends ServiceImpl<ColumnArticleMapper, C
|
|
|
this.removeById(id);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<ColumnArticleVo> getArticleByOpen(ColumnArticleSelectDto dto) {
|
|
|
+ IWrapper<ColumnArticle> wrapper = getWrapper();
|
|
|
+ if(StrUtil.isNotBlank(dto.getStatus())){
|
|
|
+ wrapper.eq("ca", ColumnArticle::getStatus, dto.getStatus());
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(dto.getColumnId())){
|
|
|
+ wrapper.eq("ca", ColumnArticle::getColumnId, dto.getColumnId());
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(dto.getSubId())){
|
|
|
+ wrapper.eq("ca", ColumnArticle::getSubId, dto.getSubId());
|
|
|
+ }
|
|
|
+ wrapper.orderByAsc("ca", ColumnArticle::getSort);
|
|
|
+ Page<ColumnArticleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+
|
|
|
+ page.getRecords().forEach(x->{
|
|
|
+ //获取封面图片
|
|
|
+ List<Long> businessIdList = new ArrayList<>();
|
|
|
+ businessIdList.add(x.getId());
|
|
|
+ Map<Long, List<FileInfoVo>> fileMap = ObsFileUtil.getFileMap(businessIdList, 1);
|
|
|
+ x.setCoverList(fileMap.get(x.getId()));
|
|
|
+ });
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ColumnArticleVo getArticleDetailByOpen(Long id) {
|
|
|
+ ColumnArticle ColumnArticle = this.getById(id);
|
|
|
+ ColumnArticleVo result = BeanUtil.toBean(ColumnArticle, ColumnArticleVo.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveReadyArticleNum(Long id) {
|
|
|
+ ColumnArticle columnArticle = this.getById(id);
|
|
|
+ columnArticle.setReadNum(Math.addExact(columnArticle.getReadNum(),1L));
|
|
|
+ updateById(columnArticle);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 相关文章
|
|
|
+ * 根据点击量排序
|
|
|
+ * @param dto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<ColumnArticleVo> relatedArticles(ColumnArticleSelectDto dto) {
|
|
|
+ IWrapper<ColumnArticle> wrapper = getWrapper();
|
|
|
+ wrapper.keyword(dto, new SqlField("ca", ColumnArticle::getTitle));
|
|
|
+ if(StrUtil.isNotBlank(dto.getStatus())){
|
|
|
+ wrapper.eq("ca", ColumnArticle::getStatus, dto.getStatus());
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(dto.getSubId())){
|
|
|
+ wrapper.eq("ca", ColumnArticle::getSubId, dto.getSubId());
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc("ca", ColumnArticle::getReadNum);
|
|
|
+ Page<ColumnArticleVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
}
|