Authored by 张帅

添加话题相关

... ... @@ -13,6 +13,8 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* Created by meiling.ge on 2019/1/8.
*/
... ... @@ -38,5 +40,10 @@ public class GrassTopicController {
return new ApiResponse.ApiResponseBuilder().build();
}
@RequestMapping("/getAllTopic")
@ResponseBody
public ApiResponse getAllTopic(){
List<TopicRespBo> result = topicService.getAllTopic();
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
}
... ...
... ... @@ -7,11 +7,15 @@ import com.yohobuy.platform.model.grass.request.GrassTopicReq;
import com.yohobuy.platform.model.grass.response.GrassLabelBo;
import com.yohobuy.platform.model.grass.response.TopicRespBo;
import java.util.List;
/**
* Created by meiling.ge on 2019/1/8.
*/
public interface ITopicService {
PageResponseVO<TopicRespBo> getGrassTopicList(GrassTopicReq req);
List<TopicRespBo> getAllTopic();
void addUpGrassTopic(GrassTopicReq req);
}
... ...
... ... @@ -7,13 +7,11 @@ import com.google.common.collect.Maps;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yohobuy.platform.common.exception.PlatformException;
import com.yohobuy.platform.common.util.DateUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleBlockDao;
import com.yohobuy.platform.dal.grass.IGrassArticleDao;
import com.yohobuy.platform.dal.grass.IGrassArticleProductDao;
import com.yohobuy.platform.dal.grass.IGrassVirtualUserDao;
import com.yohobuy.platform.dal.grass.*;
import com.yohobuy.platform.dal.grass.model.GrassArticle;
import com.yohobuy.platform.dal.grass.model.GrassArticleBlock;
import com.yohobuy.platform.dal.grass.model.GrassArticleProduct;
import com.yohobuy.platform.dal.grass.model.GrassTopic;
import com.yohobuy.platform.grass.service.IGrassArticleService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GrassArticleReq;
... ... @@ -46,6 +44,9 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
@Resource
private IGrassVirtualUserDao grassVirtualUserDao;
@Resource
private IGrassTopicDAO grassTopicDAO;
private final static String BLOCK_TEXT = "text";
private final static String BLOCK_IMAGE = "image";
... ... @@ -287,13 +288,9 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return new ArrayList<>();
}
List<Integer> ids = articleList.stream().map(GrassArticle::getId).collect(Collectors.toList());
List<Integer> topicIds = articleList.stream().map(GrassArticle::getTopicId).collect(Collectors.toList());
List<GrassArticleBlock> grassArticleContentList = grassArticleBlockDao.selectByArticleIds(ids);
List<GrassArticleProduct> grassArticlePoductList = grassArticleProductDao.selectByArticleIds(ids);
if(CollectionUtils.isNotEmpty(topicIds)){
List<String> topics = Lists.newArrayList();
}
Map<Integer, List<String>> imgMap = Maps.newHashMap();
Map<Integer,String> textMap = Maps.newHashMap();
Map<Integer, List<Integer>> sknMap = Maps.newHashMap();
... ... @@ -331,6 +328,7 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
rspBo.setArticleContent(textMap.get(article.getId()));
rspBo.setAuthorUid(article.getAuthorUid());
rspBo.setTopicId(article.getTopicId());
rspBo.setTopicName(getArticleName(article.getTopicId()));
rspBo.setNickName("");
rspBo.setCommentCount(article.getCommentCount());
rspBo.setShareCount(article.getShareCount());
... ... @@ -347,6 +345,13 @@ public class GrassArticleServiceImpl implements IGrassArticleService{
return rspBoList;
}
private String getArticleName(int id){
GrassTopic topic = grassTopicDAO.selectByPrimaryKey(id);
if(topic != null){
return topic.getTopicName();
}
return "";
}
private void publishCheck(GrassArticleReq req) throws PlatformException {
if(req.getAuthorUid() ==null){
logger.info("publishCheck uid is null");
... ...
package com.yohobuy.platform.grass.service.impl;
import com.google.common.collect.Lists;
import com.yohobuy.platform.common.util.BeanTool;
import com.yohobuy.platform.common.util.CollectionUtil;
import com.yohobuy.platform.common.util.DateUtil;
... ... @@ -67,6 +68,19 @@ public class TopicServiceImpl implements ITopicService {
}
@Override
public List<TopicRespBo> getAllTopic() {
List<GrassTopic> topicList = grassTopicDAO.selectUsingTopics();
List<TopicRespBo> rspList = Lists.newArrayList();
topicList.forEach(grassTopic -> {
TopicRespBo bo = new TopicRespBo();
bo.setId(grassTopic.getId());
bo.setTopicName(grassTopic.getTopicName());
rspList.add(bo);
});
return rspList;
}
@Override
public void addUpGrassTopic(GrassTopicReq req) {
logger.info("enter addUpGrassTopic req={}",req);
GrassTopic record = new GrassTopic();
... ...
... ... @@ -127,7 +127,15 @@
});
$("#topic").combobox({
prompt: "请选择话题"
prompt: "请选择话题",
required: true,
selectOnNavigation : true,
valueField: 'id',
textField: 'topicName',
url : serverContextPath + "/grassTopicManage/getAllTopic",
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
initimg();
... ...
... ... @@ -170,7 +170,7 @@
str = str + ' <img style="width: 60px; height: 60px" src="'+ imgList[i]+'">';
}
str =str + '</p>';
str =str + '<p> #话题</p>';
str =str + '<p> #'+rowData.topicName+'</p>';
str = str + '</div>';
return str;
... ...