CommonMapper.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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.CommonMapper">
  6. <resultMap id="retMap" type="com.ruoyi.system.entity.CommonEntity" autoMapping="true">
  7. <collection property="resultMap" ofType="map" autoMapping="true"
  8. javaType="map"></collection>
  9. </resultMap>
  10. <select id="selectList" resultMap="retMap">
  11. select * from ${tableName}
  12. <where>
  13. <if test="conditions != null">
  14. <foreach collection="conditions" item="value" index="key" separator="and">
  15. ${key}=#{value}
  16. </foreach>
  17. </if>
  18. </where>
  19. </select>
  20. <select id="queryTableList" resultMap="retMap">
  21. ${Sql}
  22. </select>
  23. <insert id="batchInsert">
  24. insert into ${tableName}
  25. <foreach collection="fieldNames" item="fieldName" open="(" close=")" separator=",">
  26. ${fieldName}
  27. </foreach>
  28. values
  29. <foreach collection="fieldValues" item="map" separator=",">
  30. <foreach collection="map" item="value" index="key" separator="," open="(" close=")">
  31. #{value}
  32. </foreach>
  33. </foreach>
  34. </insert>
  35. <delete id="batchDelete">
  36. update ${tableName} set del_flag = '2'
  37. <where>
  38. <if test="conditions != null">
  39. <foreach collection="conditions" item="value" index="key" separator="and">
  40. ${key} in
  41. <foreach collection="value" item="v" open="(" close=")" separator=",">
  42. #{v}
  43. </foreach>
  44. </foreach>
  45. </if>
  46. </where>
  47. </delete>
  48. <update id="edit">
  49. update ${tableName} set
  50. <foreach collection="fields" item="field" index="key" separator=",">
  51. ${key}=#{field}
  52. </foreach>
  53. <where>
  54. <if test="conditions != null">
  55. <foreach collection="conditions" item="value" index="key" separator="and">
  56. ${key}=#{value}
  57. </foreach>
  58. </if>
  59. </where>
  60. </update>
  61. <select id="selectDropDownList" resultType="map">
  62. select ${fieldKey} as fieldKey,${fieldName} as fieldName from ${tableName}
  63. <where>
  64. <if test="conditions != null">
  65. <foreach collection="conditions" item="value" index="key" separator="and">
  66. ${key}=#{value}
  67. </foreach>
  68. </if>
  69. </where>
  70. </select>
  71. <select id="selectDropDownListByDict" resultType="map">
  72. select dict_value as fieldKey,dict_label as fieldName from sys_dict_data where dict_type = #{dictType} and status = '0'
  73. </select>
  74. </mapper>