CertificationMapper.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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.example.mapper.CertificationMapper">
  6. <sql id="Base_Column_List">
  7. id,user_id,name,avatar,phone,card_no,card1,card2,address,status,reason
  8. </sql>
  9. <select id="selectAll" resultType="com.example.entity.Certification">
  10. select
  11. <include refid="Base_Column_List" />
  12. from certification
  13. <where>
  14. <if test="id != null"> and id = #{id}</if>
  15. <if test="userId != null"> and user_id = #{userId}</if>
  16. <if test="name != null"> and name like concat('%', #{name}, '%')</if>
  17. <if test="avatar != null"> and avatar like concat('%', #{avatar}, '%')</if>
  18. <if test="phone != null"> and phone like concat('%', #{phone}, '%')</if>
  19. <if test="cardNo != null"> and card_no like concat('%', #{cardNo}, '%')</if>
  20. <if test="card1 != null"> and card1 like concat('%', #{card1}, '%')</if>
  21. <if test="card2 != null"> and card2 like concat('%', #{card2}, '%')</if>
  22. <if test="address != null"> and address like concat('%', #{address}, '%')</if>
  23. <if test="status != null"> and status like concat('%', #{status}, '%')</if>
  24. <if test="reason != null"> and reason like concat('%', #{reason}, '%')</if>
  25. </where>
  26. order by id desc
  27. </select>
  28. <select id="selectById" resultType="com.example.entity.Certification">
  29. select
  30. <include refid="Base_Column_List" />
  31. from certification
  32. where id = #{id}
  33. </select>
  34. <select id="selectByUserId" resultType="com.example.entity.Certification">
  35. select
  36. <include refid="Base_Column_List" />
  37. from certification
  38. where user_id = #{userId}
  39. </select>
  40. <delete id="deleteById">
  41. delete from certification
  42. where id = #{id}
  43. </delete>
  44. <insert id="insert" parameterType="com.example.entity.Certification" useGeneratedKeys="true">
  45. insert into certification
  46. <trim prefix="(" suffix=")" suffixOverrides=",">
  47. <if test="id != null">id,</if>
  48. <if test="userId != null">user_id,</if>
  49. <if test="name != null">name,</if>
  50. <if test="avatar != null">avatar,</if>
  51. <if test="phone != null">phone,</if>
  52. <if test="cardNo != null">card_no,</if>
  53. <if test="card1 != null">card1,</if>
  54. <if test="card2 != null">card2,</if>
  55. <if test="address != null">address,</if>
  56. <if test="status != null">status,</if>
  57. <if test="reason != null">reason,</if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="id != null">#{id},</if>
  61. <if test="userId != null">#{userId},</if>
  62. <if test="name != null">#{name},</if>
  63. <if test="avatar != null">#{avatar},</if>
  64. <if test="phone != null">#{phone},</if>
  65. <if test="cardNo != null">#{cardNo},</if>
  66. <if test="card1 != null">#{card1},</if>
  67. <if test="card2 != null">#{card2},</if>
  68. <if test="address != null">#{address},</if>
  69. <if test="status != null">#{status},</if>
  70. <if test="reason != null">#{reason},</if>
  71. </trim>
  72. </insert>
  73. <update id="updateById" parameterType="com.example.entity.Certification">
  74. update certification
  75. <set>
  76. <if test="userId != null">
  77. user_id = #{userId},
  78. </if>
  79. <if test="name != null">
  80. name = #{name},
  81. </if>
  82. <if test="avatar != null">
  83. avatar = #{avatar},
  84. </if>
  85. <if test="phone != null">
  86. phone = #{phone},
  87. </if>
  88. <if test="cardNo != null">
  89. card_no = #{cardNo},
  90. </if>
  91. <if test="card1 != null">
  92. card1 = #{card1},
  93. </if>
  94. <if test="card2 != null">
  95. card2 = #{card2},
  96. </if>
  97. <if test="address != null">
  98. address = #{address},
  99. </if>
  100. <if test="status != null">
  101. status = #{status},
  102. </if>
  103. <if test="reason != null">
  104. reason = #{reason},
  105. </if>
  106. </set>
  107. where id = #{id}
  108. </update>
  109. </mapper>