LegalHolidaysMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.LegalHolidaysMapper">
  4. <resultMap type="com.goafanti.common.model.LegalHolidays" id="LegalHolidaysMap">
  5. <result property="id" column="id" jdbcType="INTEGER"/>
  6. <result property="holidays" column="holidays" jdbcType="TIMESTAMP"/>
  7. <result property="status" column="status" jdbcType="INTEGER"/>
  8. </resultMap>
  9. <sql id="LegalHolidaysAllSql">
  10. id, holidays, status
  11. </sql>
  12. <!--查询单个-->
  13. <select id="selectById" resultMap="LegalHolidaysMap">
  14. select
  15. <include refid="LegalHolidaysAllSql"/>
  16. from legal_holidays
  17. where id = #{id}
  18. </select>
  19. <!--新增所有列-->
  20. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  21. insert into legal_holidays(holidays, status)
  22. values (#{holidays}, #{status})
  23. </insert>
  24. <insert id="insertBatch">
  25. insert into legal_holidays(holidays, status)
  26. values
  27. <foreach collection="entities" item="entity" separator=",">
  28. (#{entity.holidays}, #{entity.status})
  29. </foreach>
  30. </insert>
  31. <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
  32. insert into legal_holidays(holidays, status)
  33. values
  34. <foreach collection="entities" item="entity" separator=",">
  35. (#{entity.holidays}, #{entity.status})
  36. </foreach>
  37. on duplicate key update
  38. holidays = values(holidays),
  39. status = values(status)
  40. </insert>
  41. <!--通过主键修改数据-->
  42. <update id="update">
  43. update legal_holidays
  44. <set>
  45. <if test="holidays != null">
  46. holidays = #{holidays},
  47. </if>
  48. <if test="status != null">
  49. status = #{status},
  50. </if>
  51. </set>
  52. where id = #{id}
  53. </update>
  54. <!--查询指定行数据-->
  55. <select id="findLegalHolidaysList" resultMap="LegalHolidaysMap">
  56. select
  57. <include refid="LegalHolidaysAllSql"/>
  58. from legal_holidays
  59. <where>
  60. <if test="id != null">
  61. and id = #{id}
  62. </if>
  63. <if test="holidays != null">
  64. and holidays = #{holidays}
  65. </if>
  66. <if test="status != null">
  67. and status = #{status}
  68. </if>
  69. </where>
  70. <if test="page_sql != null">
  71. ${page_sql}
  72. </if>
  73. </select>
  74. <!--统计总行数-->
  75. <select id="findLegalHolidaysCount" resultType="java.lang.Integer">
  76. select count(1)
  77. from legal_holidays
  78. <where>
  79. <if test="id != null">
  80. and id = #{id}
  81. </if>
  82. <if test="holidays != null">
  83. and holidays = #{holidays}
  84. </if>
  85. <if test="status != null">
  86. and status = #{status}
  87. </if>
  88. </where>
  89. </select>
  90. <!--通过主键删除-->
  91. <delete id="deleteById">
  92. delete
  93. from legal_holidays
  94. where id = #{id}
  95. </delete>
  96. <select id="selectAll" resultMap="LegalHolidaysMap">
  97. select
  98. <include refid="LegalHolidaysAllSql"/>
  99. from legal_holidays
  100. </select>
  101. </mapper>