chao %!s(int64=4) %!d(string=hai) anos
pai
achega
77de93c7c9

+ 17 - 0
src/main/java/com/caimei/www/controller/unlimited/ArticleController.java

@@ -3,10 +3,13 @@ package com.caimei.www.controller.unlimited;
 import com.caimei.www.controller.BaseController;
 import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.BaseLink;
+import com.caimei.www.pojo.page.ImageLink;
 import com.caimei.www.service.ArticleService;
+import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import java.util.List;
@@ -53,4 +56,18 @@ public class ArticleController extends BaseController {
     public JsonModel<List<BaseLink>> getArticleLabels() {
         return articleService.getArticleLabels();
     }
+
+    /**
+     * 获取文章推荐
+     */
+    @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) {
+        return articleService.getArticleRecommended(typeId, pageNum, pageSize);
+    }
+
+
+
 }

+ 9 - 0
src/main/java/com/caimei/www/mapper/ArticleDao.java

@@ -1,7 +1,9 @@
 package com.caimei.www.mapper;
 
 import com.caimei.www.pojo.page.BaseLink;
+import com.caimei.www.pojo.page.ImageLink;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -24,4 +26,11 @@ public interface ArticleDao {
      * @return
      */
     List<BaseLink> getArticleLabels();
+
+    /**
+     * 获取文章推荐
+     * @param typeId
+     * @return
+     */
+    List<ImageLink> getArticleRecommended(@Param("typeId") Integer typeId);
 }

+ 7 - 0
src/main/java/com/caimei/www/service/ArticleService.java

@@ -2,6 +2,8 @@ package com.caimei.www.service;
 
 import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.BaseLink;
+import com.caimei.www.pojo.page.ImageLink;
+import com.github.pagehelper.PageInfo;
 
 import java.util.List;
 
@@ -16,4 +18,9 @@ public interface ArticleService {
      * 获取文章热门标签
      */
     JsonModel<List<BaseLink>> getArticleLabels();
+
+    /**
+     * 获取文章推荐
+     */
+    JsonModel<PageInfo<ImageLink>> getArticleRecommended(Integer typeId, int pageNum, int pageSize);
 }

+ 19 - 2
src/main/java/com/caimei/www/service/impl/ArticleServiceImpl.java

@@ -1,12 +1,13 @@
 package com.caimei.www.service.impl;
 
-import com.caimei.www.mapper.AccountDao;
 import com.caimei.www.mapper.ArticleDao;
 import com.caimei.www.pojo.JsonModel;
 import com.caimei.www.pojo.page.BaseLink;
+import com.caimei.www.pojo.page.ImageLink;
 import com.caimei.www.service.ArticleService;
 import com.caimei.www.utils.PriceUtil;
-import io.netty.util.internal.MathUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -40,4 +41,20 @@ public class ArticleServiceImpl implements ArticleService {
         });
         return JsonModel.success(labels);
     }
+
+    /**
+     * 获取文章推荐
+     *
+     * @param typeId
+     * @param pageNum
+     */
+    @Override
+    public JsonModel<PageInfo<ImageLink>> getArticleRecommended(Integer typeId, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<ImageLink> recommended = articleDao.getArticleRecommended(typeId);
+        PageInfo<ImageLink> pageInfo = new PageInfo(recommended);
+        return JsonModel.success(pageInfo);
+    }
+
+
 }

+ 13 - 0
src/main/resources/mapper/ArticleMapper.xml

@@ -15,6 +15,19 @@
 		order by recommendLabelStatus desc, hotLabelStatus desc, createDate desc
 		limit 30
     </select>
+    <select id="getArticleRecommended" resultType="com.caimei.www.pojo.page.ImageLink">
+		select  a.id,
+				a.title,
+				a.guidanceImage as image
+		from info a
+		where a.recommendStatus = 1
+		and a.enabledStatus = 1
+		and NOW() >= a.pubdate
+		<if test="typeId != null and typeId != ''">
+			and a.typeId = #{typeId}
+		</if>
+		order by a.pubdate desc
+	</select>
 
 
 </mapper>

+ 0 - 0
src/main/resources/static/css/article/list.css → src/main/resources/static/css/article/article.css


+ 0 - 17
src/main/resources/static/css/article/detail.css

@@ -1,17 +0,0 @@
-@charset "utf-8";
-li{list-style:none}
-/**
- * PC端
- */
-@media screen and (min-width:768px){
-
-}
-
-/**
-* 移动端
-*/
-@media screen and (max-width:768px){
-
-
-}
-

+ 1 - 1
src/main/resources/templates/article/detail.html

@@ -4,7 +4,7 @@
 <head>
     <title>采美365网-中国美业全方位线上交易服务互动平台,做美业,上采美</title>
     <template th:replace="components/head-link"></template>
-    <link th:href="@{/css/article/detail.css(v=${version})}" rel="stylesheet" type="text/css">
+    <link th:href="@{/css/article/article.css(v=${version})}" rel="stylesheet" type="text/css">
 </head>
 <body>
 <!-- 引用头部 -->

+ 1 - 1
src/main/resources/templates/article/list.html

@@ -4,7 +4,7 @@
 <head>
     <title>采美365网-文章列表</title>
     <template th:replace="components/head-link"></template>
-    <link th:href="@{/css/article/list.css(v=${version})}" rel="stylesheet" type="text/css">
+    <link th:href="@{/css/article/article.css(v=${version})}" rel="stylesheet" type="text/css">
 </head>
 <body>
 <div id="articleList">