You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xzs-mysql/source/xzs/target/classes/mapper/MessageMapper.xml

173 lines
6.1 KiB

<?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.mindskip.xzs.repository.MessageMapper">
<resultMap id="BaseResultMap" type="com.mindskip.xzs.domain.Message">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="title" jdbcType="VARCHAR" property="title" />
<result column="content" jdbcType="VARCHAR" property="content" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="send_user_id" jdbcType="INTEGER" property="sendUserId" />
<result column="send_user_name" jdbcType="VARCHAR" property="sendUserName" />
<result column="send_real_name" jdbcType="VARCHAR" property="sendRealName" />
<result column="receive_user_count" jdbcType="INTEGER" property="receiveUserCount" />
<result column="read_count" jdbcType="INTEGER" property="readCount" />
</resultMap>
<sql id="Base_Column_List">
id, title, content, create_time, send_user_id, send_user_name, send_real_name, receive_user_count,
read_count
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_message
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from t_message
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.mindskip.xzs.domain.Message" useGeneratedKeys="true" keyProperty="id">
insert into t_message (id, title, content,
create_time, send_user_id, send_user_name,
send_real_name, receive_user_count, read_count
)
values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{sendUserId,jdbcType=INTEGER}, #{sendUserName,jdbcType=VARCHAR},
#{sendRealName,jdbcType=VARCHAR}, #{receiveUserCount,jdbcType=INTEGER}, #{readCount,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.mindskip.xzs.domain.Message" useGeneratedKeys="true" keyProperty="id">
insert into t_message
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="title != null">
title,
</if>
<if test="content != null">
content,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="sendUserId != null">
send_user_id,
</if>
<if test="sendUserName != null">
send_user_name,
</if>
<if test="sendRealName != null">
send_real_name,
</if>
<if test="receiveUserCount != null">
receive_user_count,
</if>
<if test="readCount != null">
read_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="sendUserId != null">
#{sendUserId,jdbcType=INTEGER},
</if>
<if test="sendUserName != null">
#{sendUserName,jdbcType=VARCHAR},
</if>
<if test="sendRealName != null">
#{sendRealName,jdbcType=VARCHAR},
</if>
<if test="receiveUserCount != null">
#{receiveUserCount,jdbcType=INTEGER},
</if>
<if test="readCount != null">
#{readCount,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.mindskip.xzs.domain.Message">
update t_message
<set>
<if test="title != null">
title = #{title,jdbcType=VARCHAR},
</if>
<if test="content != null">
content = #{content,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="sendUserId != null">
send_user_id = #{sendUserId,jdbcType=INTEGER},
</if>
<if test="sendUserName != null">
send_user_name = #{sendUserName,jdbcType=VARCHAR},
</if>
<if test="sendRealName != null">
send_real_name = #{sendRealName,jdbcType=VARCHAR},
</if>
<if test="receiveUserCount != null">
receive_user_count = #{receiveUserCount,jdbcType=INTEGER},
</if>
<if test="readCount != null">
read_count = #{readCount,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.mindskip.xzs.domain.Message">
update t_message
set title = #{title,jdbcType=VARCHAR},
content = #{content,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
send_user_id = #{sendUserId,jdbcType=INTEGER},
send_user_name = #{sendUserName,jdbcType=VARCHAR},
send_real_name = #{sendRealName,jdbcType=VARCHAR},
receive_user_count = #{receiveUserCount,jdbcType=INTEGER},
read_count = #{readCount,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="page" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.admin.message.MessagePageRequestVM">
select
<include refid="Base_Column_List" />
from t_message
<where>
<if test="sendUserName != null">
and send_user_name like concat('%',#{sendUserName},'%')
</if>
</where>
</select>
<select id="selectByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_message
where id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<update id="readAdd" parameterType="java.lang.Integer">
UPDATE t_message SET read_count = read_count + 1
WHERE id= #{id} and read_count = (SELECT m.read_count from ( SELECT read_count FROM t_message WHERE id = #{id} ) m)
</update>
</mapper>