Browse Source

官网新增关键词等开发

anderx 2 years ago
parent
commit
1c284a3d5e

+ 30 - 5
src/main/java/com/kede/admin/controller/AdminSystemController.java

@@ -2,6 +2,8 @@ package com.kede.admin.controller;
 
 
 import javax.annotation.Resource;
+
+import com.kede.common.model.SysConfig;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -31,8 +33,8 @@ public class AdminSystemController extends BaseApiController {
 	@Resource(name = "passwordUtil")
 	private PasswordUtil					passwordUtil;
 
-	
-	
+
+
 	/**
 	 * 管理员修改本人信息
 	 */
@@ -64,18 +66,41 @@ public class AdminSystemController extends BaseApiController {
 		res.setData(adminService.updateByPrimaryKey(ad));
 		return res;
 	}
-	
+
 	@RequestMapping(value = "/userList",method = RequestMethod.GET)
 	public Result userList(String name,Integer pageNo,Integer PageSize) {
 		Result res =new Result();
 		return res.data(userService.list(name,pageNo,PageSize));
 	}
-	
+
 	@RequestMapping(value = "/orderList",method = RequestMethod.GET)
 	public Result orderList(String name,Integer payStatus,String startTime,String endTime,Integer pageNo,Integer PageSize) {
 		Result res =new Result();
 		return res.data(OrderService.list( name, 1,payStatus, startTime, endTime, pageNo, PageSize));
 	}
 
-	
+	@RequestMapping(value = "/addSysConfig",method = RequestMethod.POST)
+	public Result addSysConfig(SysConfig in){
+		Result res=new Result();
+		if(in.getContent()==null){
+			res.getError().add(buildError("内容不能为空"));
+		}
+		return res.data(adminService.addSysConfig(in));
+	}
+	@RequestMapping(value = "/getSysConfig",method = RequestMethod.POST)
+		public Result getSysConfig(Integer id){
+			Result res=new Result();
+			return res.data(adminService.getSysConfig(id));
+		}
+	@RequestMapping(value = "/updateSysConfig",method = RequestMethod.POST)
+		public Result updateSysConfig(SysConfig in){
+			Result res=new Result();
+			if(in.getContent()==null){
+				res.getError().add(buildError("内容不能为空"));
+			}
+			return res.data(adminService.updateSysConfig(in));
+		}
+
+
+
 }

+ 6 - 1
src/main/java/com/kede/admin/service/AdminService.java

@@ -1,6 +1,7 @@
 package com.kede.admin.service;
 
 import com.kede.common.model.Admin;
+import com.kede.common.model.SysConfig;
 
 public interface AdminService {
 
@@ -10,6 +11,10 @@ public interface AdminService {
 
 	int updateByPrimaryKey(Admin ad);
 
-	
+	int addSysConfig(SysConfig in);
+
+	int updateSysConfig(SysConfig in);
+
+	SysConfig getSysConfig(Integer id);
 
 }

+ 21 - 2
src/main/java/com/kede/admin/service/impl/AdminServiceImpl.java

@@ -1,5 +1,7 @@
 package com.kede.admin.service.impl;
 
+import com.kede.common.dao.SysConfigMapper;
+import com.kede.common.model.SysConfig;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -11,7 +13,9 @@ public class AdminServiceImpl implements AdminService {
 
 	@Autowired
 	private AdminMapper adminMapper;
-	
+	@Autowired
+	private SysConfigMapper sysConfigMapper;
+
 	@Override
 	public Admin selectByUserName(String username) {
 		return adminMapper.selectByUserName(username);
@@ -24,6 +28,21 @@ public class AdminServiceImpl implements AdminService {
 	public int updateByPrimaryKey(Admin ad) {
 		return adminMapper.updateByPrimaryKeySelective(ad);
 	}
-	
+
+	@Override
+	public int addSysConfig(SysConfig in) {
+		return sysConfigMapper.insertSelective(in);
+	}
+
+	@Override
+	public int updateSysConfig(SysConfig in) {
+		return sysConfigMapper.updateByPrimaryKeySelective(in);
+	}
+
+	@Override
+	public SysConfig getSysConfig(Integer id) {
+		return sysConfigMapper.selectByPrimaryKey(id);
+	}
+
 
 }

+ 5 - 1
src/main/java/com/kede/common/controller/WebpageController.java

@@ -3,6 +3,7 @@ package com.kede.common.controller;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -143,8 +144,11 @@ public class WebpageController extends BaseController {
 		if (title.length()>18)title=title.substring(0,18);
 		String content = outNews.getContent();
 		if (content.length()>180)content=content.substring(0,180);
-		String keywords=outNews.getKeywords();
+		if (outNews.getKeywords()!=null){
+		String[] split = outNews.getKeywords().split(",");
+		List<String>  keywords= Arrays.asList(split);
 		modelview.addObject("keywords",keywords);
+		}
 		modelview.addObject("tt",title);
 		modelview.addObject("content",removeHtmlTag(content));
 		modelview.addObject("news",outNews);

+ 0 - 1
src/main/java/com/kede/common/dao/NewsMapper.java

@@ -21,5 +21,4 @@ public interface NewsMapper {
 
     OutNews selectByid(Integer id);
 
-    List<OutNews> selectByType(Integer type);
 }

+ 17 - 0
src/main/java/com/kede/common/dao/SysConfigMapper.java

@@ -0,0 +1,17 @@
+package com.kede.common.dao;
+
+import com.kede.common.model.SysConfig;
+
+public interface SysConfigMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(SysConfig record);
+
+    int insertSelective(SysConfig record);
+
+    SysConfig selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(SysConfig record);
+
+    int updateByPrimaryKey(SysConfig record);
+}

+ 8 - 7
src/main/java/com/kede/common/mapper/NewsMapper.xml

@@ -204,7 +204,10 @@
     and status = #{n.status}
     </if>
     <if test="n.type!=null">
-    and type = #{n.type}
+      and type = #{n.type}
+    </if>
+    <if test="n.keywords!=null">
+      and find_in_set(#{n.keywords},keywords)
     </if>
     order by
     <if test="n.hot ==1">
@@ -234,12 +237,10 @@
     <if test="n.type!=null">
     and type = #{n.type}
     </if>
+    <if test="n.keywords!=null">
+      and find_in_set(#{n.keywords},keywords)
+    </if>
   </select>
-    <select id="selectByType" resultType="com.kede.news.bo.OutNews">
-      select  id, title, publisher, type, picture_url pictureUrl, status, sort, release_status releaseStatus,content,
-        date_format(create_time,'%Y-%m-%d %H:%i:%S') as createTimeConvert,create_time createTime,keywords,hot,
-        date_format(release_time,'%Y-%m-%d %H:%i:%S') as releaseTimeConvert ,release_time releaseTime
-      from news where type =#{type}
-    </select>
+
 
 </mapper>

+ 76 - 0
src/main/java/com/kede/common/mapper/SysConfigMapper.xml

@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.kede.common.dao.SysConfigMapper">
+  <resultMap id="BaseResultMap" type="com.kede.common.model.SysConfig">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="content" jdbcType="VARCHAR" property="content" />
+    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, content, remarks, create_time
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from sys_config
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from sys_config
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.kede.common.model.SysConfig" useGeneratedKeys="true">
+    insert into sys_config (content, remarks, create_time
+      )
+    values (#{content,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
+      )
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.kede.common.model.SysConfig" useGeneratedKeys="true">
+    insert into sys_config
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="content != null">
+        content,
+      </if>
+      <if test="remarks != null">
+        remarks,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="content != null">
+        #{content,jdbcType=VARCHAR},
+      </if>
+      <if test="remarks != null">
+        #{remarks,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.kede.common.model.SysConfig">
+    update sys_config
+    <set>
+      <if test="content != null">
+        content = #{content,jdbcType=VARCHAR},
+      </if>
+      <if test="remarks != null">
+        remarks = #{remarks,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.kede.common.model.SysConfig">
+    update sys_config
+    set content = #{content,jdbcType=VARCHAR},
+      remarks = #{remarks,jdbcType=VARCHAR},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 61 - 0
src/main/java/com/kede/common/model/SysConfig.java

@@ -0,0 +1,61 @@
+package com.kede.common.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * sys_config
+ * @author 
+ */
+public class SysConfig implements Serializable {
+    private Integer id;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getRemarks() {
+        return remarks;
+    }
+
+    public void setRemarks(String remarks) {
+        this.remarks = remarks;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+}

+ 4 - 2
src/main/java/com/kede/news/service/impl/NewsServiceImpl.java

@@ -97,7 +97,6 @@ public class NewsServiceImpl extends BaseMybatisDao<NewsMapper> implements NewsS
 		newNews.setId(use.getId());
 		newNews.setHot(use.getHot());
 		pushAfter(use);
-
 		newsMapper.updateByPrimaryKeySelective(newNews);
 		return use;
 	}
@@ -107,7 +106,10 @@ public class NewsServiceImpl extends BaseMybatisDao<NewsMapper> implements NewsS
 	 * @param use
 	 */
 	private void pushAfter(OutNews use) {
-		List<OutNews>list= newsMapper.selectByType(use.getType());
+		InputNews in =new InputNews();
+		in.setReleaseStatus(1);
+		in.setType(use.getType());
+		List<OutNews>list= (List<OutNews>) listnewsDetails(in,9999,1).getList();
 		int max = list.size()-1;
 		list.forEach(i ->{
 			if (i.getId().equals(use.getId())){

+ 20 - 6
src/main/webapp/WEB-INF/views/portal/newsDetails.html

@@ -62,11 +62,25 @@
 
             </div>
             <div class="copyright">
-              【本站声明】
-              <p>1、本网站发布的该篇文章,主要解读科技咨询知识及传递、交流政策奖补信息,以便您学习或了解政策知识,请不要用于其它用途;</p>
-              <p>2、该篇文章中所涉及的商标、标识的商品/服务并非来源于本网站,更非本网站提供,与本网站无关,系他人的商品或服务,本网站对于该类商标、标识不拥有任何权利;</p>
-              <p>3、本网站不对该篇文章中所涉及的商标、标识的商品/服务作任何明示或暗示的保证或担保;</p>
-              <p>4、本网站不对文章中所涉及的内容真实性、准确性、可靠性负责,仅系客观性描述,如您需要了解该项目详细的资讯,请您直接与在线客服联系。</p>
+              <p>
+                <span style="font-size: 18px;">热门关键词:</span>
+                <a class="kw" th:each="key:${keywords}" th:text="${key}+'&nbsp;&nbsp;'"></a>
+              </p>
+              <p>上一篇: <a th:if="${news.beforeId} != null" th:href="'/news/'+${news.beforeId}"
+                         th:text="${news.beforeTitle}"></a>
+                <a th:if="${news.beforeId}  == null" th:text="已经是第一篇"></a>
+              </p>
+              <p>下一篇: <a th:if="${news.afterId} != null" th:href="'/news/'+${news.afterId}"
+                         th:text="${news.afterTitle}"></a>
+                <a th:if="${news.afterId}  == null" th:text="已经是最后一篇"></a>
+              </p>
+              <div class="bzsm">
+                【本站声明】
+                <p>1、本网站发布的该篇文章,主要解读科技咨询知识及传递、交流政策奖补信息,以便您学习或了解政策知识,请不要用于其它用途;</p>
+                <p>2、该篇文章中所涉及的商标、标识的商品/服务并非来源于本网站,更非本网站提供,与本网站无关,系他人的商品或服务,本网站对于该类商标、标识不拥有任何权利;</p>
+                <p>3、本网站不对该篇文章中所涉及的商标、标识的商品/服务作任何明示或暗示的保证或担保;</p>
+                <p>4、本网站不对文章中所涉及的内容真实性、准确性、可靠性负责,仅系客观性描述,如您需要了解该项目详细的资讯,请您直接与在线客服联系。</p>
+              </div>
             </div>
           </div>
           <!-- 最新资讯 -->
@@ -129,4 +143,4 @@
   </div>
 </body>
 
-</html>
+</html>