|
@@ -0,0 +1,177 @@
|
|
|
+<?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.example.nngkxxdp.program.dao.HlwPraisesDao">
|
|
|
+
|
|
|
+ <resultMap type="com.example.nngkxxdp.program.entity.jsonobj.HlwPraises" id="HlwPraisesMap">
|
|
|
+ <result property="id" column="id" jdbcType="INTEGER"/>
|
|
|
+ <result property="userId" column="user_id" jdbcType="INTEGER"/>
|
|
|
+ <result property="nickName" column="nick_name" jdbcType="VARCHAR"/>
|
|
|
+ <result property="sourceUserImage" column="source_user_image" jdbcType="VARCHAR"/>
|
|
|
+ <result property="praiseTime" column="praise_time" jdbcType="VARCHAR"/>
|
|
|
+ <result property="sourceId" column="source_id" jdbcType="VARCHAR"/>
|
|
|
+ <result property="sourceType" column="source_type" jdbcType="INTEGER"/>
|
|
|
+ <result property="type" column="type" jdbcType="INTEGER"/>
|
|
|
+ <result property="content" column="content" jdbcType="VARCHAR"/>
|
|
|
+ <result property="sourceTitle" column="source_title" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!--查询单个-->
|
|
|
+ <select id="queryById" resultMap="HlwPraisesMap">
|
|
|
+ select
|
|
|
+ id, user_id, nick_name, source_user_image, praise_time, source_id, source_type, type, content, source_title
|
|
|
+ from hlw_praises
|
|
|
+ where id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--查询指定行数据-->
|
|
|
+ <select id="queryAllByLimit" resultMap="HlwPraisesMap">
|
|
|
+ select
|
|
|
+ id, user_id, nick_name, source_user_image, praise_time, source_id, source_type, type, content, source_title
|
|
|
+ from hlw_praises
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ and user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="nickName != null and nickName != ''">
|
|
|
+ and nick_name = #{nickName}
|
|
|
+ </if>
|
|
|
+ <if test="sourceUserImage != null and sourceUserImage != ''">
|
|
|
+ and source_user_image = #{sourceUserImage}
|
|
|
+ </if>
|
|
|
+ <if test="praiseTime != null and praiseTime != ''">
|
|
|
+ and praise_time = #{praiseTime}
|
|
|
+ </if>
|
|
|
+ <if test="sourceId != null and sourceId != ''">
|
|
|
+ and source_id = #{sourceId}
|
|
|
+ </if>
|
|
|
+ <if test="sourceType != null">
|
|
|
+ and source_type = #{sourceType}
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ and type = #{type}
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ and content = #{content}
|
|
|
+ </if>
|
|
|
+ <if test="sourceTitle != null and sourceTitle != ''">
|
|
|
+ and source_title = #{sourceTitle}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ limit #{pageable.offset}, #{pageable.pageSize}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--统计总行数-->
|
|
|
+ <select id="count" resultType="java.lang.Long">
|
|
|
+ select count(1)
|
|
|
+ from hlw_praises
|
|
|
+ <where>
|
|
|
+ <if test="id != null">
|
|
|
+ and id = #{id}
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ and user_id = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="nickName != null and nickName != ''">
|
|
|
+ and nick_name = #{nickName}
|
|
|
+ </if>
|
|
|
+ <if test="sourceUserImage != null and sourceUserImage != ''">
|
|
|
+ and source_user_image = #{sourceUserImage}
|
|
|
+ </if>
|
|
|
+ <if test="praiseTime != null and praiseTime != ''">
|
|
|
+ and praise_time = #{praiseTime}
|
|
|
+ </if>
|
|
|
+ <if test="sourceId != null and sourceId != ''">
|
|
|
+ and source_id = #{sourceId}
|
|
|
+ </if>
|
|
|
+ <if test="sourceType != null">
|
|
|
+ and source_type = #{sourceType}
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ and type = #{type}
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ and content = #{content}
|
|
|
+ </if>
|
|
|
+ <if test="sourceTitle != null and sourceTitle != ''">
|
|
|
+ and source_title = #{sourceTitle}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!--新增所有列-->
|
|
|
+ <insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into hlw_praises(user_id, nick_name, source_user_image, praise_time, source_id, source_type, type, content, source_title)
|
|
|
+ values (#{userId}, #{nickName}, #{sourceUserImage}, #{praiseTime}, #{sourceId}, #{sourceType}, #{type}, #{content}, #{sourceTitle})
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into hlw_praises(user_id, nick_name, source_user_image, praise_time, source_id, source_type, type, content, source_title)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{entity.userId}, #{entity.nickName}, #{entity.sourceUserImage}, #{entity.praiseTime}, #{entity.sourceId}, #{entity.sourceType}, #{entity.type}, #{entity.content}, #{entity.sourceTitle})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
|
+ insert into hlw_praises(user_id, nick_name, source_user_image, praise_time, source_id, source_type, type, content, source_title)
|
|
|
+ values
|
|
|
+ <foreach collection="entities" item="entity" separator=",">
|
|
|
+ (#{entity.userId}, #{entity.nickName}, #{entity.sourceUserImage}, #{entity.praiseTime}, #{entity.sourceId}, #{entity.sourceType}, #{entity.type}, #{entity.content}, #{entity.sourceTitle})
|
|
|
+ </foreach>
|
|
|
+ on duplicate key update
|
|
|
+ user_id = values(user_id),
|
|
|
+ nick_name = values(nick_name),
|
|
|
+ source_user_image = values(source_user_image),
|
|
|
+ praise_time = values(praise_time),
|
|
|
+ source_id = values(source_id),
|
|
|
+ source_type = values(source_type),
|
|
|
+ type = values(type),
|
|
|
+ content = values(content),
|
|
|
+ source_title = values(source_title)
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!--通过主键修改数据-->
|
|
|
+ <update id="update">
|
|
|
+ update hlw_praises
|
|
|
+ <set>
|
|
|
+ <if test="userId != null">
|
|
|
+ user_id = #{userId},
|
|
|
+ </if>
|
|
|
+ <if test="nickName != null and nickName != ''">
|
|
|
+ nick_name = #{nickName},
|
|
|
+ </if>
|
|
|
+ <if test="sourceUserImage != null and sourceUserImage != ''">
|
|
|
+ source_user_image = #{sourceUserImage},
|
|
|
+ </if>
|
|
|
+ <if test="praiseTime != null and praiseTime != ''">
|
|
|
+ praise_time = #{praiseTime},
|
|
|
+ </if>
|
|
|
+ <if test="sourceId != null and sourceId != ''">
|
|
|
+ source_id = #{sourceId},
|
|
|
+ </if>
|
|
|
+ <if test="sourceType != null">
|
|
|
+ source_type = #{sourceType},
|
|
|
+ </if>
|
|
|
+ <if test="type != null">
|
|
|
+ type = #{type},
|
|
|
+ </if>
|
|
|
+ <if test="content != null and content != ''">
|
|
|
+ content = #{content},
|
|
|
+ </if>
|
|
|
+ <if test="sourceTitle != null and sourceTitle != ''">
|
|
|
+ source_title = #{sourceTitle},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!--通过主键删除-->
|
|
|
+ <delete id="deleteById">
|
|
|
+ delete from hlw_praises where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+</mapper>
|
|
|
+
|