CommonMapper.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.steerinfo.dil.mapper.CommonMapper">
  4. <sql id="orderBy">
  5. <if test="orderByField!=null and orderByField !=''">
  6. order by "${orderByField}"
  7. <if test="orderByType == 'desc'">
  8. desc
  9. </if>
  10. <if test="orderByType == 'asc'">
  11. asc
  12. </if>
  13. </if>
  14. </sql>
  15. <sql id="rootCompanyFilter">
  16. <if test="rootCompanyMap != null and urlFlag != null and urlFlag != 'null' and urlFlag != ''">
  17. AND #{urlFlag} = (SELECT IS_LISTED FROM RMS_COMPANY WHERE COMPANY_ID = "rootCompanyId")
  18. </if>
  19. </sql>
  20. <sql id="filterCompanyData">
  21. <if test="roleCodes != null and roleCodes.size > 0 and dilCompanyList != null and dilCompanyList.size > 0">
  22. AND
  23. <foreach collection="roleCodes" index="index" item="item" separator="or" close=")" open="(">
  24. <choose>
  25. <when test="item == 'chengYunShang'">
  26. (
  27. "carrierId"
  28. in
  29. <foreach collection="dilCompanyList" open="(" close=")" separator=" UNION " item="item"
  30. index="index">
  31. SELECT
  32. COMPANY_ID
  33. FROM
  34. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID =
  35. #{item.companyId})
  36. </foreach>
  37. OR
  38. "shippingCompanyId"
  39. in
  40. <foreach collection="dilCompanyList" open="(" close=")" separator=" UNION " item="item"
  41. index="index">
  42. SELECT
  43. COMPANY_ID
  44. FROM
  45. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID =
  46. #{item.companyId})
  47. </foreach>
  48. OR
  49. "receivingCompanyId"
  50. in
  51. <foreach collection="dilCompanyList" open="(" close=")" separator=" UNION " item="item"
  52. index="index">
  53. SELECT
  54. COMPANY_ID
  55. FROM
  56. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID =
  57. #{item.companyId})
  58. </foreach>
  59. )
  60. </when>
  61. <when test="item == 'businessCompany'">
  62. "businessCompanyId" in(
  63. select COMPANY_ID from RMS_COMPANY where COMPANY_NAME in(select COMPANY_NAME FROM RMS_COMPANY
  64. where COMPANY_ID in
  65. <foreach collection="dilCompanyList" open="(" close=")" separator="," item="item" index="index">
  66. #{item.companyId}
  67. </foreach>
  68. ))
  69. </when>
  70. <when test="item == 'approveBusinessCompany'">
  71. "approveBusinessCompanyId"
  72. in
  73. <foreach collection="dilCompanyList" open="(" close=")" separator="," item="item" index="index">
  74. #{item.companyId}
  75. </foreach>
  76. </when>
  77. <when test="item.contains('admin')">
  78. 1 = 1
  79. </when>
  80. <when test="item.contains('siji')">
  81. 1 = 1
  82. </when>
  83. <otherwise>
  84. 1 != 1
  85. </otherwise>
  86. </choose>
  87. </foreach>
  88. </if>
  89. </sql>
  90. </mapper>