CustomerPointsRecordMapper.xml 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.yijia.integral.mapper.CustomerPointsRecordMapper">
  6. <resultMap type="CustomerPointsRecord" id="CustomerPointsRecordResult">
  7. <result property="id" column="id" />
  8. <result property="unionId" column="union_id" />
  9. <result property="customerName" column="customer_name" />
  10. <result property="recordType" column="record_type" />
  11. <result property="integral" column="integral" />
  12. <result property="createTime" column="create_time" />
  13. <result property="stationId" column="station_id" />
  14. <result property="stationName" column="station_name" />
  15. </resultMap>
  16. <sql id="selectCustomerPointsRecordVo">
  17. select id, union_id, customer_name, record_type, integral, create_time, station_id, station_name from customer_points_record
  18. </sql>
  19. <select id="selectCustomerPointsRecordList" parameterType="CustomerPointsRecord" resultMap="CustomerPointsRecordResult">
  20. <include refid="selectCustomerPointsRecordVo"/>
  21. <where>
  22. <if test="unionId != null and unionId != ''"> and union_id = #{unionId}</if>
  23. <if test="customerName != null and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
  24. <if test="recordType != null and recordType != ''"> and record_type = #{recordType}</if>
  25. <if test="integral != null "> and integral = #{integral}</if>
  26. <if test="stationId != null "> and station_id = #{stationId}</if>
  27. <if test="stationIdList != null ">
  28. and station_id in
  29. <foreach item="item" index="index" collection="stationIdList"
  30. open="(" separator="," close=")">
  31. #{item}
  32. </foreach>
  33. </if>
  34. </where>
  35. order by id desc
  36. </select>
  37. <select id="selectCustomerPointsRecordById" parameterType="Long" resultMap="CustomerPointsRecordResult">
  38. <include refid="selectCustomerPointsRecordVo"/>
  39. where id = #{id}
  40. </select>
  41. <insert id="insertCustomerPointsRecord" parameterType="CustomerPointsRecord" useGeneratedKeys="true" keyProperty="id">
  42. insert into customer_points_record
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="unionId != null">union_id,</if>
  45. <if test="customerName != null">customer_name,</if>
  46. <if test="recordType != null">record_type,</if>
  47. <if test="integral != null">integral,</if>
  48. <if test="createTime != null">create_time,</if>
  49. <if test="stationId != null">station_id,</if>
  50. <if test="stationName != null">station_name,</if>
  51. </trim>
  52. <trim prefix="values (" suffix=")" suffixOverrides=",">
  53. <if test="unionId != null">#{unionId},</if>
  54. <if test="customerName != null">#{customerName},</if>
  55. <if test="recordType != null">#{recordType},</if>
  56. <if test="integral != null">#{integral},</if>
  57. <if test="createTime != null">#{createTime},</if>
  58. <if test="stationId != null">#{stationId},</if>
  59. <if test="stationName != null">#{stationName},</if>
  60. </trim>
  61. </insert>
  62. <update id="updateCustomerPointsRecord" parameterType="CustomerPointsRecord">
  63. update customer_points_record
  64. <trim prefix="SET" suffixOverrides=",">
  65. <if test="unionId != null">union_id = #{unionId},</if>
  66. <if test="customerName != null">customer_name = #{customerName},</if>
  67. <if test="recordType != null">record_type = #{recordType},</if>
  68. <if test="integral != null">integral = #{integral},</if>
  69. <if test="createTime != null">create_time = #{createTime},</if>
  70. <if test="stationId != null">station_id = #{stationId},</if>
  71. <if test="stationName != null">station_name = #{stationName},</if>
  72. </trim>
  73. where id = #{id}
  74. </update>
  75. <delete id="deleteCustomerPointsRecordById" parameterType="Long">
  76. delete from customer_points_record where id = #{id}
  77. </delete>
  78. <delete id="deleteCustomerPointsRecordByIds" parameterType="String">
  79. delete from customer_points_record where id in
  80. <foreach item="id" collection="array" open="(" separator="," close=")">
  81. #{id}
  82. </foreach>
  83. </delete>
  84. </mapper>