TableSqlMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.system.mapper.TableSqlMapper">
  6. <resultMap type="com.ruoyi.system.entity.TableSql" id="TableSqlResult">
  7. <result property="tId" column="t_id"/>
  8. <result property="tableSql" column="table_sql"/>
  9. <result property="tableCondition" column="table_condition"/>
  10. <result property="tableAlias" column="table_alias"/>
  11. <result property="sqlKey" column="sql_key"/>
  12. <result property="tableExportField" column="table_export_field"/>
  13. <result property="createBy" column="create_by"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateBy" column="update_by"/>
  16. <result property="updateTime" column="update_time"/>
  17. <result property="delFlag" column="del_flag"/>
  18. <result property="orderByColumn" column="order_by_column"/>
  19. <result property="sortOrder" column="is_asc"/>
  20. </resultMap>
  21. <sql id="selectTableSqlVo">
  22. select t_id,
  23. table_sql,
  24. table_condition,
  25. table_alias,
  26. sql_key,
  27. table_export_field,
  28. create_by,
  29. create_time,
  30. update_by,
  31. update_time,
  32. del_flag,
  33. order_by_column,
  34. is_asc
  35. from table_sql
  36. </sql>
  37. <select id="selectTableSqlList" parameterType="com.ruoyi.system.entity.TableSql" resultMap="TableSqlResult">
  38. <include refid="selectTableSqlVo"/>
  39. <where>
  40. <if test="tableSql != null and tableSql != ''">and table_sql = #{tableSql}</if>
  41. <if test="tableCondition != null and tableCondition != ''">and table_condition = #{tableCondition}</if>
  42. <if test="tableAlias != null and tableAlias != ''">and table_alias = #{tableAlias}</if>
  43. <if test="sqlKey != null and sqlKey != ''">and sql_key = #{sqlKey}</if>
  44. </where>
  45. </select>
  46. <select id="selectTableSqlByTId" parameterType="Long" resultMap="TableSqlResult">
  47. <include refid="selectTableSqlVo"/>
  48. where t_id = #{tId}
  49. </select>
  50. <select id="selectTableSqlByTSqlKey" parameterType="String" resultMap="TableSqlResult">
  51. <include refid="selectTableSqlVo"/>
  52. where sql_key = #{SQLKEY}
  53. </select>
  54. <insert id="insertTableSql" parameterType="com.ruoyi.system.entity.TableSql" useGeneratedKeys="true"
  55. keyProperty="tId">
  56. insert into table_sql
  57. <trim prefix="(" suffix=")" suffixOverrides=",">
  58. <if test="tableSql != null">table_sql,</if>
  59. <if test="tableCondition != null">table_condition,</if>
  60. <if test="tableAlias != null">table_alias,</if>
  61. <if test="sqlKey != null">sql_key,</if>
  62. <if test="tableExportField != null">table_export_field,</if>
  63. <if test="createBy != null">create_by,</if>
  64. <if test="createTime != null">create_time,</if>
  65. <if test="updateBy != null">update_by,</if>
  66. <if test="updateTime != null">update_time,</if>
  67. <if test="delFlag != null">del_flag,</if>
  68. <if test="orderByColumn != null">order_by_column,</if>
  69. <if test="sortOrder != null">is_asc,</if>
  70. </trim>
  71. <trim prefix="values (" suffix=")" suffixOverrides=",">
  72. <if test="tableSql != null">#{tableSql},</if>
  73. <if test="tableCondition != null">#{tableCondition},</if>
  74. <if test="tableAlias != null">#{tableAlias},</if>
  75. <if test="sqlKey != null">#{sqlKey},</if>
  76. <if test="tableExportField != null">#{tableExportField},</if>
  77. <if test="createBy != null">#{createBy},</if>
  78. <if test="createTime != null">#{createTime},</if>
  79. <if test="updateBy != null">#{updateBy},</if>
  80. <if test="updateTime != null">#{updateTime},</if>
  81. <if test="delFlag != null">#{delFlag},</if>
  82. <if test="orderByColumn != null">#{orderByColumn},</if>
  83. <if test="sortOrder != null">#{sortOrder},</if>
  84. </trim>
  85. </insert>
  86. <update id="updateTableSql" parameterType="com.ruoyi.system.entity.TableSql">
  87. update table_sql
  88. <trim prefix="SET" suffixOverrides=",">
  89. <if test="tableSql != null">table_sql = #{tableSql},</if>
  90. <if test="tableCondition != null">table_condition = #{tableCondition},</if>
  91. <if test="tableAlias != null">table_alias = #{tableAlias},</if>
  92. <if test="sqlKey != null">sql_key = #{sqlKey},</if>
  93. <if test="tableExportField != null">table_export_field = #{tableExportField},</if>
  94. <if test="createBy != null">create_by = #{createBy},</if>
  95. <if test="createTime != null">create_time = #{createTime},</if>
  96. <if test="updateBy != null">update_by = #{updateBy},</if>
  97. <if test="updateTime != null">update_time = #{updateTime},</if>
  98. <if test="delFlag != null">del_flag = #{delFlag},</if>
  99. <if test="orderByColumn != null">order_by_column = #{orderByColumn},</if>
  100. <if test="sortOrder != null">is_asc = #{sortOrder},</if>
  101. </trim>
  102. where t_id = #{tId}
  103. </update>
  104. <delete id="deleteTableSqlByTId" parameterType="Long">
  105. delete
  106. from table_sql
  107. where t_id = #{tId}
  108. </delete>
  109. <delete id="deleteTableSqlByTIds" parameterType="String">
  110. delete from table_sql where t_id in
  111. <foreach item="tId" collection="array" open="(" separator="," close=")">
  112. #{tId}
  113. </foreach>
  114. </delete>
  115. <update id="updateTableSqlBySqlKey">
  116. update table_sql
  117. <trim prefix="SET" suffixOverrides=",">
  118. <if test="tableSql != null">table_sql = #{tableSql},</if>
  119. <if test="tableCondition != null">table_condition = #{tableCondition},</if>
  120. <if test="tableAlias != null">table_alias = #{tableAlias},</if>
  121. <if test="tableExportField != null">table_export_field = #{tableExportField},</if>
  122. <if test="createBy != null">create_by = #{createBy},</if>
  123. <if test="createTime != null">create_time = #{createTime},</if>
  124. <if test="updateBy != null">update_by = #{updateBy},</if>
  125. <if test="updateTime != null">update_time = #{updateTime},</if>
  126. <if test="delFlag != null">del_flag = #{delFlag},</if>
  127. <if test="orderByColumn != null">order_by_column = #{orderByColumn},</if>
  128. <if test="sortOrder != null">is_asc = #{sortOrder},</if>
  129. </trim>
  130. where sql_key = #{sqlKey}
  131. </update>
  132. <delete id="deleteTableSqlBySqlKeys" parameterType="String">
  133. delete from table_sql where sql_key in
  134. <foreach item="sqlKey" collection="list" open="(" separator="," close=")">
  135. #{sqlKey}
  136. </foreach>
  137. </delete>
  138. </mapper>