xiangpei
2024-05-31 c9d04bc519b73f7fc4841c34e2f15fca9db7aad2
src/main/resources/mapper/MessageMapper.xml
@@ -13,135 +13,10 @@
    <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,
        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.ycl.jxkg.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.ycl.jxkg.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.ycl.jxkg.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.ycl.jxkg.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.ycl.jxkg.vo.admin.message.MessagePageRequestVO">
    select
@@ -165,8 +40,10 @@
  </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 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>