PicturesMapper.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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="PicturesMapper">
  4. <!--表名 -->
  5. <sql id="tableName">
  6. TB_PICTURES
  7. </sql>
  8. <!-- 字段 -->
  9. <sql id="Field">
  10. TITLE,
  11. NAME,
  12. PATH,
  13. CREATETIME,
  14. MASTER_ID,
  15. BZ,
  16. PICTURES_ID
  17. </sql>
  18. <!-- 字段值 -->
  19. <sql id="FieldValue">
  20. #{TITLE},
  21. #{NAME},
  22. #{PATH},
  23. #{CREATETIME},
  24. #{MASTER_ID},
  25. #{BZ},
  26. #{PICTURES_ID}
  27. </sql>
  28. <!-- 列表 -->
  29. <select id="datalistPage" parameterType="page" resultType="pd">
  30. select
  31. a.TITLE,
  32. a.NAME,
  33. a.PATH,
  34. a.CREATETIME,
  35. a.MASTER_ID,
  36. a.BZ,
  37. a.PICTURES_ID
  38. from
  39. <include refid="tableName"></include> a
  40. where 1 = 1
  41. <if test="pd.KEYW != null and pd.KEYW != ''"><!-- 关键词检索 -->
  42. and
  43. (
  44. a.TITLE LIKE CONCAT(CONCAT('%', #{pd.KEYW}),'%')
  45. or
  46. a.NAME LIKE CONCAT(CONCAT('%', #{pd.KEYW}),'%')
  47. or
  48. a.PICTURES_ID LIKE CONCAT(CONCAT('%', #{pd.KEYW}),'%')
  49. or
  50. a.MASTER_ID LIKE CONCAT(CONCAT('%', #{pd.KEYW}),'%')
  51. )
  52. </if>
  53. </select>
  54. <!-- 新增-->
  55. <insert id="save" parameterType="pd">
  56. insert into <include refid="tableName"></include>(
  57. <include refid="Field"></include>
  58. ) values (
  59. <include refid="FieldValue"></include>
  60. )
  61. </insert>
  62. <!-- 删除-->
  63. <delete id="delete" parameterType="pd">
  64. delete from <include refid="tableName"></include>
  65. where
  66. PICTURES_ID = #{PICTURES_ID}
  67. </delete>
  68. <!-- 修改 -->
  69. <update id="edit" parameterType="pd">
  70. update <include refid="tableName"></include>
  71. set
  72. TITLE = #{TITLE},
  73. PATH = #{PATH},
  74. <if test="NAME != null and NAME != ''">
  75. NAME = #{NAME},
  76. </if>
  77. MASTER_ID = #{MASTER_ID},
  78. BZ = #{BZ},
  79. PICTURES_ID = PICTURES_ID
  80. where
  81. PICTURES_ID = #{PICTURES_ID}
  82. </update>
  83. <!-- 通过ID获取数据 -->
  84. <select id="findById" parameterType="pd" resultType="pd">
  85. select
  86. <include refid="Field"></include>
  87. from
  88. <include refid="tableName"></include>
  89. where
  90. PICTURES_ID = #{PICTURES_ID}
  91. </select>
  92. <!-- 批量删除 -->
  93. <delete id="deleteAll" parameterType="String">
  94. delete from <include refid="tableName"></include>
  95. where
  96. PICTURES_ID in
  97. <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
  98. #{item}
  99. </foreach>
  100. </delete>
  101. <!-- 批量获取 -->
  102. <select id="getAllById" parameterType="String" resultType="pd">
  103. select PATH from <include refid="tableName"></include>
  104. where
  105. PICTURES_ID in
  106. <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
  107. #{item}
  108. </foreach>
  109. </select>
  110. <!-- 删除图片 -->
  111. <update id="delTp" parameterType="pd">
  112. update <include refid="tableName"></include>
  113. set
  114. PATH = ''
  115. where
  116. PICTURES_ID = #{PICTURES_ID}
  117. </update>
  118. <!-- fh QQ313596790(青苔) -->
  119. </mapper>