Commit 04a7175c by 郑永强

资讯列表增加字段

parent 93e0d7fa
package com.pcloud.book.applet.biz.impl;
import com.pcloud.appcenter.assist.dto.AssistTempletDTO;
import com.pcloud.book.applet.biz.AppletNewsBiz;
import com.pcloud.book.applet.dao.AppletNewsClassifyDao;
import com.pcloud.book.applet.dao.AppletNewsCommentDao;
......@@ -12,6 +13,9 @@ import com.pcloud.book.applet.entity.AppletNews;
import com.pcloud.book.applet.entity.AppletNewsClassify;
import com.pcloud.book.applet.entity.AppletNewsComment;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.dao.BookLabelDao;
import com.pcloud.book.book.entity.BookLabel;
import com.pcloud.book.consumer.app.AssistTempletConsr;
import com.pcloud.book.consumer.label.LabelConsr;
import com.pcloud.book.consumer.reader.ReaderConsr;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
......@@ -50,6 +54,10 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
private ReaderConsr readerConsr;
@Autowired
private RightsSettingBiz rightsSettingBiz;
@Autowired
private BookLabelDao bookLabelDao;
@Autowired
private AssistTempletConsr assistTempletConsr;
@Override
public Long addAppletNewsClassify(AppletNewsClassify appletNewsClassify) {
......@@ -118,6 +126,7 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
return new PageBeanNew<>(currentPage,numPerPage,0,new ArrayList<>());
}
fillLabel(pageBeanNew.getRecordList());
setLabelContent(pageBeanNew.getRecordList());
return pageBeanNew;
}
......@@ -155,6 +164,58 @@ public class AppletNewsBizImpl implements AppletNewsBiz {
}
}
private void setLabelContent(List<AppletNewsDTO> appletNewsDTOS) {
if (ListUtils.isEmpty(appletNewsDTOS)){
return;
}
List<Long> firstClassifyIds = new ArrayList<>(appletNewsDTOS.size());
List<Long> secondClassifyIds = new ArrayList<>(appletNewsDTOS.size());
List<Long> classifyIds = new ArrayList<>();
List<Long> gradeLabelIds = new ArrayList<>(appletNewsDTOS.size());
List<Long> subjectLabelIds = new ArrayList<>(appletNewsDTOS.size());
List<Long> labelIds = new ArrayList<>();
for (AppletNewsDTO appletNewsDTO : appletNewsDTOS){
firstClassifyIds.add(appletNewsDTO.getFirstClassify());
secondClassifyIds.add(appletNewsDTO.getSecondClassify());
gradeLabelIds.add(appletNewsDTO.getGradeLabelId());
subjectLabelIds.add(appletNewsDTO.getSubjectLabelId());
}
if (!ListUtils.isEmpty(firstClassifyIds)){
classifyIds.addAll(firstClassifyIds);
}
if (!ListUtils.isEmpty(secondClassifyIds)){
classifyIds.addAll(secondClassifyIds);
}
if (!ListUtils.isEmpty(gradeLabelIds)){
labelIds.addAll(gradeLabelIds);
}
if (!ListUtils.isEmpty(subjectLabelIds)){
labelIds.addAll(subjectLabelIds);
}
Map<Long, AssistTempletDTO> classifyMap = new HashMap<>();
Map<Long, BookLabel> labelMap= new HashMap<>();
if (!ListUtils.isEmpty(classifyIds)){
classifyMap = assistTempletConsr.mapByIds4Classify(classifyIds);
}
if (!ListUtils.isEmpty(labelIds)){
labelMap = bookLabelDao.getMapByIds(labelIds);
}
for (AppletNewsDTO appletNewsDTO : appletNewsDTOS){
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(appletNewsDTO.getFirstClassify())){
appletNewsDTO.setFirstClassifyContent(classifyMap.get(appletNewsDTO.getFirstClassify()).getTempletName());
}
if (!MapUtils.isEmpty(classifyMap) && classifyMap.containsKey(appletNewsDTO.getSecondClassify())){
appletNewsDTO.setSecondClassifyContent(classifyMap.get(appletNewsDTO.getSecondClassify()).getTempletName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(appletNewsDTO.getGradeLabelId())){
appletNewsDTO.setGradeLabelIdContent(labelMap.get(appletNewsDTO.getGradeLabelId()).getName());
}
if (!MapUtils.isEmpty(labelMap) && labelMap.containsKey(appletNewsDTO.getSubjectLabelId())){
appletNewsDTO.setSubjectLabelIdContent(labelMap.get(appletNewsDTO.getSubjectLabelId()).getName());
}
}
}
@Override
public List<AppletNewsClassifyDTO> getAllNewsClassify(Boolean showState) {
return appletNewsClassifyDao.getAllNewsClassify(showState);
......
......@@ -65,4 +65,14 @@ public class AppletNewsDTO extends BaseDto {
@ApiModelProperty("权益分类id")
private Long rightsClassifyId;
private String firstClassifyContent;
private String secondClassifyContent;
private String gradeLabelIdContent;
private String subjectLabelIdContent;
@ApiModelProperty("权益分类")
private String rightsClassifyContent;
}
......@@ -128,9 +128,11 @@
n.second_classify secondClassify,
n.grade_label_id gradeLabelId,
n.subject_label_id subjectLabelId,
n.rights_classify_id rightsClassifyId
FROM applet_news n LEFT JOIN applet_news_classify c ON
n.news_classify_id=c.id
n.rights_classify_id rightsClassifyId,
d.classify rightsClassifyContent
FROM applet_news n
LEFT JOIN applet_news_classify c ON n.news_classify_id=c.id
LEFT JOIN rights_setting_classify d ON n.rights_classify_id = d.id
WHERE 1=1
<if test="name != null">
AND n.news_name LIKE CONCAT("%",#{name},"%")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment