|
@@ -0,0 +1,125 @@
|
|
|
|
+<?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.sooka.jnb.knowledge.mapper.JnbKnowledgeBaseMapper">
|
|
|
|
+
|
|
|
|
+ <resultMap type="JnbKnowledgeBase" id="JnbKnowledgeBaseResult">
|
|
|
|
+ <result property="id" column="id" />
|
|
|
|
+ <result property="titleName" column="title_name" />
|
|
|
|
+ <result property="textDetails" column="text_details" />
|
|
|
|
+ <result property="popular" column="popular" />
|
|
|
|
+ <result property="integral" column="integral" />
|
|
|
|
+ <result property="likeNum" column="like_num" />
|
|
|
|
+ <result property="watchNum" column="watch_num" />
|
|
|
|
+ <result property="createBy" column="create_by" />
|
|
|
|
+ <result property="createTime" column="create_time" />
|
|
|
|
+ <result property="updateBy" column="update_by" />
|
|
|
|
+ <result property="updateTime" column="update_time" />
|
|
|
|
+ <result property="delFlag" column="del_flag" />
|
|
|
|
+ </resultMap>
|
|
|
|
+
|
|
|
|
+ <sql id="selectJnbKnowledgeBaseVo">
|
|
|
|
+ SELECT
|
|
|
|
+ jkb.id,
|
|
|
|
+ title_name,
|
|
|
|
+ text_details,
|
|
|
|
+ popular,
|
|
|
|
+ integral,
|
|
|
|
+ like_num,
|
|
|
|
+ watch_num,
|
|
|
|
+ jkb.create_by,
|
|
|
|
+ jkb.create_time,
|
|
|
|
+ jkb.update_by,
|
|
|
|
+ jkb.update_time ,
|
|
|
|
+ GROUP_CONCAT(jkbi.id) AS imgId,
|
|
|
|
+ GROUP_CONCAT(jkbi.img_url) AS imgUrlList
|
|
|
|
+ FROM
|
|
|
|
+ jnb_knowledge_base jkb
|
|
|
|
+ left join jnb_knowledge_base_img jkbi on jkb.id = jkbi.knowledge_id and jkbi.del_flag = 0
|
|
|
|
+ where jkb.del_flag = 0
|
|
|
|
+ </sql>
|
|
|
|
+
|
|
|
|
+ <select id="selectJnbKnowledgeBaseList" resultType="com.sooka.jnb.knowledge.vo.JnbKnowledgeBaseVO">
|
|
|
|
+ <include refid="selectJnbKnowledgeBaseVo"/>
|
|
|
|
+ <if test="titleName != null and titleName != ''"> and title_name like concat('%', #{titleName}, '%')</if>
|
|
|
|
+ <if test="textDetails != null and textDetails != ''"> and text_details = #{textDetails}</if>
|
|
|
|
+ <if test="popular != null "> and popular = #{popular}</if>
|
|
|
|
+ <if test="integral != null "> and integral = #{integral}</if>
|
|
|
|
+ <if test="likeNum != null "> and like_num = #{likeNum}</if>
|
|
|
|
+ <if test="watchNum != null "> and watch_num = #{watchNum}</if>
|
|
|
|
+ GROUP BY jkb.id
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <select id="selectJnbKnowledgeBaseById" resultType="com.sooka.jnb.knowledge.vo.JnbKnowledgeBaseVO">
|
|
|
|
+ <include refid="selectJnbKnowledgeBaseVo"/>
|
|
|
|
+ and jkb.id = #{id}
|
|
|
|
+ GROUP BY jkb.id
|
|
|
|
+ </select>
|
|
|
|
+
|
|
|
|
+ <insert id="insertJnbKnowledgeBase" parameterType="com.sooka.jnb.knowledge.vo.JnbKnowledgeBaseVO" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
+ <selectKey keyProperty="id" resultType="java.lang.Long" order="AFTER">
|
|
|
|
+ SELECT LAST_INSERT_ID() AS id
|
|
|
|
+ </selectKey>
|
|
|
|
+ insert into jnb_knowledge_base
|
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
+ <if test="titleName != null">title_name,</if>
|
|
|
|
+ <if test="textDetails != null">text_details,</if>
|
|
|
|
+ <if test="popular != null">popular,</if>
|
|
|
|
+ <if test="integral != null">integral,</if>
|
|
|
|
+ <if test="likeNum != null">like_num,</if>
|
|
|
|
+ <if test="watchNum != null">watch_num,</if>
|
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
|
+ <if test="updateBy != null">update_by,</if>
|
|
|
|
+ <if test="updateTime != null">update_time,</if>
|
|
|
|
+ </trim>
|
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
|
+ <if test="titleName != null">#{titleName},</if>
|
|
|
|
+ <if test="textDetails != null">#{textDetails},</if>
|
|
|
|
+ <if test="popular != null">#{popular},</if>
|
|
|
|
+ <if test="integral != null">#{integral},</if>
|
|
|
|
+ <if test="likeNum != null">#{likeNum},</if>
|
|
|
|
+ <if test="watchNum != null">#{watchNum},</if>
|
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
|
+ <if test="updateBy != null">#{updateBy},</if>
|
|
|
|
+ <if test="updateTime != null">#{updateTime},</if>
|
|
|
|
+ </trim>
|
|
|
|
+ </insert>
|
|
|
|
+
|
|
|
|
+ <update id="updateJnbKnowledgeBase" parameterType="com.sooka.jnb.knowledge.vo.JnbKnowledgeBaseVO">
|
|
|
|
+ update jnb_knowledge_base
|
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
|
+ <if test="titleName != null">title_name = #{titleName},</if>
|
|
|
|
+ <if test="textDetails != null">text_details = #{textDetails},</if>
|
|
|
|
+ <if test="popular != null">popular = #{popular},</if>
|
|
|
|
+ <if test="integral != null">integral = #{integral},</if>
|
|
|
|
+ <if test="likeNum != null">like_num = #{likeNum},</if>
|
|
|
|
+ <if test="watchNum != null">watch_num = #{watchNum},</if>
|
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
+ <if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
+ <if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
+ </trim>
|
|
|
|
+ where id = #{id}
|
|
|
|
+ </update>
|
|
|
|
+
|
|
|
|
+ <delete id="deleteJnbKnowledgeBaseById" parameterType="Long">
|
|
|
|
+ delete from jnb_knowledge_base where id = #{id}
|
|
|
|
+ </delete>
|
|
|
|
+
|
|
|
|
+ <delete id="deleteJnbKnowledgeBaseByIds" parameterType="String">
|
|
|
|
+ update jnb_knowledge_base set del_flag = 1 where id in
|
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
+ #{id}
|
|
|
|
+ </foreach>
|
|
|
|
+ </delete>
|
|
|
|
+ <update id="updateIsPopular" parameterType="JnbKnowledgeBase">
|
|
|
|
+ update jnb_knowledge_base
|
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
|
+ <if test="popular != null">popular = #{popular},</if>
|
|
|
|
+ </trim>
|
|
|
|
+ where id = #{id}
|
|
|
|
+ </update>
|
|
|
|
+</mapper>
|