UserMapper.xml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. 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
  26. </sql>
  27. <resultMap id="BaseResultMapVO" type="com.hssx.cloudmodel.entity.vo.UserVO">
  28. <id column="id" property="id" />
  29. <result column="account" property="account" />
  30. <result column="username" property="username" />
  31. <result column="password" property="password" />
  32. <result column="mobile" property="mobile" />
  33. <result column="role_type" property="roleType" />
  34. <result column="role_name" property="roleName" />
  35. <result column="company_id" property="companyId" />
  36. <result column="company_name" property="companyName"/>
  37. <result column="parent_id" property="parentId" />
  38. <result column="sex" property="sex" />
  39. <result column="work_state" property="workState" />
  40. <result column="is_disable" property="isDisable" />
  41. <result column="indate" property="indate" />
  42. <result column="head_imgurl" property="headImgurl" />
  43. <result column="team_name" property="teamName" />
  44. <result column="subordinate_type" property="subordinateType" />
  45. </resultMap>
  46. <select id="selectListByCondition" resultMap="BaseResultMapVO">
  47. SELECT
  48. 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,
  49. u.role_name role_name,u.parent_id parent_id, u.sex sex, u.work_state work_state, u.is_disable is_disable,
  50. u.indate indate, u.head_imgurl head_imgurl, u.team_name team_name, u.subordinate_type subordinate_type
  51. FROM
  52. tb_user AS u
  53. LEFT JOIN tb_company c
  54. ON u.company_id = c.`id`
  55. <where>
  56. u.id != #{user.id}
  57. <if test="user.id != 1">
  58. AND u.parent_id = #{user.id}
  59. </if>
  60. <if test="flag==0 and keyName != '' and keyName !=null">
  61. AND u.username like concat('%',#{keyName},'%')
  62. </if>
  63. <if test="flag==1 and keyName != '' and keyName !=null">
  64. AND u.account like concat('%',#{keyName},'%')
  65. </if>
  66. <if test="companyId != -1">
  67. AND u.company_id = #{companyId}
  68. </if>
  69. </where>
  70. Order by u.id desc
  71. </select>
  72. </mapper>