QwContactWayLogsMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.qw.mapper.QwContactWayLogsMapper">
  6. <resultMap type="QwContactWayLogs" id="QwContactWayLogsResult">
  7. <result property="id" column="id" />
  8. <result property="wayId" column="way_id" />
  9. <result property="userId" column="user_id" />
  10. <result property="companyUserId" column="company_user_id" />
  11. <result property="type" column="type" />
  12. <result property="msg" column="msg" />
  13. <result property="corpId" column="corp_id" />
  14. <result property="externalUserId" column="external_user_id" />
  15. <result property="companyId" column="company_id" />
  16. <result property="createTime" column="create_time" />
  17. <result property="informationId" column="information_id" />
  18. </resultMap>
  19. <sql id="selectQwContactWayLogsVo">
  20. select id, way_id,information_id, user_id, company_user_id, type, msg, external_user_id, company_id, create_time,corp_id from qw_contact_way_logs
  21. </sql>
  22. <select id="selectQwContactWayLogsList" parameterType="QwContactWayLogs" resultType="QwContactWayLogs">
  23. select a.*,b.name,b.avatar,b.gender,b.is_repeat,c.nick_name from qw_contact_way_logs a
  24. inner join qw_external_contact b on a.external_user_id = b.id
  25. inner join company_user c on b.company_user_id = c.user_id
  26. <where>
  27. <if test="wayId != null "> and a.way_id = #{wayId}</if>
  28. <if test="userId != null "> and a.user_id = #{userId}</if>
  29. <if test="companyUserId != null "> and b.company_user_id = #{companyUserId}</if>
  30. <if test="type != null "> and a.type = #{type}</if>
  31. <if test="msg != null and msg != ''"> and a.msg = #{msg}</if>
  32. <if test="corpId != null "> and a.corp_id = #{corpId}</if>
  33. <if test="externalUserId != null "> and a.external_user_id = #{externalUserId}</if>
  34. <if test="companyId != null "> and a.company_id = #{companyId}</if>
  35. <if test="beginTime != null"><!-- 开始时间检索 -->
  36. AND date_format(a.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  37. </if>
  38. <if test="endTime != null"><!-- 结束时间检索 -->
  39. AND date_format(a.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  40. </if>
  41. </where>
  42. </select>
  43. <select id="selectQwContactWayLogsById" parameterType="Long" resultMap="QwContactWayLogsResult">
  44. <include refid="selectQwContactWayLogsVo"/>
  45. where id = #{id}
  46. </select>
  47. <insert id="insertQwContactWayLogs" parameterType="QwContactWayLogs" useGeneratedKeys="true" keyProperty="id">
  48. insert into qw_contact_way_logs
  49. <trim prefix="(" suffix=")" suffixOverrides=",">
  50. <if test="wayId != null">way_id,</if>
  51. <if test="userId != null">user_id,</if>
  52. <if test="companyUserId != null">company_user_id,</if>
  53. <if test="type != null">type,</if>
  54. <if test="msg != null">msg,</if>
  55. <if test="corpId != null">corp_id,</if>
  56. <if test="externalUserId != null">external_user_id,</if>
  57. <if test="companyId != null">company_id,</if>
  58. <if test="createTime != null">create_time,</if>
  59. <if test="informationId != null">information_id,</if>
  60. </trim>
  61. <trim prefix="values (" suffix=")" suffixOverrides=",">
  62. <if test="wayId != null">#{wayId},</if>
  63. <if test="userId != null">#{userId},</if>
  64. <if test="companyUserId != null">#{companyUserId},</if>
  65. <if test="type != null">#{type},</if>
  66. <if test="msg != null">#{msg},</if>
  67. <if test="corpId != null">#{corpId},</if>
  68. <if test="externalUserId != null">#{externalUserId},</if>
  69. <if test="companyId != null">#{companyId},</if>
  70. <if test="createTime != null">#{createTime},</if>
  71. <if test="informationId != null">#{informationId},</if>
  72. </trim>
  73. </insert>
  74. <update id="updateQwContactWayLogs" parameterType="QwContactWayLogs">
  75. update qw_contact_way_logs
  76. <trim prefix="SET" suffixOverrides=",">
  77. <if test="wayId != null">way_id = #{wayId},</if>
  78. <if test="userId != null">user_id = #{userId},</if>
  79. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  80. <if test="type != null">type = #{type},</if>
  81. <if test="msg != null">msg = #{msg},</if>
  82. <if test="corpId != null">corp_id = #{corpId},</if>
  83. <if test="externalUserId != null">external_user_id = #{externalUserId},</if>
  84. <if test="companyId != null">company_id = #{companyId},</if>
  85. <if test="createTime != null">create_time = #{createTime},</if>
  86. <if test="informationId != null">information_id = #{informationId},</if>
  87. </trim>
  88. where id = #{id}
  89. </update>
  90. <delete id="deleteQwContactWayLogsById" parameterType="Long">
  91. delete from qw_contact_way_logs where id = #{id}
  92. </delete>
  93. <delete id="deleteQwContactWayLogsByIds" parameterType="String">
  94. delete from qw_contact_way_logs where id in
  95. <foreach item="id" collection="array" open="(" separator="," close=")">
  96. #{id}
  97. </foreach>
  98. </delete>
  99. </mapper>