PublicAssistDetailsMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.goafanti.common.dao.PublicAssistDetailsMapper">
  4. <resultMap type="com.goafanti.common.model.PublicAssistDetails" id="PublicAssistDetailsMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="prid" column="prid" jdbcType="INTEGER"/>
  7. <result property="type" column="type" jdbcType="VARCHAR"/>
  8. <result property="contentType" column="content_type" jdbcType="VARCHAR"/>
  9. <result property="content" column="content" jdbcType="VARCHAR"/>
  10. </resultMap>
  11. <sql id="PublicAssistDetailsAllSql">
  12. id, prid, type, content_type, content
  13. </sql>
  14. <!--查询单个-->
  15. <select id="selectById" resultMap="PublicAssistDetailsMap">
  16. select
  17. <include refid="PublicAssistDetailsAllSql"/>
  18. from public_assist_details
  19. where id = #{id}
  20. </select>
  21. <!--新增所有列-->
  22. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  23. insert into public_assist_details(prid, type, content_type, content)
  24. values (#{prid}, #{type}, #{contentType}, #{content})
  25. </insert>
  26. <insert id="insertBatch">
  27. insert into public_assist_details(prid, type, content_type, content)
  28. values
  29. <foreach collection="entities" item="entity" separator=",">
  30. (#{entity.prid}, #{entity.type}, #{entity.contentType}, #{entity.content})
  31. </foreach>
  32. </insert>
  33. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  34. insert into public_assist_details(prid, type, content_type, content)
  35. values
  36. <foreach collection="entities" item="entity" separator=",">
  37. (#{entity.prid}, #{entity.type}, #{entity.contentType}, #{entity.content})
  38. </foreach>
  39. on duplicate key update
  40. prid = values(prid),
  41. type = values(type),
  42. content_type = values(content_type),
  43. content = values(content)
  44. </insert>
  45. <!--通过主键修改数据-->
  46. <update id="update">
  47. update public_assist_details
  48. <set>
  49. <if test="prid != null">
  50. prid = #{prid},
  51. </if>
  52. <if test="type != null and type != ''">
  53. type = #{type},
  54. </if>
  55. <if test="contentType != null and contentType != ''">
  56. content_type = #{contentType},
  57. </if>
  58. <if test="content != null and content != ''">
  59. content = #{content},
  60. </if>
  61. </set>
  62. where id = #{id}
  63. </update>
  64. <!--查询指定行数据-->
  65. <select id="findPublicAssistDetailsList" resultMap="PublicAssistDetailsMap">
  66. select
  67. <include refid="PublicAssistDetailsAllSql"/>
  68. from public_assist_details
  69. <where>
  70. <if test="id != null">
  71. and id = #{id}
  72. </if>
  73. <if test="prid != null">
  74. and prid = #{prid}
  75. </if>
  76. <if test="type != null and type != ''">
  77. and type = #{type}
  78. </if>
  79. <if test="contentType != null and contentType != ''">
  80. and content_type = #{contentType}
  81. </if>
  82. <if test="content != null and content != ''">
  83. and content = #{content}
  84. </if>
  85. </where>
  86. <if test="page_sql != null">
  87. ${page_sql}
  88. </if>
  89. </select>
  90. <!--统计总行数-->
  91. <select id="findPublicAssistDetailsCount" resultType="java.lang.Integer">
  92. select count(1)
  93. from public_assist_details
  94. <where>
  95. <if test="id != null">
  96. and id = #{id}
  97. </if>
  98. <if test="prid != null">
  99. and prid = #{prid}
  100. </if>
  101. <if test="type != null and type != ''">
  102. and type = #{type}
  103. </if>
  104. <if test="contentType != null and contentType != ''">
  105. and content_type = #{contentType}
  106. </if>
  107. <if test="content != null and content != ''">
  108. and content = #{content}
  109. </if>
  110. </where>
  111. </select>
  112. <!--通过主键删除-->
  113. <delete id="deleteById">
  114. delete
  115. from public_assist_details
  116. where id = #{id}
  117. </delete>
  118. <select id="selectByPrid" resultMap="PublicAssistDetailsMap">
  119. select
  120. <include refid="PublicAssistDetailsAllSql"/>
  121. from public_assist_details
  122. where prid = #{id}
  123. </select>
  124. <delete id="deeleteByPrid">
  125. delete
  126. from public_assist_details
  127. where prid = #{id}
  128. </delete>
  129. </mapper>