CrmCustomerLogsMapper.xml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.crm.mapper.CrmCustomerLogsMapper">
  6. <resultMap type="CrmCustomerLogs" id="CrmCustomerLogsResult">
  7. <result property="logsId" column="logs_id" />
  8. <result property="customerId" column="customer_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="title" column="title" />
  11. <result property="remark" column="remark" />
  12. <result property="createTime" column="create_time" />
  13. <result property="logsType" column="logs_type" />
  14. <result property="userName" column="user_name" />
  15. </resultMap>
  16. <sql id="selectCrmCustomerLogsVo">
  17. select ccl.*,cu.user_name from crm_customer_logs ccl left join crm_customer cc on ccl.customer_id = cc.customer_id left join company_user cu on cc.create_user_id = cu.user_id
  18. </sql>
  19. <select id="selectCrmCustomerLogsList" parameterType="CrmCustomerLogs" resultMap="CrmCustomerLogsResult">
  20. <include refid="selectCrmCustomerLogsVo"/>
  21. <where>
  22. <if test="customerId != null "> and ccl.customer_id = #{customerId}</if>
  23. <if test="companyUserId != null "> and ccl.company_user_id = #{companyUserId}</if>
  24. <if test="title != null and title != ''"> and ccl.title = #{title}</if>
  25. <if test="logsType != null "> and ccl.logs_type = #{logsType}</if>
  26. </where>
  27. order by ccl.logs_id desc
  28. </select>
  29. <select id="selectCrmCustomerLogsById" parameterType="Long" resultMap="CrmCustomerLogsResult">
  30. <include refid="selectCrmCustomerLogsVo"/>
  31. where logs_id = #{logsId}
  32. </select>
  33. <insert id="insertCrmCustomerLogs" parameterType="CrmCustomerLogs" useGeneratedKeys="true" keyProperty="logsId">
  34. insert into crm_customer_logs
  35. <trim prefix="(" suffix=")" suffixOverrides=",">
  36. <if test="customerId != null">customer_id,</if>
  37. <if test="companyUserId != null">company_user_id,</if>
  38. <if test="title != null">title,</if>
  39. <if test="remark != null">remark,</if>
  40. <if test="createTime != null">create_time,</if>
  41. <if test="logsType != null">logs_type,</if>
  42. </trim>
  43. <trim prefix="values (" suffix=")" suffixOverrides=",">
  44. <if test="customerId != null">#{customerId},</if>
  45. <if test="companyUserId != null">#{companyUserId},</if>
  46. <if test="title != null">#{title},</if>
  47. <if test="remark != null">#{remark},</if>
  48. <if test="createTime != null">#{createTime},</if>
  49. <if test="logsType != null">#{logsType},</if>
  50. </trim>
  51. </insert>
  52. <update id="updateCrmCustomerLogs" parameterType="CrmCustomerLogs">
  53. update crm_customer_logs
  54. <trim prefix="SET" suffixOverrides=",">
  55. <if test="customerId != null">customer_id = #{customerId},</if>
  56. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  57. <if test="title != null">title = #{title},</if>
  58. <if test="remark != null">remark = #{remark},</if>
  59. <if test="createTime != null">create_time = #{createTime},</if>
  60. <if test="logsType != null">logs_type = #{logsType},</if>
  61. </trim>
  62. where logs_id = #{logsId}
  63. </update>
  64. <delete id="deleteCrmCustomerLogsById" parameterType="Long">
  65. delete from crm_customer_logs where logs_id = #{logsId}
  66. </delete>
  67. <delete id="deleteCrmCustomerLogsByIds" parameterType="String">
  68. delete from crm_customer_logs where logs_id in
  69. <foreach item="logsId" collection="array" open="(" separator="," close=")">
  70. #{logsId}
  71. </foreach>
  72. </delete>
  73. </mapper>