PublicAssistAdviceMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.PublicAssistAdviceMapper">
  4. <resultMap type="com.goafanti.common.model.PublicAssistAdvice" id="PublicAssistAdviceMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="prid" column="prid" jdbcType="INTEGER"/>
  7. <result property="aid" column="aid" jdbcType="VARCHAR"/>
  8. <result property="aname" column="aname" jdbcType="VARCHAR"/>
  9. <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
  10. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  11. </resultMap>
  12. <!--查询单个-->
  13. <select id="queryById" resultMap="PublicAssistAdviceMap">
  14. select
  15. id, prid, aid, aname, remarks, create_time
  16. from public_assist_advice
  17. where id = #{id}
  18. </select>
  19. <!--查询指定行数据-->
  20. <select id="findPublicAssistAdviceList" resultMap="PublicAssistAdviceMap">
  21. select
  22. id, prid, aid, aname, remarks, create_time
  23. from public_assist_advice
  24. <where>
  25. <if test="id != null">
  26. and id = #{id}
  27. </if>
  28. <if test="prid != null">
  29. and prid = #{prid}
  30. </if>
  31. <if test="aid != null and aid != ''">
  32. and aid = #{aid}
  33. </if>
  34. <if test="aname != null and aname != ''">
  35. and aname = #{aname}
  36. </if>
  37. <if test="remarks != null and remarks != ''">
  38. and remarks = #{remarks}
  39. </if>
  40. <if test="createTime != null">
  41. and create_time = #{createTime}
  42. </if>
  43. </where>
  44. limit #{pageable.offset}, #{pageable.pageSize}
  45. </select>
  46. <!--统计总行数-->
  47. <select id="findPublicAssistAdviceCount" resultType="java.lang.Integer">
  48. select count(1)
  49. from public_assist_advice
  50. <where>
  51. <if test="id != null">
  52. and id = #{id}
  53. </if>
  54. <if test="prid != null">
  55. and prid = #{prid}
  56. </if>
  57. <if test="aid != null and aid != ''">
  58. and aid = #{aid}
  59. </if>
  60. <if test="aname != null and aname != ''">
  61. and aname = #{aname}
  62. </if>
  63. <if test="remarks != null and remarks != ''">
  64. and remarks = #{remarks}
  65. </if>
  66. <if test="createTime != null">
  67. and create_time = #{createTime}
  68. </if>
  69. </where>
  70. </select>
  71. <!--新增所有列-->
  72. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  73. insert into public_assist_advice(prid, aid, aname, remarks)
  74. values (#{prid}, #{aid}, #{aname}, #{remarks})
  75. </insert>
  76. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  77. insert into public_assist_advice(prid, aid, aname, remarks, create_time)
  78. values
  79. <foreach collection="entities" item="entity" separator=",">
  80. (#{entity.prid}, #{entity.aid}, #{entity.aname}, #{entity.remarks}, #{entity.createTime})
  81. </foreach>
  82. </insert>
  83. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  84. insert into public_assist_advice(prid, aid, aname, remarks, create_time)
  85. values
  86. <foreach collection="entities" item="entity" separator=",">
  87. (#{entity.prid}, #{entity.aid}, #{entity.aname}, #{entity.remarks}, #{entity.createTime})
  88. </foreach>
  89. on duplicate key update
  90. prid = values(prid),
  91. aid = values(aid),
  92. aname = values(aname),
  93. remarks = values(remarks),
  94. create_time = values(create_time)
  95. </insert>
  96. <!--通过主键修改数据-->
  97. <update id="update">
  98. update public_assist_advice
  99. <set>
  100. <if test="prid != null">
  101. prid = #{prid},
  102. </if>
  103. <if test="aid != null and aid != ''">
  104. aid = #{aid},
  105. </if>
  106. <if test="aname != null and aname != ''">
  107. aname = #{aname},
  108. </if>
  109. <if test="remarks != null and remarks != ''">
  110. remarks = #{remarks},
  111. </if>
  112. <if test="createTime != null">
  113. create_time = #{createTime},
  114. </if>
  115. </set>
  116. where id = #{id}
  117. </update>
  118. <!--通过主键删除-->
  119. <delete id="deleteById">
  120. delete from public_assist_advice where id = #{id}
  121. </delete>
  122. <select id="selectList" resultType="com.goafanti.common.model.PublicAssistAdvice">
  123. select
  124. a.id, a.prid, a.aid, a.aname, a.remarks, a.create_time as createTime
  125. from public_assist_advice a
  126. <if test="type ==0">
  127. left join public_release b on a.prid=b.id
  128. where b.type=3 and b.id = #{id}
  129. </if>
  130. <if test="type ==1">
  131. left join public_release b on a.prid=b.id
  132. left join public_release c on b.main_id=c.id
  133. where b.type=3 and c.id = #{id}
  134. </if>
  135. </select>
  136. </mapper>