CrmCustomerAssistMapper.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.CrmCustomerAssistMapper">
  6. <resultMap type="CrmCustomerAssist" id="CrmCustomerAssistResult">
  7. <result property="id" column="id" />
  8. <result property="companyId" column="company_id" />
  9. <result property="companyUserId" column="company_user_id" />
  10. <result property="companyUserName" column="company_user_name" />
  11. <result property="customerId" column="customer_id" />
  12. <result property="createTime" column="create_time" />
  13. </resultMap>
  14. <sql id="selectCrmCustomerAssistVo">
  15. select id, company_id, company_user_id,company_user_name, customer_id, create_time from crm_customer_assist
  16. </sql>
  17. <select id="selectCrmCustomerAssistList" parameterType="CrmCustomerAssist" resultMap="CrmCustomerAssistResult">
  18. <include refid="selectCrmCustomerAssistVo"/>
  19. <where>
  20. <if test="companyId != null "> and company_id = #{companyId}</if>
  21. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  22. <if test="companyUserName != null and companyUserName != ''"> and company_user_name = #{companyUserName}</if>
  23. <if test="customerId != null "> and customer_id = #{customerId}</if>
  24. </where>
  25. </select>
  26. <select id="selectCrmCustomerAssistById" parameterType="Long" resultMap="CrmCustomerAssistResult">
  27. <include refid="selectCrmCustomerAssistVo"/>
  28. where id = #{id}
  29. </select>
  30. <select id="selectCompanyUserNameByCustomerId" resultType="java.lang.String">
  31. select CONCAT(company_user_name, '(', company_user_id, ')') AS assistUser
  32. from crm_customer_assist
  33. where customer_id = #{customerId}
  34. </select>
  35. <insert id="insertCrmCustomerAssist" parameterType="CrmCustomerAssist" useGeneratedKeys="true" keyProperty="id">
  36. insert into crm_customer_assist
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="companyId != null">company_id,</if>
  39. <if test="companyUserId != null">company_user_id,</if>
  40. <if test="companyUserName != null">company_user_name,</if>
  41. <if test="customerId != null">customer_id,</if>
  42. <if test="createTime != null">create_time,</if>
  43. </trim>
  44. <trim prefix="values (" suffix=")" suffixOverrides=",">
  45. <if test="companyId != null">#{companyId},</if>
  46. <if test="companyUserId != null">#{companyUserId},</if>
  47. <if test="companyUserName != null">#{companyUserName},</if>
  48. <if test="customerId != null">#{customerId},</if>
  49. <if test="createTime != null">#{createTime},</if>
  50. </trim>
  51. </insert>
  52. <update id="updateCrmCustomerAssist" parameterType="CrmCustomerAssist">
  53. update crm_customer_assist
  54. <trim prefix="SET" suffixOverrides=",">
  55. <if test="companyId != null">company_id = #{companyId},</if>
  56. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  57. <if test="companyUserName != null">company_user_name = #{companyUserName},</if>
  58. <if test="customerId != null">customer_id = #{customerId},</if>
  59. <if test="createTime != null">create_time = #{createTime},</if>
  60. </trim>
  61. where id = #{id}
  62. </update>
  63. <delete id="deleteCrmCustomerAssistById" parameterType="Long">
  64. delete from crm_customer_assist where id = #{id}
  65. </delete>
  66. <delete id="deleteCrmCustomerAssistByIds" parameterType="String">
  67. delete from crm_customer_assist where id in
  68. <foreach item="id" collection="array" open="(" separator="," close=")">
  69. #{id}
  70. </foreach>
  71. </delete>
  72. <delete id="removeByCustomer">
  73. delete from crm_customer_assist where customer_id in
  74. <foreach collection="maps.customerIds" item="customerId" open="(" separator="," close=")">
  75. #{customerId}
  76. </foreach>
  77. <if test="maps.companyUserId != null">
  78. and company_user_id = #{maps.companyUserId}
  79. </if>
  80. </delete>
  81. <delete id="deleteCrmCustomerAssistByCustomerId">
  82. delete from crm_customer_assist where customer_id = #{customerId}
  83. </delete>
  84. </mapper>