zhuyiyi 3 місяців тому
батько
коміт
764f3117f2

+ 4 - 7
src/main/java/lingtao/net/bean/StandardMemo.java

@@ -1,9 +1,9 @@
 package lingtao.net.bean;
 
-import java.util.Date;
-
 import lombok.Data;
 
+import java.util.Date;
+
 /**
  * 产品知识点;
  * 
@@ -11,15 +11,12 @@ import lombok.Data;
  *
  */
 @Data
-public class Information {
-
+public class StandardMemo {
 
 	private Integer id;
 
 	private String content;
 
-	private String type;
-
 	private String createBy;
 
 	private Date createDate;
@@ -30,5 +27,5 @@ public class Information {
 	/**
 	 * 附件
 	 */
-	private String attachment;
+	private String title;
 }

+ 49 - 50
src/main/java/lingtao/net/controller/StandardMemoController.java

@@ -1,65 +1,64 @@
 package lingtao.net.controller;
 
-import java.util.List;
-
-import javax.servlet.http.HttpSession;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-
 import lingtao.net.bean.Information;
 import lingtao.net.bean.Msg;
+import lingtao.net.bean.StandardMemo;
 import lingtao.net.service.InformationService;
+import lingtao.net.service.StandardMemoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpSession;
+import java.util.List;
 
 @RestController
-public class InformationController {
+public class StandardMemoController {
 
-	@Autowired
-	private InformationService informationService;
+    @Autowired
+    private StandardMemoService standardMemoService;
 
-	/**
-	 * 产品知识列表
-	 * 
-	 * @return
-	 */
-	@RequestMapping("/getInformations")
-	public Msg getInformations(@RequestParam(value = "page", defaultValue = "1") Integer page,
-			@RequestParam(value = "limit", defaultValue = "10") Integer limit, Information information) {
-		PageHelper.startPage(page, limit);
-		List<Information> informationList = informationService.getInformations(information);
-		PageInfo<Information> pageInfo = new PageInfo<Information>(informationList);
-		return Msg.success().add("list", pageInfo);
-	}
+    /**
+     * 产品知识列表
+     *
+     * @return
+     */
+    @RequestMapping("/getStandard")
+    public Msg getStandard(@RequestParam(value = "page", defaultValue = "1") Integer page,
+                           @RequestParam(value = "limit", defaultValue = "10") Integer limit, StandardMemo standardMemo) {
+        PageHelper.startPage(page, limit);
+        List<StandardMemo> standardMemoList = standardMemoService.getStandardMemos(standardMemo);
+        PageInfo<StandardMemo> pageInfo = new PageInfo<>(standardMemoList);
+        return Msg.success().add("list", pageInfo);
+    }
 
-	/**
-	 * 添加产品知识
-	 */
-	@RequestMapping("/addInformation")
-	public Msg addInformation(Information information, HttpSession session) {
-		informationService.addInformation(information, session);
-		return Msg.success();
-	}
+    /**
+     * 添加产品知识
+     */
+    @RequestMapping("/addStandard")
+    public Msg addStandard(StandardMemo standardMemo, HttpSession session) {
+        standardMemoService.addStandardMemo(standardMemo, session);
+        return Msg.success();
+    }
 
-	/**
-	 * 修改产品知识
-	 */
-	@RequestMapping("/updateInformation")
-	public Msg updateInformation(Information information, HttpSession session) {
-		informationService.updateInformationById(information, session);
-		return Msg.success();
-	}
+    /**
+     * 修改产品知识
+     */
+    @RequestMapping("/updateStandard")
+    public Msg updateStandard(StandardMemo standardMemo, HttpSession session) {
+        standardMemoService.updateStandardMemoById(standardMemo, session);
+        return Msg.success();
+    }
 
-	/**
-	 * 删除
-	 */
-	@RequestMapping("/deleteInformation")
-	public Msg deleteInformation(@RequestParam("id") Integer id) {
-		informationService.deleteInformationById(id);
-		return Msg.success();
-	}
+    /**
+     * 删除
+     */
+    @RequestMapping("/deleteStandard")
+    public Msg deleteStandard(@RequestParam("id") Integer id) {
+        standardMemoService.deleteStandardMemoById(id);
+        return Msg.success();
+    }
 }

+ 7 - 9
src/main/java/lingtao/net/dao/StandardMemoMapper.java

@@ -1,19 +1,17 @@
 package lingtao.net.dao;
 
-import java.util.List;
-
-import lingtao.net.bean.Information;
+import lingtao.net.bean.StandardMemo;
 
-public interface InformationMapper {
+import java.util.List;
 
-	List<Information> getInformations(Information information);
+public interface StandardMemoMapper {
 
-	void addInformation(Information information);
+    List<StandardMemo> getStandardMemos(StandardMemo standardMemo);
 
-	void updateInformationById(Information information);
+    void addStandardMemo(StandardMemo standardMemo);
 
-	void deleteInformationById(Integer id);
+    void updateStandardMemoById(StandardMemo standardMemo);
 
-	List<Information> getShortAnswers();
+    void deleteStandardMemoById(Integer id);
 
 }

+ 47 - 53
src/main/java/lingtao/net/service/StandardMemoService.java

@@ -1,62 +1,56 @@
 package lingtao.net.service;
 
-import java.util.List;
-
-import javax.servlet.http.HttpSession;
-
+import lingtao.net.bean.Msg;
+import lingtao.net.bean.StandardMemo;
+import lingtao.net.bean.SysUser;
+import lingtao.net.dao.StandardMemoMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import lingtao.net.bean.Information;
-import lingtao.net.bean.Msg;
-import lingtao.net.bean.SysUser;
-import lingtao.net.dao.InformationMapper;
+import javax.servlet.http.HttpSession;
+import java.util.List;
 
 @Service
-public class InformationService {
-
-	@Autowired
-	private InformationMapper informationMapper;
-
-	public List<Information> getInformations(Information information) {
-		return informationMapper.getInformations(information);
-	}
-
-	public Msg addInformation(Information information, HttpSession session) {
-		SysUser user = (SysUser) session.getAttribute("USER_SESSION");
-		information.setCreateBy(user.getRealname());
-		try {
-			informationMapper.addInformation(information);
-			return Msg.success();
-		} catch (Exception e) {
-			return Msg.fail();
-		}
-	}
-
-	public Msg updateInformationById(Information information, HttpSession session) {
-		SysUser user = (SysUser) session.getAttribute("USER_SESSION");
-		information.setUpdateBy(user.getRealname());
-		try {
-			informationMapper.updateInformationById(information);
-			return Msg.success();
-		} catch (Exception e) {
-			return Msg.fail();
-		}
-
-	}
-
-	public Msg deleteInformationById(Integer id) {
-		try {
-			informationMapper.deleteInformationById(id);
-			return Msg.success();
-		} catch (Exception e) {
-			return Msg.fail();
-		}
-
-	}
-
-	public List<Information> getShortAnswers() {
-		return informationMapper.getShortAnswers();
-	}
+public class StandardMemoService {
+
+    @Autowired
+    private StandardMemoMapper standardMemoMapper;
+
+    public List<StandardMemo> getStandardMemos(StandardMemo standardMemo) {
+        return standardMemoMapper.getStandardMemos(standardMemo);
+    }
+
+    public Msg addStandardMemo(StandardMemo standardMemo, HttpSession session) {
+        SysUser user = (SysUser) session.getAttribute("USER_SESSION");
+        standardMemo.setCreateBy(user.getRealname());
+        try {
+            standardMemoMapper.addStandardMemo(standardMemo);
+            return Msg.success();
+        } catch (Exception e) {
+            return Msg.fail();
+        }
+    }
+
+    public Msg updateStandardMemoById(StandardMemo standardMemo, HttpSession session) {
+        SysUser user = (SysUser) session.getAttribute("USER_SESSION");
+        standardMemo.setUpdateBy(user.getRealname());
+        try {
+            standardMemoMapper.updateStandardMemoById(standardMemo);
+            return Msg.success();
+        } catch (Exception e) {
+            return Msg.fail();
+        }
+
+    }
+
+    public Msg deleteStandardMemoById(Integer id) {
+        try {
+            standardMemoMapper.deleteStandardMemoById(id);
+            return Msg.success();
+        } catch (Exception e) {
+            return Msg.fail();
+        }
+
+    }
 
 }

+ 42 - 56
src/main/resources/mapper/StandardMemoMapper.xml

@@ -1,62 +1,48 @@
 <?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="lingtao.net.dao.InformationMapper">
+<mapper namespace="lingtao.net.dao.StandardMemoMapper">
+    <select id="getStandardMemos" parameterType="lingtao.net.bean.StandardMemo"
+            resultType="lingtao.net.bean.StandardMemo">
+        SELECT
+        *
+        FROM
+        tbl_standard_memo
+        <where>
+            <if test="content != null and content != ''">
+                title like '%${content}%' or content like '%${content}%'
+            </if>
+        </where>
+        order by id desc
+    </select>
 
-	<select id="getInformations" parameterType="Information"
-		resultType="Information">
-		SELECT
-		*
-		FROM
-		tbl_information
-		<where>
-			<if test="content != null and content != ''">
-				content like '%${content}%'
-			</if>
-		</where>
-		order by id 
-	</select>
-	
-	<!-- 获取简答题 -->
-	<select id="getShortAnswers" resultType="Information">
-		SELECT 
-		  * 
-		FROM
-		  tbl_information 
-		WHERE TYPE = 0 
-		ORDER BY id 
-	</select>
+    <insert id="addStandardMemo" parameterType="lingtao.net.bean.StandardMemo">
+        insert into tbl_standard_memo
+            (content, createBy, createDate, title)
+        values (#{content}, #{createBy}, now(), #{title})
+    </insert>
 
-	<insert id="addInformation" parameterType="Information">
-		insert into
-			tbl_information
-		(content,type,createBy,createDate,attachment)
-		values
-		(#{content},#{type},#{createBy},now(),#{attachment})
-	</insert>
+    <update id="updateStandardMemoById" parameterType="lingtao.net.bean.StandardMemo">
+        update tbl_standard_memo
+        <set>
+            <if test="content != null">
+                content = #{content,jdbcType=VARCHAR},
+            </if>
+            <if test="updateBy != null">
+                updateBy = #{updateBy,jdbcType=VARCHAR},
+            </if>
+            <if test="updateDate != null">
+                updateDate = now(),
+            </if>
+            <if test="attachment != null">
+                title = #{title,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where id = #{id,jdbcType=INTEGER}
+    </update>
 
-	<update id="updateInformationById" parameterType="Information">
-		update tbl_information
-		<set>
-			<if test="content != null">
-				content = #{content,jdbcType=VARCHAR},
-			</if>
-			<if test="type != null">
-				type = #{type,jdbcType=VARCHAR},
-			</if>
-			<if test="updateBy != null">
-				updateBy = #{updateBy,jdbcType=VARCHAR},
-			</if>
-			<if test="updateDate != null">
-				updateDate = now(),
-			</if>
-			<if test="attachment != null">
-				attachment = #{attachment,jdbcType=VARCHAR},
-			</if>
-		</set>
-		where id = #{id,jdbcType=INTEGER}
-	</update>
-
-	<delete id="deleteInformationById">
-		delete from tbl_information where id = #{id}
-	</delete>
+    <delete id="deleteStandardMemoById">
+        delete
+        from tbl_standard_memo
+        where id = #{id}
+    </delete>
 </mapper>