UserMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. <result column="position" property="position" />
  31. </resultMap>
  32. <!-- 通用查询结果列 -->
  33. <sql id="Base_Column_List">
  34. 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, position
  35. </sql>
  36. <!--单独分页获取人员-->
  37. <select id="getUserByDepartment" resultType="java.util.Map">
  38. SELECT a.id, a.role_id as roleId, a.role_name as roleName, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  39. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  40. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive, a.cost_apply_date as costApplyDate
  41. FROM user AS a
  42. LEFT JOIN department AS b ON a.department_id = b.department_id
  43. WHERE a.company_id = #{companyId}
  44. <if test="departmentId != null and companyId != ''">
  45. AND a.department_id = #{departmentId}
  46. </if>
  47. <if test="keyword != null and keyword != ''">
  48. AND a.name like '%${keyword}%'
  49. </if>
  50. <if test="status != null">
  51. AND a.is_active = #{status}
  52. </if>
  53. <if test="roleId != null">
  54. AND a.role_id = #{roleId}
  55. </if>
  56. </select>
  57. <!--范围分页获取人员-->
  58. <select id="getUserByDepartmentList" resultType="java.util.Map">
  59. SELECT a.id, a.role_id as roleId, a.role_name as roleName, a.name, a.phone, a.portrait_url AS portraitUrl, a.role, a.company_id AS companyId, a.cost,
  60. a.department_id AS departmentId, b.department_name AS departmentName, a.department_cascade AS departmentCascade,
  61. a.month_cost as monthCost, a.salary_type as salaryType, a.is_active as isActive, a.cost_apply_date as costApplyDate
  62. FROM user AS a
  63. LEFT JOIN department AS b ON a.department_id = b.department_id
  64. WHERE a.company_id = #{companyId} AND a.department_id IN
  65. <foreach collection="departmentIds" item="departmentId" index="index" open="(" close=")" separator=",">
  66. #{departmentId}
  67. </foreach>
  68. <if test="keyword != null and keyword != ''">
  69. AND a.name like '%${keyword}%'
  70. </if>
  71. <if test="status != null">
  72. AND a.is_active = #{status}
  73. </if>
  74. <if test="roleId != null">
  75. AND a.role_id = #{roleId}
  76. </if>
  77. </select>
  78. <select id="getPushUserList" resultType="java.util.Map">
  79. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid, a.name, a.phone, b.department_name AS departmentName
  80. FROM user AS a LEFT JOIN department b ON a.department_id = b.department_id
  81. WHERE a.company_id = #{companyId}
  82. AND (a.wx_openid IS NOT NULL or corpwx_userid is not null)
  83. AND a.is_active = 1
  84. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
  85. </select>
  86. <select id="getPushDingdingUserList" resultType="java.util.Map">
  87. SELECT a.company_id as companyId, a.dingding_userid as dingdingUserid
  88. FROM user AS a left join time_type on time_type.company_id = a.company_id
  89. WHERE a.dingding_userid is not null and time_type.alert_time = #{alertTime}
  90. AND a.is_active = 1
  91. AND NOT EXISTS(SELECT 1 FROM report WHERE report.`creator_id` = a.id AND report.`create_date` = DATE_FORMAT(NOW(), '%Y-%m-%d'))
  92. order by a.company_id
  93. </select>
  94. <!--获取项目的参与人的推送id -->
  95. <select id="getProjectPushUserList" resultType="java.util.Map">
  96. SELECT a.id, a.wx_openid as wxOpenid, a.corpwx_userid as corpwxUserid
  97. FROM user AS a
  98. WHERE a.wx_openid IS NOT NULL
  99. AND a.is_active = 1
  100. AND a.id in (select user_id from participation where project_id = #{projectId})
  101. </select>
  102. <select id="getSimpleNameList" resultType="java.util.HashMap">
  103. select id, name from user
  104. ${ew.customSqlSegment}
  105. </select>
  106. </mapper>