CertificationMapper.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. <delete id="deleteById">
  35. delete from certification
  36. where id = #{id}
  37. </delete>
  38. <insert id="insert" parameterType="com.example.entity.Certification" useGeneratedKeys="true">
  39. insert into certification
  40. <trim prefix="(" suffix=")" suffixOverrides=",">
  41. <if test="id != null">id,</if>
  42. <if test="userId != null">user_id,</if>
  43. <if test="name != null">name,</if>
  44. <if test="avatar != null">avatar,</if>
  45. <if test="phone != null">phone,</if>
  46. <if test="cardNo != null">card_no,</if>
  47. <if test="card1 != null">card1,</if>
  48. <if test="card2 != null">card2,</if>
  49. <if test="address != null">address,</if>
  50. <if test="status != null">status,</if>
  51. <if test="reason != null">reason,</if>
  52. </trim>
  53. <trim prefix="values (" suffix=")" suffixOverrides=",">
  54. <if test="id != null">#{id},</if>
  55. <if test="userId != null">#{userId},</if>
  56. <if test="name != null">#{name},</if>
  57. <if test="avatar != null">#{avatar},</if>
  58. <if test="phone != null">#{phone},</if>
  59. <if test="cardNo != null">#{cardNo},</if>
  60. <if test="card1 != null">#{card1},</if>
  61. <if test="card2 != null">#{card2},</if>
  62. <if test="address != null">#{address},</if>
  63. <if test="status != null">#{status},</if>
  64. <if test="reason != null">#{reason},</if>
  65. </trim>
  66. </insert>
  67. <update id="updateById" parameterType="com.example.entity.Certification">
  68. update certification
  69. <set>
  70. <if test="userId != null">
  71. user_id = #{userId},
  72. </if>
  73. <if test="name != null">
  74. name = #{name},
  75. </if>
  76. <if test="avatar != null">
  77. avatar = #{avatar},
  78. </if>
  79. <if test="phone != null">
  80. phone = #{phone},
  81. </if>
  82. <if test="cardNo != null">
  83. card_no = #{cardNo},
  84. </if>
  85. <if test="card1 != null">
  86. card1 = #{card1},
  87. </if>
  88. <if test="card2 != null">
  89. card2 = #{card2},
  90. </if>
  91. <if test="address != null">
  92. address = #{address},
  93. </if>
  94. <if test="status != null">
  95. status = #{status},
  96. </if>
  97. <if test="reason != null">
  98. reason = #{reason},
  99. </if>
  100. </set>
  101. where id = #{id}
  102. </update>
  103. </mapper>