CommonMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.common.mapper.CommonMapper">
  5. <resultMap id="GetResultMap" type="com.zhyc.xps.common.vo.GroupVo" >
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
  7. <result column="group_id" property="groupId" jdbcType="BIGINT" /><!--群组ID-->
  8. <result column="group_name" property="groupName" jdbcType="VARCHAR" /><!--群组Name-->
  9. <result column="group_code" property="groupCode" jdbcType="VARCHAR" /><!--群组Code-->
  10. <result column="group_cat_id" property="groupCatId" jdbcType="BIGINT" /><!--群组类别ID-->
  11. <result column="parent_id" property="parentId" jdbcType="BIGINT" /><!--父群组-->
  12. <result column="root_id" property="rootId" jdbcType="BIGINT" /><!--根群组ID-->
  13. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" /><!--Node Left-->
  14. <result column="node_right" property="nodeRight" jdbcType="BIGINT" /><!--Node Right-->
  15. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" /><!--Node Leve-->
  16. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" /><!--Leaf-->
  17. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" /><!--是否可删除-->
  18. <result column="group_desc" property="groupDesc" jdbcType="VARCHAR" /><!--描述-->
  19. <result column="group_select" property="groupSelect" jdbcType="VARCHAR" /><!--供首字母等检索用-->
  20. <result column="parent_name" property="parentName" jdbcType="VARCHAR" />
  21. <result column="group_cat_title" property="groupCatTitle" jdbcType="VARCHAR" />
  22. </resultMap>
  23. <sql id="GroupVo_Cols">
  24. A.oc_id,
  25. A.group_id,
  26. A.group_name,
  27. A.group_code,
  28. A.group_cat_id,
  29. C.group_cat_title,
  30. A.node_left,
  31. A.node_right,
  32. A.parent_id,
  33. A.root_id,
  34. B.group_name as parent_name,
  35. A.node_level,
  36. A.is_leaf,
  37. A.is_fixed,
  38. A.group_desc
  39. </sql>
  40. <!--根据ID获取群组信息-->
  41. <select id="getGroupById" resultMap="GetResultMap">
  42. SELECT
  43. <include refid="GroupVo_Cols"/>
  44. FROM s_group AS A
  45. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id )
  46. LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
  47. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT} AND A.deleted_flag = 0 AND A.group_id = #{groupId ,jdbcType=BIGINT}
  48. </select>
  49. <!--根据条件返回相应的群组列表-->
  50. <select id="getGroupByList" parameterType="java.util.Map" resultMap="GetResultMap">
  51. SELECT
  52. <include refid="GroupVo_Cols"/>
  53. FROM s_group AS A
  54. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.parent_id = B.group_id)
  55. LEFT JOIN s_group_cat AS C ON (A.oc_id = C.oc_id AND A.group_cat_id = C.group_cat_id)
  56. WHERE A.oc_id = #{ocId,jdbcType=BIGINT} AND A.deleted_flag = 0
  57. <if test="nodeLeft != null and nodeRight != null">
  58. <![CDATA[
  59. AND A.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  60. AND A.node_right <= #{nodeRight ,jdbcType=BIGINT}
  61. ]]>
  62. </if>
  63. <if test="groupCatId!=null">
  64. AND A.group_cat_id = #{groupCatId ,jdbcType=BIGINT}
  65. </if>
  66. <if test="groupId !=null">
  67. AND A.group_id = #{groupId,jdbcType=BIGINT}
  68. </if>
  69. <if test="parentId != null">
  70. AND A.parent_id = #{parentId, jdbcType=BIGINT}
  71. </if>
  72. <if test="keywords != null and keywords != ''">
  73. AND ( A.group_name LIKE "%"#{keywords}"%"
  74. </if>
  75. </select>
  76. <resultMap id="GroupMemberDoResultMap" type="com.zhyc.xps.common.vo.GroupMemberVo">
  77. <result column="gm_id" property="gmId" jdbcType="BIGINT" /><!--群组成员ID-->
  78. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--公司机构ID-->
  79. <result column="group_id" property="groupId" jdbcType="BIGINT" /><!--群组ID-->
  80. <result column="account_id" property="accountId" jdbcType="BIGINT" /><!--帐号ID-->
  81. </resultMap>
  82. <sql id="GroupMemberVo_Cols">
  83. A.gm_id,
  84. A.oc_id,
  85. A.group_id,
  86. A.account_id
  87. </sql>
  88. <!--条件列表查询-->
  89. <select id="getGroupMemberByList" parameterType="java.util.Map" resultMap="GroupMemberDoResultMap">
  90. SELECT
  91. <include refid="GroupMemberVo_Cols"/>
  92. FROM s_group_member AS A
  93. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.group_id = B.group_id)
  94. WHERE B.deleted_flag = 0
  95. <if test="ocId != null">
  96. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  97. </if>
  98. <if test="nodeLeft != null and nodeRight != null">
  99. <![CDATA[
  100. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  101. AND B.node_right <= #{nodeRight,jdbcType=BIGINT}
  102. ]]>
  103. </if>
  104. </select>
  105. </mapper>