123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?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.BaseSchoolDao">
- <resultMap type="com.liang.entity.BaseSchool" id="BaseSchoolMap">
- <result property="id" column="id" jdbcType="INTEGER"/>
- <result property="name" column="name" jdbcType="VARCHAR"/>
- <result property="pid" column="pid" jdbcType="INTEGER"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="BaseSchoolMap">
- select id,
- name,
- pid
- from base_School
- where id = #{id}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="BaseSchoolMap">
- select
- id, name, pid
- from base_School
- <where>
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="name != null and name != ''">
- and name = #{name}
- </if>
- <if test="pid != null">
- and pid = #{pid}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from base_School
- <where>
- <if test="id != null">
- and id = #{id}
- </if>
- <if test="name != null and name != ''">
- and name = #{name}
- </if>
- <if test="pid != null">
- and pid = #{pid}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into base_School(name, pid)
- values (#{name}, #{pid})
- </insert>
- <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_School(name, pid)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.name}, #{entity.pid})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_School(name, pid)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.name}, #{entity.pid})
- </foreach>
- on duplicate key update
- name = values(name),
- pid = values(pid)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update base_School
- <set>
- <if test="name != null and name != ''">
- name = #{name},
- </if>
- <if test="pid != null">
- pid = #{pid},
- </if>
- </set>
- where id = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from base_School
- where id = #{id}
- </delete>
- <!--查询所有记录-->
- <select id="queryAll" resultMap="BaseSchoolMap">
- select *
- from base_School
- order by id asc
- </select>
- <!--获取国家基金委学科领域-->
- <select id="getSchoolList" resultType="map">
- select id as code, name
- from base_School
- </select>
- </mapper>
|