PositionMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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.tofly.base.mapper.PositionMapper">
  4. <resultMap id="positionMap" type="com.tofly.base.entity.Position">
  5. <id property="id" column="ID"/>
  6. <!--<result property="name" column="NAME"/>-->
  7. <result property="category" column="CATEGORY"/>
  8. <!--<result property="head" column="HEAD"/>-->
  9. <!--<result property="deptaudit" column="DEPTAUDIT"/>-->
  10. <result property="departmentId" column="DEPARTMENT_ID"/>
  11. <result property="userId" column="USER_ID"/>
  12. <result property="createUser" column="CREATE_USER"/>
  13. <result property="createDate" column="CREATE_DATE"/>
  14. <!--<association property="position" column="category" javaType="com.tofly.base.entity.Code" select="getName"></association>-->
  15. <association property="pname" column="category" javaType="java.lang.String" select="getpName"></association>
  16. </resultMap>
  17. <select id="getName" resultType="com.tofly.base.entity.Code" parameterType="java.lang.String" databaseId="oracle">
  18. select * from tf_smpn_code_x where key='position' and value=#{category}
  19. </select>
  20. <select id="getName" resultType="com.tofly.base.entity.Code" parameterType="java.lang.String" databaseId="mysql">
  21. select * from TF_SMPN_CODE_X where `key`='position' and `value`=#{category}
  22. </select>
  23. <select id="getpName" resultType="string" parameterType="java.lang.String" databaseId="oracle">
  24. select notes from tf_smpn_code_x where key='position' and value=#{category}
  25. </select>
  26. <select id="getpName" resultType="string" parameterType="java.lang.String" databaseId="mysql">
  27. select notes from TF_SMPN_CODE_X where `key`='position' and `value`=#{category}
  28. </select>
  29. <select id="getPosition" resultType="map" databaseId="oracle">
  30. select t.*,
  31. (select notes from tf_smpn_code_x c where c.key = 'position' and value=t.CATEGORY) as category_name,
  32. (select username from tf_smpn_user_x where id=t.user_id) username,
  33. (select real_name from tf_smpn_user_x where id=t.user_id) real_name
  34. from tf_smpn_position_x t
  35. where 1=1
  36. <if test="map.username != null and map.username.trim() != ''">
  37. and exists (select 1 from tf_smpn_user_x where id=t.user_id
  38. and (username like '%'||#{map.username}||'%' or real_name like '%'||#{map.username}||'%'))
  39. </if>
  40. <if test="map.category != null and map.category.trim() != ''">
  41. and category=#{map.category}
  42. </if>
  43. <if test="map.userId != null and map.userId!= 0">
  44. and user_id=#{map.userId}
  45. </if>
  46. </select>
  47. <select id="getPosition" resultType="map" databaseId="mysql">
  48. select t.*,
  49. (select notes from TF_SMPN_CODE_X c where c.`key` = 'position' and `value`=t.CATEGORY) as category_name,
  50. (select username from TF_SMPN_USER_X where id=t.user_id) username,
  51. (select real_name from TF_SMPN_USER_X where id=t.user_id) real_name
  52. from TF_SMPN_POSITION_X t
  53. where 1=1
  54. <if test="map.username != null and map.username.trim() != ''">
  55. and exists (select 1 from TF_SMPN_USER_X where id=t.user_id
  56. and (username like CONCAT('%',#{map.username},'%') or real_name like CONCAT('%',#{map.username},'%')))
  57. </if>
  58. <if test="map.category != null and map.category.trim() != ''">
  59. and category=#{map.category}
  60. </if>
  61. <if test="map.userId != null and map.userId!= 0">
  62. and user_id=#{map.userId}
  63. </if>
  64. </select>
  65. <select id="getAllUserPosition" resultType="map" databaseId="oracle">
  66. select id,
  67. username,
  68. phone,
  69. avatar,
  70. department_id,
  71. create_time,
  72. update_time,
  73. lock_flag,
  74. status_flag,
  75. wx_openid,
  76. qq_openid,
  77. email,
  78. real_name,
  79. login_time,
  80. last_ip,
  81. pwderrtimes,
  82. worknumber,
  83. findpwdkey,
  84. aliasname,
  85. birthday,
  86. belong,
  87. create_user,
  88. (select count(1) from tf_smpn_position_x p where t.id = p.user_id) category_count,
  89. to_char((select wmsys.wm_concat(c.notes)
  90. from tf_smpn_code_x c, tf_smpn_position_x p
  91. where t.id = p.user_id
  92. and p.category = c.value
  93. and c.key = 'position')) as category_name
  94. from tf_smpn_user_x t
  95. </select>
  96. <select id="getAllUserPosition" resultType="map" databaseId="mysql">
  97. select id,
  98. username,
  99. phone,
  100. avatar,
  101. department_id,
  102. create_time,
  103. update_time,
  104. lock_flag,
  105. status_flag,
  106. wx_openid,
  107. qq_openid,
  108. email,
  109. real_name,
  110. login_time,
  111. last_ip,
  112. pwderrtimes,
  113. worknumber,
  114. findpwdkey,
  115. aliasname,
  116. birthday,
  117. belong,
  118. create_user,
  119. (select count(1) from TF_SMPN_POSITION_X p where t.id = p.user_id) category_count,
  120. (select group_concat(c.notes)
  121. from TF_SMPN_CODE_X c, TF_SMPN_POSITION_X p
  122. where t.id = p.user_id
  123. and p.category = c.`value`
  124. and c.`key` = 'position' group by c.`key`) as category_name
  125. from TF_SMPN_USER_X t
  126. </select>
  127. </mapper>