UserMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.goafanti.common.dao.UserMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.User">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="mobile" jdbcType="VARCHAR" property="mobile" />
  7. <result column="password" jdbcType="VARCHAR" property="password" />
  8. <result column="nickname" jdbcType="VARCHAR" property="nickname" />
  9. <result column="email" jdbcType="VARCHAR" property="email" />
  10. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  11. <result column="number" jdbcType="BIGINT" property="number" />
  12. <result column="type" jdbcType="INTEGER" property="type" />
  13. </resultMap>
  14. <sql id="Base_Column_List">
  15. id, mobile, password, nickname, email, create_time, number, type
  16. </sql>
  17. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  18. select
  19. <include refid="Base_Column_List" />
  20. from user
  21. where id = #{id,jdbcType=VARCHAR}
  22. </select>
  23. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  24. delete from user
  25. where id = #{id,jdbcType=VARCHAR}
  26. </delete>
  27. <insert id="insert" parameterType="com.goafanti.common.model.User">
  28. insert into user (id, mobile, password,
  29. nickname, email, create_time,
  30. number, type)
  31. values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
  32. #{nickname,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
  33. #{number,jdbcType=BIGINT}, #{type,jdbcType=INTEGER})
  34. </insert>
  35. <insert id="insertSelective" parameterType="com.goafanti.common.model.User">
  36. insert into user
  37. <trim prefix="(" suffix=")" suffixOverrides=",">
  38. <if test="id != null">
  39. id,
  40. </if>
  41. <if test="mobile != null">
  42. mobile,
  43. </if>
  44. <if test="password != null">
  45. password,
  46. </if>
  47. <if test="nickname != null">
  48. nickname,
  49. </if>
  50. <if test="email != null">
  51. email,
  52. </if>
  53. <if test="createTime != null">
  54. create_time,
  55. </if>
  56. <if test="number != null">
  57. number,
  58. </if>
  59. <if test="type != null">
  60. type,
  61. </if>
  62. </trim>
  63. <trim prefix="values (" suffix=")" suffixOverrides=",">
  64. <if test="id != null">
  65. #{id,jdbcType=VARCHAR},
  66. </if>
  67. <if test="mobile != null">
  68. #{mobile,jdbcType=VARCHAR},
  69. </if>
  70. <if test="password != null">
  71. #{password,jdbcType=VARCHAR},
  72. </if>
  73. <if test="nickname != null">
  74. #{nickname,jdbcType=VARCHAR},
  75. </if>
  76. <if test="email != null">
  77. #{email,jdbcType=VARCHAR},
  78. </if>
  79. <if test="createTime != null">
  80. #{createTime,jdbcType=TIMESTAMP},
  81. </if>
  82. <if test="number != null">
  83. #{number,jdbcType=BIGINT},
  84. </if>
  85. <if test="type != null">
  86. #{type,jdbcType=INTEGER},
  87. </if>
  88. </trim>
  89. </insert>
  90. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.User">
  91. update user
  92. <set>
  93. <if test="mobile != null">
  94. mobile = #{mobile,jdbcType=VARCHAR},
  95. </if>
  96. <if test="password != null">
  97. password = #{password,jdbcType=VARCHAR},
  98. </if>
  99. <if test="nickname != null">
  100. nickname = #{nickname,jdbcType=VARCHAR},
  101. </if>
  102. <if test="email != null">
  103. email = #{email,jdbcType=VARCHAR},
  104. </if>
  105. <if test="createTime != null">
  106. create_time = #{createTime,jdbcType=TIMESTAMP},
  107. </if>
  108. <if test="number != null">
  109. number = #{number,jdbcType=BIGINT},
  110. </if>
  111. <if test="type != null">
  112. type = #{type,jdbcType=INTEGER},
  113. </if>
  114. </set>
  115. where id = #{id,jdbcType=VARCHAR}
  116. </update>
  117. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.User">
  118. update user
  119. set mobile = #{mobile,jdbcType=VARCHAR},
  120. password = #{password,jdbcType=VARCHAR},
  121. nickname = #{nickname,jdbcType=VARCHAR},
  122. email = #{email,jdbcType=VARCHAR},
  123. create_time = #{createTime,jdbcType=TIMESTAMP},
  124. number = #{number,jdbcType=BIGINT},
  125. type = #{type,jdbcType=INTEGER}
  126. where id = #{id,jdbcType=VARCHAR}
  127. </update>
  128. <select id="selectByMobieAndType" resultMap="BaseResultMap">
  129. select
  130. <include refid="Base_Column_List" />
  131. from user
  132. where mobile = #{0} and type=#{1}
  133. </select>
  134. </mapper>