UserMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.management.platform.mapper.UserMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.User">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="phone" property="phone" />
  9. <result column="password" property="password" />
  10. <result column="portrait_url" property="portraitUrl" />
  11. <result column="create_time" property="createTime" />
  12. <result column="role" property="role" />
  13. <result column="company_id" property="companyId" />
  14. <result column="department_id" property="departmentId" />
  15. <result column="department_cascade" property="departmentCascade" />
  16. <result column="cost" property="cost" />
  17. <result column="month_cost" property="monthCost" />
  18. <result column="salary_type" property="salaryType" />
  19. <result column="manage_dept_id" property="manageDeptId" />
  20. <result column="color" property="color" />
  21. <result column="is_active" property="isActive" />
  22. <result column="wx_openid" property="wxOpenid" />
  23. <result column="role_id" property="roleId" />
  24. <result column="role_name" property="roleName" />
  25. <result column="cost_apply_date" property="costApplyDate" />
  26. <result column="dingding_userid" property="dingdingUserid" />
  27. <result column="dingding_unionid" property="dingdingUnionid" />
  28. <result column="corpwx_userid" property="corpwxUserid" />
  29. <result column="inactive_date" property="inactiveDate" />
  30. </resultMap>
  31. <!-- 通用查询结果列 -->
  32. <sql id="Base_Column_List">
  33. id, name, phone, password, portrait_url, create_time, role, company_id, department_id, department_cascade, cost, month_cost, salary_type, manage_dept_id, color, is_active, wx_openid, role_id, role_name, cost_apply_date, dingding_userid, dingding_unionid, corpwx_userid, inactive_date
  34. </sql>
  35. <!--单独分页获取人员-->
  36. <select id="getUserByDepartment" resultType="java.util.Map">
  37. SELECT a.id, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  38. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  39. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive, a.cost_apply_date as costApplyDate
  40. FROM user AS a
  41. LEFT JOIN department AS b ON a.department_id = b.department_id
  42. WHERE a.company_id = #{companyId}
  43. <if test="departmentId != null and companyId != ''">
  44. AND a.department_id = #{departmentId}
  45. </if>
  46. <if test="keyword != null and keyword != ''">
  47. AND a.name like '%${keyword}%'
  48. </if>
  49. </select>
  50. <!--单独分页获取人员数量-->
  51. <select id="countUserByDepartment" resultType="java.lang.Integer">
  52. SELECT COUNT(a.id) AS count
  53. FROM user AS a
  54. WHERE a.company_id = #{companyId}
  55. <if test="departmentId != null and companyId != ''">
  56. AND a.department_id = #{departmentId}
  57. </if>
  58. <if test="keyword != null and keyword != ''">
  59. AND a.name like '%${keyword}%'
  60. </if>
  61. </select>
  62. <!--范围分页获取人员-->
  63. <select id="getUserByDepartmentList" resultType="java.util.Map">
  64. SELECT a.id, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  65. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  66. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive, a.cost_apply_date as costApplyDate
  67. FROM user AS a
  68. LEFT JOIN department AS b ON a.department_id = b.department_id
  69. WHERE a.company_id = #{companyId} AND a.department_id IN
  70. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  71. #{departmentId}
  72. </foreach>
  73. <if test="keyword != null and keyword != ''">
  74. AND a.name like '%${keyword}%'
  75. </if>
  76. </select>
  77. <!--范围分页获取人员数量-->
  78. <select id="countUserByDepartmentList" resultType="java.lang.Integer">
  79. SELECT COUNT(a.id) AS count
  80. FROM user AS a
  81. WHERE a.company_id = #{companyId} AND a.department_id IN
  82. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  83. #{departmentId}
  84. </foreach>
  85. <if test="keyword != null and keyword != ''">
  86. AND a.name like '%${keyword}%'
  87. </if>
  88. </select>
  89. <select id="getPushUserList" resultType="java.util.Map">
  90. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid, a.name, a.phone, b.department_name AS departmentName
  91. FROM user AS a LEFT JOIN department b ON a.department_id = b.department_id
  92. WHERE a.company_id = #{companyId}
  93. AND (a.wx_openid IS NOT NULL or corpwx_userid is not null)
  94. AND a.is_active = 1
  95. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
  96. </select>
  97. <!--获取项目的参与人的推送id -->
  98. <select id="getProjectPushUserList" resultType="java.util.Map">
  99. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid
  100. FROM user AS a
  101. WHERE a.wx_openid IS NOT NULL
  102. AND a.is_active = 1
  103. AND a.id in (select user_id from participation where project_id = #{projectId})
  104. </select>
  105. </mapper>