ChatMsgUserMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.kede.common.dao.ChatMsgUserMapper">
  4. <resultMap type="com.kede.common.model.ChatMsgUser" id="ChatMsgUserMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="userId" column="user_id" jdbcType="VARCHAR"/>
  7. <result property="name" column="name" jdbcType="VARCHAR"/>
  8. <result property="type" column="type" jdbcType="INTEGER"/>
  9. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  10. </resultMap>
  11. <sql id="ChatMsgUserAllSql">
  12. id, user_id, name, type, create_time
  13. </sql>
  14. <!--查询单个-->
  15. <select id="selectById" resultMap="ChatMsgUserMap">
  16. select
  17. <include refid="ChatMsgUserAllSql"/>
  18. from chat_msg_user
  19. where id = #{id}
  20. </select>
  21. <!--新增所有列-->
  22. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  23. insert into chat_msg_user(user_id, name, type, create_time)
  24. values (#{userId}, #{name}, #{type}, #{createTime})
  25. </insert>
  26. <insert id="insertBatch">
  27. insert into chat_msg_user(user_id, name, type, create_time)
  28. values
  29. <foreach collection="entities" item="entity" separator=",">
  30. (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime})
  31. </foreach>
  32. </insert>
  33. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  34. insert into chat_msg_user(user_id, name, type, create_time)
  35. values
  36. <foreach collection="entities" item="entity" separator=",">
  37. (#{entity.userId}, #{entity.name}, #{entity.type}, #{entity.createTime})
  38. </foreach>
  39. on duplicate key update
  40. user_id = values(user_id),
  41. name = values(name),
  42. type = values(type),
  43. create_time = values(create_time)
  44. </insert>
  45. <!--通过主键修改数据-->
  46. <update id="update">
  47. update chat_msg_user
  48. <set>
  49. <if test="userId != null and userId != ''">
  50. user_id = #{userId},
  51. </if>
  52. <if test="name != null and name != ''">
  53. name = #{name},
  54. </if>
  55. <if test="type != null">
  56. type = #{type},
  57. </if>
  58. <if test="createTime != null">
  59. create_time = #{createTime},
  60. </if>
  61. </set>
  62. where id = #{id}
  63. </update>
  64. <!--查询指定行数据-->
  65. <select id="findChatMsgUserList" resultMap="ChatMsgUserMap">
  66. select
  67. <include refid="ChatMsgUserAllSql"/>
  68. from chat_msg_user
  69. <where>
  70. <if test="id != null">
  71. and id = #{id}
  72. </if>
  73. <if test="userId != null and userId != ''">
  74. and user_id = #{userId}
  75. </if>
  76. <if test="name != null and name != ''">
  77. and name = #{name}
  78. </if>
  79. <if test="type != null">
  80. and type = #{type}
  81. </if>
  82. <if test="createTime != null">
  83. and create_time = #{createTime}
  84. </if>
  85. </where>
  86. <if test="page_sql != null">
  87. ${page_sql}
  88. </if>
  89. </select>
  90. <!--统计总行数-->
  91. <select id="findChatMsgUserCount" resultType="java.lang.Integer">
  92. select count(1)
  93. from chat_msg_user
  94. <where>
  95. <if test="id != null">
  96. and id = #{id}
  97. </if>
  98. <if test="userId != null and userId != ''">
  99. and user_id = #{userId}
  100. </if>
  101. <if test="name != null and name != ''">
  102. and name = #{name}
  103. </if>
  104. <if test="type != null">
  105. and type = #{type}
  106. </if>
  107. <if test="createTime != null">
  108. and create_time = #{createTime}
  109. </if>
  110. </where>
  111. </select>
  112. <!--通过主键删除-->
  113. <delete id="deleteById">
  114. delete
  115. from chat_msg_user
  116. where id = #{id}
  117. </delete>
  118. <select id="selectByUserId" resultMap="ChatMsgUserMap">
  119. select
  120. <include refid="ChatMsgUserAllSql"/>
  121. from chat_msg_user
  122. where user_id = #{id}
  123. </select>
  124. </mapper>