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