91 lines
2.4 KiB
XML
91 lines
2.4 KiB
XML
<?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.mapper.CarDao">
|
|
|
|
<resultMap type="com.entity.Car" id="CarMap">
|
|
<result property="id" column="id" jdbcType="INTEGER"/>
|
|
<result property="carId" column="car_id" jdbcType="VARCHAR"/>
|
|
</resultMap>
|
|
|
|
<!--查询单个-->
|
|
<select id="queryById" resultMap="CarMap">
|
|
select id
|
|
from car
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<!--查询指定行数据-->
|
|
<select id="queryAllByLimit" resultMap="CarMap">
|
|
select
|
|
id,car_id
|
|
from car
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="carId != null and carId != ''">
|
|
and car_id = #{carId}
|
|
</if>
|
|
</where>
|
|
limit #{pageRequest.page}, #{pageRequest.size}
|
|
</select>
|
|
|
|
<!--统计总行数-->
|
|
<select id="count" resultType="java.lang.Long">
|
|
select count(1)
|
|
from car
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id}
|
|
</if>
|
|
<if test="carId != null and carId != ''">
|
|
and car_id = #{carId}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<!--新增所有列-->
|
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
|
insert into car(car_id)
|
|
values (#{carId})
|
|
</insert>
|
|
|
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into car(car_id)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.carId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
|
insert into car(car_id)
|
|
values
|
|
<foreach collection="entities" item="entity" separator=",">
|
|
(#{entity.carId})
|
|
</foreach>
|
|
on duplicate key update
|
|
car_id = values(car_id)
|
|
</insert>
|
|
|
|
<!--通过主键修改数据-->
|
|
<update id="update">
|
|
update car
|
|
<set>
|
|
<if test="carId != null and carId != ''">
|
|
car_id = #{carId},
|
|
</if>
|
|
</set>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<!--通过主键删除-->
|
|
<delete id="deleteById">
|
|
delete
|
|
from car
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
</mapper>
|
|
|