UserMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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.hssx.cloudmodel.mapper.UserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.hssx.cloudmodel.entity.User">
  6. <id column="id" property="id" />
  7. <result column="account" property="account" />
  8. <result column="username" property="username" />
  9. <result column="password" property="password" />
  10. <result column="mobile" property="mobile" />
  11. <result column="role_type" property="roleType" />
  12. <result column="company_id" property="companyId" />
  13. <result column="parent_id" property="parentId" />
  14. <result column="sex" property="sex" />
  15. <result column="role_name" property="roleName" />
  16. <result column="work_state" property="workState" />
  17. <result column="is_disable" property="isDisable" />
  18. <result column="indate" property="indate" />
  19. <result column="head_imgurl" property="headImgurl" />
  20. <result column="team_name" property="teamName" />
  21. <result column="subordinate_type" property="subordinateType" />
  22. <result column="openid" property="openid" />
  23. </resultMap>
  24. <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.UserVO">
  25. <id column="id" property="id" />
  26. <result column="account" property="account" />
  27. <result column="username" property="username" />
  28. <result column="password" property="password" />
  29. <result column="mobile" property="mobile" />
  30. <result column="role_type" property="roleType" />
  31. <result column="role_name" property="roleName" />
  32. <result column="company_id" property="companyId" />
  33. <result column="company_name" property="companyName"/>
  34. <result column="parent_id" property="parentId" />
  35. <result column="sex" property="sex" />
  36. <result column="work_state" property="workState" />
  37. <result column="is_disable" property="isDisable" />
  38. <result column="indate" property="indate" />
  39. <result column="head_imgurl" property="headImgurl" />
  40. <result column="team_name" property="teamName" />
  41. <result column="subordinate_type" property="subordinateType" />
  42. </resultMap>
  43. <!-- 通用查询结果列 -->
  44. <sql id="Base_Column_List">
  45. id, account, username, password, mobile, role_type, company_id, parent_id, sex, role_name, work_state, is_disable, indate, head_imgurl, team_name, subordinate_type, openid
  46. </sql>
  47. <select id="selsctUsersByUids" resultMap="BaseResultMapVO">
  48. SELECT
  49. u.id id, u.username username, u.mobile mobile, u.company_id company_id, c.`company_name` company_name,
  50. u.parent_id parent_id, u.work_state work_state, u.is_disable is_disable,
  51. u.indate indate, u.head_imgurl head_imgurl, u.team_name team_name, u.subordinate_type subordinate_type
  52. FROM
  53. tb_user AS u
  54. LEFT JOIN tb_company c
  55. ON u.company_id = c.`id`
  56. <where>
  57. <foreach collection="list" separator="," close=")" item="item" open="u.id in (" index="index">
  58. #{item}
  59. </foreach>
  60. and u.id != #{id}
  61. </where>
  62. </select>
  63. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  64. SELECT
  65. u.id id, u.account account, u.username username, u.password password, u.mobile mobile, u.role_type role_type, u.company_id company_id, c.`company_name` company_name,
  66. u.role_name role_name,u.parent_id parent_id, u.sex sex, u.work_state work_state, u.is_disable is_disable,
  67. u.indate indate, u.head_imgurl head_imgurl, u.team_name team_name, u.subordinate_type subordinate_type
  68. FROM
  69. tb_user AS u
  70. LEFT JOIN tb_company c
  71. ON u.company_id = c.`id`
  72. <where>
  73. u.id != #{user.id}
  74. <if test="user.id != 1">
  75. AND u.parent_id = #{user.id}
  76. </if>
  77. <if test="flag==0 and keyName != '' and keyName !=null">
  78. AND u.username like concat('%',#{keyName},'%')
  79. </if>
  80. <if test="flag==1 and keyName != '' and keyName !=null">
  81. AND u.account like concat('%',#{keyName},'%')
  82. </if>
  83. <if test="companyId != -1">
  84. AND u.company_id = #{companyId}
  85. </if>
  86. </where>
  87. Order by u.id desc
  88. </select>
  89. <select id="selectUserListByCondition" resultMap="BaseResultMapVO">
  90. SELECT
  91. u.id id, u.account account, u.username username, u.password password, u.mobile mobile, u.role_type role_type, u.company_id company_id, c.`company_name` company_name,
  92. u.role_name role_name,u.parent_id parent_id, u.sex sex, u.work_state work_state, u.is_disable is_disable,
  93. u.indate indate, u.head_imgurl head_imgurl, u.team_name team_name, u.subordinate_type subordinate_type
  94. FROM
  95. tb_user AS u
  96. LEFT JOIN tb_company c
  97. ON u.company_id = c.`id`
  98. <where>
  99. u.id in
  100. <foreach collection="list" index="index" open="(" item="item" close=")" separator=",">
  101. #{item}
  102. </foreach>
  103. and u.id != #{user.id}
  104. <if test="flag==0 and keyName != '' and keyName !=null">
  105. AND u.username like concat('%',#{keyName},'%')
  106. </if>
  107. <if test="flag==1 and keyName != '' and keyName !=null">
  108. AND u.account like concat('%',#{keyName},'%')
  109. </if>
  110. <if test="companyId != -1">
  111. AND u.company_id = #{companyId}
  112. </if>
  113. </where>
  114. Order by u.id desc
  115. </select>
  116. <select id="getUserByAccount" resultMap="BaseResultMapVO">
  117. select
  118. u.id id, u.account account, u.username username, u.password password, u.mobile mobile, u.role_type role_type, u.company_id company_id, c.`company_name` company_name,
  119. u.role_name role_name,u.parent_id parent_id, u.sex sex, u.work_state work_state, u.is_disable is_disable,
  120. u.indate indate, u.head_imgurl head_imgurl, u.team_name team_name, u.subordinate_type subordinate_type
  121. from
  122. tb_user AS u
  123. LEFT JOIN tb_company c
  124. ON u.company_id = c.`id`
  125. where
  126. u.account = #{userVO.account}
  127. </select>
  128. </mapper>