CommonMapper.xml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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" index="index">
  30. SELECT
  31. COMPANY_ID
  32. FROM
  33. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID =
  34. #{item.companyId})
  35. </foreach>
  36. OR
  37. "shippingCompanyId"
  38. in
  39. <foreach collection="dilCompanyList" open="(" close=")" separator=" UNION " item="item" index="index">
  40. SELECT
  41. COMPANY_ID
  42. FROM
  43. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID = #{item.companyId})
  44. </foreach>
  45. OR
  46. "receivingCompanyId"
  47. in
  48. <foreach collection="dilCompanyList" open="(" close=")" separator=" UNION " item="item" index="index">
  49. SELECT
  50. COMPANY_ID
  51. FROM
  52. RMS_COMPANY WHERE COMPANY_NAME IN ( SELECT COMPANY_NAME FROM RMS_COMPANY WHERE COMPANY_ID = #{item.companyId})
  53. </foreach>
  54. )
  55. </when>
  56. <when test="item == 'businessCompany'">
  57. "businessCompanyId"
  58. in
  59. <foreach collection="dilCompanyList" open="(" close=")" separator="," item="item" index="index">
  60. #{item.companyId}
  61. </foreach>
  62. </when>
  63. <when test="item == 'approveBusinessCompany'">
  64. "approveBusinessCompanyId"
  65. in
  66. <foreach collection="dilCompanyList" open="(" close=")" separator="," item="item" index="index">
  67. #{item.companyId}
  68. </foreach>
  69. </when>
  70. <when test="item.contains('admin')">
  71. 1 = 1
  72. </when>
  73. <when test="item.contains('siji')">
  74. 1 = 1
  75. </when>
  76. <otherwise>
  77. 1 != 1
  78. </otherwise>
  79. </choose>
  80. </foreach>
  81. </if>
  82. </sql>
  83. </mapper>