123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.liang.dao.BasePartyDao">
- <resultMap type="com.liang.entity.BaseParty" id="BasePartyMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="mc" column="MC" jdbcType="VARCHAR"/>
- <result property="bm" column="BM" jdbcType="VARCHAR"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="BasePartyMap">
- select ID,
- MC,
- BM
- from base_Party
- where ID = #{id}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="BasePartyMap">
- select
- ID, MC, BM
- from base_Party
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="mc != null and mc != ''">
- and MC = #{mc}
- </if>
- <if test="bm != null and bm != ''">
- and BM = #{bm}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from base_Party
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="mc != null and mc != ''">
- and MC = #{mc}
- </if>
- <if test="bm != null and bm != ''">
- and BM = #{bm}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into base_Party(MC, BM)
- values (#{mc}, #{bm})
- </insert>
- <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_Party(MC, BM)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mc}, #{entity.bm})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_Party(MC, BM)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mc}, #{entity.bm})
- </foreach>
- on duplicate key update
- MC = values(MC),
- BM = values(BM)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update base_Party
- <set>
- <if test="mc != null and mc != ''">
- MC = #{mc},
- </if>
- <if test="bm != null and bm != ''">
- BM = #{bm},
- </if>
- </set>
- where ID = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from base_Party
- where ID = #{id}
- </delete>
- <!--获取党派-->
- <select id="getParty" resultType="map">
- select BM as code, MC as name
- from base_Party
- </select>
- </mapper>
|