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