BasePartyDao.xml 3.0 KB

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