UserMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.jkcredit.invoice.mapper.user.UserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="baseResultMap" type="com.jkcredit.invoice.model.entity.user.User">
  6. <id column="id" property="id"/>
  7. <result column="user_name" property="userName"/>
  8. <result column="password" property="password"/>
  9. <result column="name" property="name"/>
  10. <result column="phone" property="phone"/>
  11. <result column="company" property="company"/>
  12. <result column="role_id" property="roleId"/>
  13. <result column="role_name" property="roleName"/>
  14. <result column="create_time" property="createTime"/>
  15. <result column="is_lock" property="isLock"/>
  16. <result column="company_num" property="companyNum"/>
  17. </resultMap>
  18. <sql id="userSql">
  19. id,
  20. user_name,
  21. `name`,
  22. company_num,
  23. phone,
  24. company,
  25. role_id,
  26. password,
  27. role_name,
  28. create_time,
  29. is_lock
  30. </sql>
  31. <select id="getUserByUserName" resultMap="baseResultMap">
  32. SELECT
  33. <include refid="userSql" />
  34. FROM
  35. t_user
  36. WHERE user_name = BINARY #{userName}
  37. </select>
  38. <select id="getAllUser" resultMap="baseResultMap">
  39. SELECT
  40. <include refid="userSql" />
  41. FROM
  42. t_user
  43. ORDER by id desc
  44. </select>
  45. <select id="getUserById" resultMap="baseResultMap">
  46. SELECT
  47. <include refid="userSql" />
  48. FROM
  49. t_user
  50. WHERE
  51. id = #{id}
  52. </select>
  53. <select id="getUsersPage" resultMap="baseResultMap">
  54. SELECT
  55. <include refid="userSql"/>
  56. FROM
  57. t_user
  58. <where>
  59. <if test="query.userName != null and query.userName != ''">
  60. and user_name = BINARY #{query.userName}
  61. </if>
  62. <if test="query.company != null and query.company != ''">
  63. and company LIKE BINARY CONCAT('%',#{query.company},'%')
  64. </if>
  65. </where>
  66. order by create_time desc
  67. </select>
  68. <update id="updatePassword">
  69. UPDATE
  70. t_user
  71. SET
  72. password = #{password, jdbcType=VARCHAR}
  73. WHERE
  74. id = #{id}
  75. </update>
  76. <update id="updateLock">
  77. UPDATE
  78. t_user
  79. SET
  80. is_lock = #{isLock}
  81. WHERE
  82. id = #{id}
  83. </update>
  84. <update id="updateCompanyNumById">
  85. UPDATE
  86. t_user
  87. SET
  88. company_num = #{companyNum}
  89. WHERE
  90. id = #{id}
  91. </update>
  92. <update id="updateUserInfo">
  93. UPDATE
  94. t_user
  95. <set>
  96. <if test="name != null and name != ''">
  97. `name` = #{name},
  98. </if>
  99. <if test="phone != null and phone != ''">
  100. phone = #{phone},
  101. </if>
  102. <if test="company != null and company != ''">
  103. company = #{company},
  104. </if>
  105. <if test="roleId != null and roleId != ''">
  106. role_id = #{roleId},
  107. </if>
  108. <if test="roleName != null and roleName != ''">
  109. role_name = #{roleName}
  110. </if>
  111. </set>
  112. WHERE
  113. id = #{id}
  114. </update>
  115. </mapper>