|
@@ -7,6 +7,8 @@ import com.caimei.www.pojo.page.*;
|
|
|
import com.caimei.www.service.page.ArticleService;
|
|
|
import com.caimei.www.service.page.CmBrandLandingService;
|
|
|
import com.caimei.www.service.page.ProductService;
|
|
|
+import com.caimei.www.utils.PaginationVo;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,9 +21,8 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.server.ServerWebExchange;
|
|
|
import org.thymeleaf.util.StringUtils;
|
|
|
|
|
|
-import java.lang.reflect.Array;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.Arrays;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -57,29 +58,30 @@ public class ArticleController extends BaseController {
|
|
|
* 文章列表【旧center】
|
|
|
*/
|
|
|
@GetMapping("/info/center-{id}-{pageNum}.html")
|
|
|
- public String toArticleList(@PathVariable("id") Integer id, @PathVariable("pageNum") Integer pageNum, final Model model) {
|
|
|
+ public String toArticleList(@PathVariable("id") Integer id, @PathVariable("pageNum") Integer pageNum,
|
|
|
+ final Model model) {
|
|
|
List<BaseLink> typeList = articleService.getArticleTypes();
|
|
|
List<CmBrandLandingVO> cmBrandLandingList = cmBrandLandingService.getCmBrandLandingList(new CmBrandLanding()
|
|
|
.setType("4").setAuthorId(id.toString()));
|
|
|
- List<ImageLink> infoSelected = articleService.getArticleSelected();
|
|
|
- List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime();
|
|
|
+ List<ImageLink> infoSelected = articleService.getArticleSelected(0, 5);
|
|
|
+ List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(0, 3);
|
|
|
List<ProductList> productSellNumbers = productService.getProductSellNumbers();
|
|
|
List<BaseLink> data = articleService.getArticleLabels().getData();
|
|
|
List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
|
|
|
model.addAttribute("ads", Ads);
|
|
|
model.addAttribute("labels", data);
|
|
|
- model.addAttribute("articleType", typeList);//导航栏
|
|
|
- model.addAttribute("articleImages", cmBrandLandingList);//导航栏图片
|
|
|
- model.addAttribute("infoSelected", infoSelected);//精选文章
|
|
|
- model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
|
|
|
- model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3
|
|
|
+ model.addAttribute("articleType", typeList);// 导航栏
|
|
|
+ model.addAttribute("articleImages", cmBrandLandingList);// 导航栏图片
|
|
|
+ model.addAttribute("infoSelected", infoSelected);// 精选文章
|
|
|
+ model.addAttribute("productSellNumbers", productSellNumbers);// 销量前三商品
|
|
|
+ model.addAttribute("archiveFiles", archiveFiles);// 最新美业资料top3
|
|
|
model.addAttribute("typeId", id);
|
|
|
model.addAttribute("labelId", 0);
|
|
|
model.addAttribute("pageNum", pageNum);
|
|
|
model.addAttribute("isSearch", true);
|
|
|
-// System.out.println("archiveFiles" + archiveFiles);
|
|
|
-// System.out.println("infoSelected" + infoSelected);
|
|
|
- //model.addAttribute("pagePath", String.format("/info/center-%s-1.html", id));
|
|
|
+ // System.out.println("archiveFiles" + archiveFiles);
|
|
|
+ // System.out.println("infoSelected" + infoSelected);
|
|
|
+ // model.addAttribute("pagePath", String.format("/info/center-%s-1.html", id));
|
|
|
return ARTICLE_LIST_PATH;
|
|
|
}
|
|
|
|
|
@@ -87,7 +89,8 @@ public class ArticleController extends BaseController {
|
|
|
* 文章列表【旧label】
|
|
|
*/
|
|
|
@GetMapping("/info/label-{id}-{pageNum}.html")
|
|
|
- public String toArticleLabel(@PathVariable("id") Integer id, @PathVariable("pageNum") Integer pageNum, final Model model) {
|
|
|
+ public String toArticleLabel(@PathVariable("id") Integer id, @PathVariable("pageNum") Integer pageNum,
|
|
|
+ final Model model) {
|
|
|
List<BaseLink> typeList = articleService.getArticleTypes();
|
|
|
List<BaseLink> data = articleService.getArticleLabels().getData();
|
|
|
List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
|
|
@@ -98,10 +101,45 @@ public class ArticleController extends BaseController {
|
|
|
model.addAttribute("labelId", id);
|
|
|
model.addAttribute("pageNum", pageNum);
|
|
|
model.addAttribute("isSearch", false);
|
|
|
- //model.addAttribute("pagePath", String.format("/info/label-%s-1.html", id));
|
|
|
+ // model.addAttribute("pagePath", String.format("/info/label-%s-1.html", id));
|
|
|
return ARTICLE_LIST_PATH;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 精选文章和美业资料列表
|
|
|
+ */
|
|
|
+ @GetMapping("/info/articlerecommendation-{id}-{pageNum}.html")
|
|
|
+ public String selectedList(@PathVariable("id") Integer id, @PathVariable("pageNum") Integer pageNum,
|
|
|
+ final Model model) {
|
|
|
+ PageHelper.startPage(pageNum, 10);
|
|
|
+ List<BaseLink> typeList = articleService.getArticleTypes();
|
|
|
+ PaginationVo pageData = null;
|
|
|
+ if (id == 1) {// 精选文章
|
|
|
+ List<ImageLink> infoSelected = articleService.getArticleSelected(null, null);
|
|
|
+ pageData = new PaginationVo<ImageLink>(infoSelected);
|
|
|
+ } else {// 美业资料
|
|
|
+ List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(null, null);
|
|
|
+ pageData = new PaginationVo<CmProductArchiveFile>(archiveFiles);
|
|
|
+ }
|
|
|
+ if (id == 1) {// 精选文章
|
|
|
+ List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(0, 3);
|
|
|
+ List<ProductList> productSellNumbers = productService.getProductSellNumbers();
|
|
|
+ model.addAttribute("productSellNumbers", productSellNumbers);// 销量前三商品
|
|
|
+ model.addAttribute("archiveFiles", archiveFiles);// 最新美业资料top3
|
|
|
+ }
|
|
|
+ List<BaseLink> data = articleService.getArticleLabels().getData();
|
|
|
+ List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
|
|
|
+ model.addAttribute("ads", Ads);
|
|
|
+ model.addAttribute("labels", data);
|
|
|
+ model.addAttribute("articleType", typeList);// 导航栏
|
|
|
+ model.addAttribute("pageData", pageData);
|
|
|
+ model.addAttribute("labelId", 0);
|
|
|
+ model.addAttribute("pageNum", pageNum);
|
|
|
+ model.addAttribute("isSearch", true);
|
|
|
+ System.out.println("pageData" + pageData);
|
|
|
+ return ARTICLE_RECOMMENDATION;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 文章搜索结果
|
|
|
*/
|
|
@@ -117,7 +155,7 @@ public class ArticleController extends BaseController {
|
|
|
model.addAttribute("labelId", 0);
|
|
|
model.addAttribute("pageNum", pageNum);
|
|
|
model.addAttribute("isSearch", false);
|
|
|
- //model.addAttribute("pagePath", "/info/search.html");
|
|
|
+ // model.addAttribute("pagePath", "/info/search.html");
|
|
|
return ARTICLE_LIST_PATH;
|
|
|
}
|
|
|
|
|
@@ -125,7 +163,8 @@ public class ArticleController extends BaseController {
|
|
|
* 文章详情【旧】
|
|
|
*/
|
|
|
@GetMapping("/info/detail-{id}-1.html")
|
|
|
- public String toArticleDetail(@PathVariable("id") Integer id, final Model model, ServerWebExchange serverWebExchange, ServerHttpResponse response) {
|
|
|
+ public String toArticleDetail(@PathVariable("id") Integer id, final Model model,
|
|
|
+ ServerWebExchange serverWebExchange, ServerHttpResponse response) {
|
|
|
List<BaseLink> typeList = articleService.getArticleTypes();
|
|
|
Article article = articleService.getArticleInfo(id);
|
|
|
if (article == null) {
|
|
@@ -160,16 +199,20 @@ public class ArticleController extends BaseController {
|
|
|
log.info("文章详情访问来源记录完成========》" + source);
|
|
|
List<BaseLink> data = articleService.getArticleLabels().getData();
|
|
|
List<ImageLink> Ads = articleService.getLastestInfoAds().getData();
|
|
|
-// List<Article> articles = articleService.getInfoById(id);
|
|
|
+ List<Article> articles = new ArrayList<>();
|
|
|
+ if (null != article && article.getAutoStatus() == 0) {
|
|
|
+ articles = articleService.getInfoById(id);
|
|
|
+ } else {
|
|
|
+ articles = articleService.getArticleRelatedId(id.toString());
|
|
|
+ }
|
|
|
String relatedLabels = articleService.relatedLabel(id);
|
|
|
- List<ImageLink> infoSelected = articleService.getArticleSelected();
|
|
|
- List<ImageLink> infoRelated = articleService.getArticleRelatedId(id.toString());
|
|
|
- List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime();
|
|
|
+ List<ImageLink> infoSelected = articleService.getArticleSelected(0, 5);
|
|
|
+ List<CmProductArchiveFile> archiveFiles = articleService.findArchiveFileAddTime(0, 3);
|
|
|
List<ProductList> productSellNumbers = productService.getProductSellNumbers();
|
|
|
- model.addAttribute("infoSelected", infoSelected);//精选文章
|
|
|
- model.addAttribute("productSellNumbers", productSellNumbers);//销量前三商品
|
|
|
- model.addAttribute("archiveFiles", archiveFiles);//最新美业资料top3
|
|
|
- model.addAttribute("articles", infoRelated);//相关文章
|
|
|
+ model.addAttribute("infoSelected", infoSelected);// 精选文章
|
|
|
+ model.addAttribute("productSellNumbers", productSellNumbers);// 销量前三商品
|
|
|
+ model.addAttribute("archiveFiles", archiveFiles);// 最新美业资料top3
|
|
|
+ model.addAttribute("articles", articles);// 相关文章
|
|
|
model.addAttribute("ads", Ads);
|
|
|
model.addAttribute("labels", data);
|
|
|
model.addAttribute("article", article);
|
|
@@ -199,8 +242,6 @@ public class ArticleController extends BaseController {
|
|
|
return ERROR_PATH;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 获取文章热门标签
|
|
|
*/
|
|
@@ -216,8 +257,8 @@ public class ArticleController extends BaseController {
|
|
|
@GetMapping("/article/recommend")
|
|
|
@ResponseBody
|
|
|
public JsonModel<PageInfo<ImageLink>> getArticleRecommended(Integer typeId,
|
|
|
- @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
|
|
|
return articleService.getArticleRecommended(typeId, pageNum, pageSize);
|
|
|
}
|
|
|
|
|
@@ -227,8 +268,8 @@ public class ArticleController extends BaseController {
|
|
|
@GetMapping("/article/related")
|
|
|
@ResponseBody
|
|
|
public JsonModel<PageInfo<Article>> getArticleRelated(Integer id, String labels,
|
|
|
- @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
- @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
|
|
|
return articleService.getArticleRelated(id, labels, pageNum, pageSize);
|
|
|
}
|
|
|
|