PrjResponsibleDao.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.liang.dao.PrjResponsibleDao">
  4. <resultMap type="com.liang.entity.PrjResponsible" id="PrjResponsibleMap">
  5. <result property="id" column="ID" jdbcType="INTEGER"/>
  6. <result property="xh" column="XH" jdbcType="VARCHAR"/>
  7. <result property="fzr" column="FZR" jdbcType="INTEGER"/>
  8. <result property="xm" column="XM" jdbcType="VARCHAR"/>
  9. <result property="zb" column="ZB" jdbcType="INTEGER"/>
  10. </resultMap>
  11. <!--查询单个-->
  12. <select id="queryById" resultMap="PrjResponsibleMap">
  13. select
  14. ID, XH, FZR, XM, ZB
  15. from prj_Responsible
  16. where ID = #{id}
  17. </select>
  18. <!--查询指定行数据-->
  19. <select id="queryAllByLimit" resultMap="PrjResponsibleMap">
  20. select
  21. ID, XH, FZR, XM, ZB
  22. from prj_Responsible
  23. <where>
  24. <if test="id != null">
  25. and ID = #{id}
  26. </if>
  27. <if test="xh != null and xh != ''">
  28. and XH = #{xh}
  29. </if>
  30. <if test="fzr != null">
  31. and FZR = #{fzr}
  32. </if>
  33. <if test="xm != null and xm != ''">
  34. and XM = #{xm}
  35. </if>
  36. <if test="zb != null">
  37. and ZB = #{zb}
  38. </if>
  39. </where>
  40. limit #{pageable.offset}, #{pageable.pageSize}
  41. </select>
  42. <!--统计总行数-->
  43. <select id="count" resultType="java.lang.Long">
  44. select count(1)
  45. from prj_Responsible
  46. <where>
  47. <if test="id != null">
  48. and ID = #{id}
  49. </if>
  50. <if test="xh != null and xh != ''">
  51. and XH = #{xh}
  52. </if>
  53. <if test="fzr != null">
  54. and FZR = #{fzr}
  55. </if>
  56. <if test="xm != null and xm != ''">
  57. and XM = #{xm}
  58. </if>
  59. <if test="zb != null">
  60. and ZB = #{zb}
  61. </if>
  62. </where>
  63. </select>
  64. <!--新增所有列-->
  65. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  66. insert into prj_Responsible(XH, FZR, XM, ZB)
  67. values (#{xh}, #{fzr}, #{xm}, #{zb})
  68. </insert>
  69. <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
  70. insert into prj_Responsible(XH, FZR, XM, ZB)
  71. values
  72. <foreach collection="entities" item="entity" separator=",">
  73. (#{entity.xh}, #{entity.fzr}, #{entity.xm}, #{entity.zb})
  74. </foreach>
  75. </insert>
  76. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  77. insert into prj_Responsible(XH, FZR, XM, ZB)
  78. values
  79. <foreach collection="entities" item="entity" separator=",">
  80. (#{entity.xh}, #{entity.fzr}, #{entity.xm}, #{entity.zb})
  81. </foreach>
  82. on duplicate key update
  83. XH = values(XH),
  84. FZR = values(FZR),
  85. XM = values(XM),
  86. ZB = values(ZB)
  87. </insert>
  88. <!--通过主键修改数据-->
  89. <update id="update">
  90. update prj_Responsible
  91. <set>
  92. <if test="xh != null and xh != ''">
  93. XH = #{xh},
  94. </if>
  95. <if test="fzr != null">
  96. FZR = #{fzr},
  97. </if>
  98. <if test="xm != null and xm != ''">
  99. XM = #{xm},
  100. </if>
  101. <if test="zb != null">
  102. ZB = #{zb},
  103. </if>
  104. </set>
  105. where ID = #{id}
  106. </update>
  107. <!--通过主键删除-->
  108. <delete id="deleteById">
  109. delete from prj_Responsible where ID = #{id}
  110. </delete>
  111. </mapper>