|
@@ -1,7 +1,10 @@
|
|
|
package com.zheng.cms.web.controller;
|
|
package com.zheng.cms.web.controller;
|
|
|
|
|
|
|
|
import com.zheng.cms.dao.model.CmsArticle;
|
|
import com.zheng.cms.dao.model.CmsArticle;
|
|
|
|
|
+import com.zheng.cms.dao.model.CmsComment;
|
|
|
|
|
+import com.zheng.cms.dao.model.CmsCommentExample;
|
|
|
import com.zheng.cms.rpc.api.CmsArticleService;
|
|
import com.zheng.cms.rpc.api.CmsArticleService;
|
|
|
|
|
+import com.zheng.cms.rpc.api.CmsCommentService;
|
|
|
import com.zheng.common.base.BaseController;
|
|
import com.zheng.common.base.BaseController;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -12,6 +15,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 文章控制器
|
|
* 文章控制器
|
|
|
* Created by shuzheng on 2017/3/26.
|
|
* Created by shuzheng on 2017/3/26.
|
|
@@ -25,10 +30,21 @@ public class ArticleController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CmsArticleService cmsArticleService;
|
|
private CmsArticleService cmsArticleService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CmsCommentService cmsCommentService;
|
|
|
|
|
+
|
|
|
@RequestMapping(value = "/{articleId}", method = RequestMethod.GET)
|
|
@RequestMapping(value = "/{articleId}", method = RequestMethod.GET)
|
|
|
public String index(@PathVariable("articleId") int articleId, Model model) {
|
|
public String index(@PathVariable("articleId") int articleId, Model model) {
|
|
|
CmsArticle article = cmsArticleService.selectByPrimaryKey(articleId);
|
|
CmsArticle article = cmsArticleService.selectByPrimaryKey(articleId);
|
|
|
model.addAttribute("article", article);
|
|
model.addAttribute("article", article);
|
|
|
|
|
+ // 评论列表
|
|
|
|
|
+ CmsCommentExample cmsCommentExample = new CmsCommentExample();
|
|
|
|
|
+ cmsCommentExample.createCriteria()
|
|
|
|
|
+ .andArticleIdEqualTo(articleId)
|
|
|
|
|
+ .andStatusEqualTo((byte) 1);
|
|
|
|
|
+ cmsCommentExample.setOrderByClause("ctime desc");
|
|
|
|
|
+ List<CmsComment> comments = cmsCommentService.selectByExampleWithBLOBs(cmsCommentExample);
|
|
|
|
|
+ model.addAttribute("comments", comments);
|
|
|
return thymeleaf("/article/index");
|
|
return thymeleaf("/article/index");
|
|
|
}
|
|
}
|
|
|
|
|
|