fuliqi
2024-10-17 8546b3d285af4235a0ef615a0c6e89486ae2c806
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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.ycl.jxkg.mapper.MessageMapper">
    <resultMap id="BaseResultMap" type="com.ycl.jxkg.domain.entity.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="page" resultMap="BaseResultMap" parameterType="com.ycl.jxkg.domain.vo.admin.message.MessagePageRequestVO">
        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>