plf %!s(int64=4) %!d(string=hai) anos
pai
achega
1532fdd487

+ 0 - 10
src/main/java/com/caimei/www/WwwApplication.java

@@ -2,13 +2,6 @@ package com.caimei.www;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Bean;
-import org.springframework.core.Ordered;
-import org.thymeleaf.spring5.view.ThymeleafViewResolver;
-
-import javax.annotation.Resource;
 
 /**
  * @author Charles
@@ -20,7 +13,4 @@ public class WwwApplication {
         SpringApplication.run(WwwApplication.class, args);
     }
 
-
-
-
 }

+ 3 - 2
src/main/java/com/caimei/www/config/CustomExceptionHandler.java

@@ -14,13 +14,14 @@ import reactor.core.publisher.Mono;
 public class CustomExceptionHandler {
 
     @ExceptionHandler(Exception.class)
-    public String convertExceptionMsg(Exception e){
+    public String convertExceptionMsg(Exception e) {
         //自定义逻辑,可返回其他值
+        e.printStackTrace();
         return "404";
     }
 
     @ExceptionHandler(IllegalAccessException.class)
-    public Mono<String> convertIllegalAccessError(Exception e){
+    public Mono<String> convertIllegalAccessError(Exception e) {
         //自定义逻辑,可返回其他值
         return Mono.just("illegal access");
     }

+ 57 - 51
src/main/java/com/caimei/www/controller/unlimited/ArticleController.java

@@ -26,57 +26,63 @@ import java.util.List;
 @Controller
 public class ArticleController extends BaseController {
 
-	private static final String ARTICLE_LIST_PATH = "article/list";
-	private static final String ARTICLE_DETAIL_PATH = "article/detail";
+    private static final String ARTICLE_LIST_PATH = "article/list";
+    private static final String ARTICLE_DETAIL_PATH = "article/detail";
     private ArticleService articleService;
+
     @Autowired
     public void setArticleService(ArticleService articleService) {
         this.articleService = articleService;
     }
 
-	/**
-	 * 文章列表【旧center】
-	 */
-	@GetMapping("/info/center-{id}-1.html")
-	public String toArticleList(@PathVariable("id") Integer id, final Model model) {
-		List<BaseLink> typeList = articleService.getArticleTypes();
-		model.addAttribute("articleType", typeList);
-		model.addAttribute("typeId", id);
-		model.addAttribute("labelId", 0);
-		return ARTICLE_LIST_PATH;
-	}
-	/**
-	 * 文章列表【旧label】
-	 */
-	@GetMapping("/info/label-{id}-1.html")
-	public String toArticleLabel(@PathVariable("id") Integer id, final Model model) {
-		List<BaseLink> typeList = articleService.getArticleTypes();
-		model.addAttribute("articleType", typeList);
-		model.addAttribute("typeId", 0);
-		model.addAttribute("labelId", id);
-		return ARTICLE_LIST_PATH;
-	}
-	/**
-	 * 文章搜索结果
-	 */
-	@GetMapping("/info/search.html")
-	public String toArticleSearch(final Model model) {
-		List<BaseLink> typeList = articleService.getArticleTypes();
-		model.addAttribute("articleType", typeList);
-		model.addAttribute("typeId", 0);
-		model.addAttribute("labelId", 0);
-		return ARTICLE_LIST_PATH;
-	}
-	/**
-	 * 文章详情【旧】
-	 */
-	@GetMapping("/info/detail-{id}-1.html")
-	public String toArticleDetail(@PathVariable("id") Integer id, final Model model) {
-		List<BaseLink> typeList = articleService.getArticleTypes();
-		model.addAttribute("articleType", typeList);
-		model.addAttribute("articleId", id);
-		return ARTICLE_DETAIL_PATH;
-	}
+    /**
+     * 文章列表【旧center】
+     */
+    @GetMapping("/info/center-{id}-1.html")
+    public String toArticleList(@PathVariable("id") Integer id, final Model model) {
+        List<BaseLink> typeList = articleService.getArticleTypes();
+        model.addAttribute("articleType", typeList);
+        model.addAttribute("typeId", id);
+        model.addAttribute("labelId", 0);
+        return ARTICLE_LIST_PATH;
+    }
+
+    /**
+     * 文章列表【旧label】
+     */
+    @GetMapping("/info/label-{id}-1.html")
+    public String toArticleLabel(@PathVariable("id") Integer id, final Model model) {
+        List<BaseLink> typeList = articleService.getArticleTypes();
+        model.addAttribute("articleType", typeList);
+        model.addAttribute("typeId", 0);
+        model.addAttribute("labelId", id);
+        return ARTICLE_LIST_PATH;
+    }
+
+    /**
+     * 文章搜索结果
+     */
+    @GetMapping("/info/search.html")
+    public String toArticleSearch(final Model model) {
+        List<BaseLink> typeList = articleService.getArticleTypes();
+        model.addAttribute("articleType", typeList);
+        model.addAttribute("typeId", 0);
+        model.addAttribute("labelId", 0);
+        return ARTICLE_LIST_PATH;
+    }
+
+    /**
+     * 文章详情【旧】
+     */
+    @GetMapping("/info/detail-{id}-1.html")
+    public String toArticleDetail(@PathVariable("id") Integer id, final Model model) {
+        List<BaseLink> typeList = articleService.getArticleTypes();
+        Article article = articleService.getArticleInfo(id);
+        model.addAttribute("article", article);
+        model.addAttribute("articleType", typeList);
+        model.addAttribute("articleId", id);
+        return ARTICLE_DETAIL_PATH;
+    }
 
     /**
      * 获取文章热门标签
@@ -104,8 +110,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);
     }
 
@@ -123,8 +129,8 @@ public class ArticleController extends BaseController {
      */
     @GetMapping("/article/label/click")
     @ResponseBody
-    public JsonModel clickArticleLabel(Integer id){
-    	return articleService.clickArticleLabel(id);
+    public JsonModel clickArticleLabel(Integer id) {
+        return articleService.clickArticleLabel(id);
     }
 
     /**
@@ -132,8 +138,8 @@ public class ArticleController extends BaseController {
      */
     @GetMapping("/article/ad/click")
     @ResponseBody
-    public JsonModel clickArticleAd(Integer id){
-    	return articleService.clickArticleAd(id);
+    public JsonModel clickArticleAd(Integer id) {
+        return articleService.clickArticleAd(id);
     }
 
 }

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

@@ -19,24 +19,28 @@ import java.util.List;
 public interface ArticleDao {
     /**
      * 获取文章类型
+     *
      * @return
      */
     List<BaseLink> getArticleTypes();
 
     /**
      * 获取最高点击量
+     *
      * @return
      */
     Integer getTopClickRate();
 
     /**
      * 获取热门标签
+     *
      * @return
      */
     List<BaseLink> getArticleLabels();
 
     /**
      * 获取文章推荐
+     *
      * @param typeId
      * @return
      */
@@ -44,6 +48,7 @@ public interface ArticleDao {
 
     /**
      * 获取文章广告
+     *
      * @return
      */
     List<ImageLink> getLastestInfoADs();
@@ -60,8 +65,17 @@ public interface ArticleDao {
 
     /**
      * 获取相关文章
+     *
      * @param id
      * @param labelArr
      */
     List<Article> getArticleRelated(@Param("id") Integer id, @Param("labels") String[] labelArr);
+
+    /**
+     * 获取文章信息
+     *
+     * @param id
+     * @return
+     */
+    Article getArticleInfo(Integer id);
 }

+ 55 - 13
src/main/java/com/caimei/www/pojo/page/Article.java

@@ -12,32 +12,74 @@ import java.io.Serializable;
  */
 @Data
 public class Article implements Serializable {
-    /** 文章ID */
+    /**
+     * 文章ID
+     */
     private Integer id;
-    /** 文章标题 */
+    /**
+     * 文章标题
+     */
     private String title;
-    /** 文章主图 */
+    /**
+     * 文章主图
+     */
     private String image;
-    /** 文章作者 */
+    /**
+     * 文章作者
+     */
     private String publisher;
-    /** 发布日期 */
+    /**
+     * 发布日期
+     */
     private String publishDate;
-    /** 文章摘要 */
+    /**
+     * 文章摘要
+     */
     private String intro;
-    /** 文章内容 */
+    /**
+     * 文章内容
+     */
     private String content;
-    /** 浏览量 */
+    /**
+     * 浏览量
+     */
     private Integer pv;
-    /** 信息分类Id */
+    /**
+     * 信息分类Id
+     */
     private Integer typeId;
-    /** 信息分类文本 */
+    /**
+     * 信息分类文本
+     */
     private String type;
-    /** 标签 */
+    /**
+     * 标签
+     */
     private String label;
-    /** 标签 id数组 */
+    /**
+     * 标签 id数组
+     */
     private Integer[] labelIds;
-    /** 标签 文本数组 */
+    /**
+     * 标签 文本数组
+     */
     private String[] labels;
+    /**
+     * 关键字
+     */
+    private String keyword;
+    /**
+     * 推荐语
+     */
+    private String recommendContent;
+    /**
+     * 来源
+     */
+    private String source;
+    /**
+     * 点赞数量
+     */
+    private Integer likes;
 
     private static final long serialVersionUID = 1L;
 

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

@@ -50,4 +50,11 @@ public interface ArticleService {
      */
     JsonModel clickArticleAd(Integer id);
 
+    /**
+     * 获取文章信息
+     *
+     * @param id 文章id
+     * @return
+     */
+    Article getArticleInfo(Integer id);
 }

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

@@ -20,8 +20,8 @@ import java.util.List;
 /**
  * Description
  *
- * @date : 2020/8/10
  * @author : Charles
+ * @date : 2020/8/10
  */
 @Service
 public class ArticleServiceImpl implements ArticleService {
@@ -49,7 +49,7 @@ public class ArticleServiceImpl implements ArticleService {
         List<BaseLink> labels = articleDao.getArticleLabels();
         double opacityParam = 0.5f;
         labels.forEach(label -> {
-            double opacity = PriceUtil.mul(PriceUtil.div(label.getSort(), topClickRate), (1-opacityParam)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + opacityParam;
+            double opacity = PriceUtil.mul(PriceUtil.div(label.getSort(), topClickRate), (1 - opacityParam)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() + opacityParam;
             label.setSort(opacity);
         });
         return JsonModel.success(labels);
@@ -119,5 +119,15 @@ public class ArticleServiceImpl implements ArticleService {
         return JsonModel.success();
     }
 
+    @Override
+    public Article getArticleInfo(Integer id) {
+        Article articleInfo = articleDao.getArticleInfo(id);
+        if (articleInfo != null) {
+            String[] labels = articleInfo.getLabel().split(",");
+            articleInfo.setLabels(labels);
+        }
+        return articleInfo;
+    }
+
 
 }

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

@@ -85,5 +85,34 @@
 		where id = #{id}
 	</update>
 
+	<select id="getArticleInfo" resultType="com.caimei.www.pojo.page.Article">
+		SELECT
+		  a.id AS id,
+		  a.title AS title,
+		  a.guidanceImage AS image,
+		  a.publisher AS publisher,
+		  a.pubdate AS publish_date,
+		  a.recommendContent AS intro,
+		  a.infoContent AS content,
+		  (
+			IFNULL(c.pv, 0) + IFNULL(a.basePv, 0) + IFNULL(
+			  (c.num + a.basePraise),
+			  0
+			)
+		  ) AS pv,
+		  a.label AS label,
+		  a.typeId AS typeId,
+		  a.keyword AS keyword,
+		  a.recommendContent AS recommendContent,
+		  a.source AS source,
+		  IFNULL((c.num + a.basePraise), 0) AS likes
+		FROM
+		  info AS a
+		  LEFT JOIN info_praise c ON a.id = c.infoId
+		WHERE
+		  a.id = #{id}
+		  AND a.enabledStatus = 1
+	</select>
+
 
 </mapper>

+ 22 - 42
src/main/resources/templates/article/detail.html

@@ -4,15 +4,15 @@
 <head>
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, account-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
-    <title>采美365网-中国美业全方位线上交易服务互动平台,做美业,上采美</title>
+    <title th:text="${article.title}+'_采美365网'"></title>
     <meta name="apple-mobile-web-app-capable" content="yes">
     <meta name="apple-mobile-web-app-status-bar-style" content="black">
     <meta http-equiv="pragma" content="no-cache">
     <meta http-equiv="cache-control" content="no-cache">
     <meta http-equiv="expires" content="0">
     <meta http-equiv="X-UA-Compatible" content="IE=Edge">
-    <meta http-equiv="keywords" content="采美365网-中国美业全方位线上交易服务互动平台,做美业,上采美">
-    <meta http-equiv="description" content="采美365网——中国美业互联网共享经济平台,中国美业较大的光电美容干货信息平台,提供美容专业线客装产品、美容院消耗品、专业线院装产品、光电美容仪器、光电美容项目交易,同时提供采美公益大讲堂、光电美容干货、光电美容资讯、美业动态等行业信息。采集梦想,美启未来。">
+    <meta http-equiv="keywords" th:content="${article.keyword}">
+    <meta http-equiv="description" th:content="${article.recommendContent}" >
     <meta http-equiv="Cache-Control" content="no-transform " />
     <link rel="shortcut icon" th:href="@{/favicon.png}" type="image/x-icon"/>
     <link rel="bookmark" th:href="@{/favicon.png}" type="image/x-icon"/>
@@ -22,6 +22,7 @@
     <link th:href="@{/css/article/article.css(v=${version})}" rel="stylesheet" type="text/css">
 </head>
 <body class="home detailData">
+<input type="hidden" th:value="${article.id}" id="articleId">
 <div class="cm-modal"></div>
 <!--导航栏-->
 <template th:replace="article/components/header"></template>
@@ -30,41 +31,22 @@
     <a href="/" target="_blank">首页</a>&gt; <a v-text="typeTxt" href="javascript:void(0);" class="title newTitle"></a>
 </div>
 <!--主体内容-->
-<div class="content clearfix">
-    <div class="new-list article">
-        <div class="title">
-            新品|FEAMIG馥秘,全国唯一一家专业线EGFC专利成分独家授权的私密品牌。
-        </div>
+<div class="content clearfix" th:object="${article}">
+    <div class="new-list article" th:if="*{not #strings.isEmpty(content)}">
+        <div class="title" th:text="*{title}"></div>
         <p class="xinxi">
-            <em class="write">
-                小猫
-            </em>
-            <em class="date">
-                来源:采美365网
-            </em>
-            <em class="time">
-                2020-08-10 10:03
-            </em>
+            <em class="write" th:text="*{publisher}"></em>
+            <em class="date" th:if="*{not #strings.isEmpty(source)}" th:text="*{source}"></em>
+            <em class="time" th:data="*{publishDate}"></em>
             <span class="P_img">
-                <em class="emliu">
-                    29
-                </em>
+                <em class="emliu" th:text="*{pv}"></em>
             </span>
         </p>
-        <div class="new-mian" id="contentDiv">
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-            文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情文章详情
-        </div>
+        <div class="new-mian" id="contentDiv" th:utext="*{content}"></div>
         <!--已点赞给类名dianzan加color:#e15616;-->
         <div class="dianzan">
-            <span class="like " data-id="6540" data-count="0">
-                赞0
+            <span class="like " data-count="0" data-th-id="*{id}" th:text="'赞'+*{likes}">
+
             </span>
             <div class="tipbox">
                 <em>
@@ -75,16 +57,8 @@
                 </a>
             </div>
         </div>
-        <p class="dea-tag">
-            <span>
-                专利成分私密品牌
-            </span>
-            <span>
-                FEAMIG馥秘
-            </span>
-            <span>
-                深圳德灏美学管理有限公司
-            </span>
+        <p class="dea-tag" th:each="label:*{labels}">
+            <span th:if="${not #strings.isEmpty(label)}" th:text="${label}"></span>
         </p>
 
 
@@ -119,6 +93,12 @@
         </div>
 
     </div>
+    <div class="new-list article all_mid" style="min-height: 800px" th:if="*{#strings.isEmpty(content)}">
+        <div class="middle">
+            <img src="/public/3.0/img/myaccount/nn.png"/>
+            <p>抱歉,内容已删除</p>
+        </div>
+    </div>
     <!--侧边栏-->
     <template th:replace="article/components/sidebar"></template>
 </div>