SyVehicleModelMapper.xml 11.4 KB
<?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.objecteye.mapper.SyVehicleModelMapper">
    <resultMap id="BaseResultMap" type="com.objecteye.entity.SyVehicleModel">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="initials" jdbcType="VARCHAR" property="initials"/>
        <result column="brand" jdbcType="VARCHAR" property="brand"/>
        <result column="subbrand" jdbcType="VARCHAR" property="subbrand"/>
        <result column="birthday" jdbcType="VARCHAR" property="birthday"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        id, initials, brand, subbrand, birthday
    </sql>

    <!--1 查询所有的汽车型号首字母-->
    <!--List<String> selectDisplayForInitials();-->
    <select id="selectDisplayForInitials" resultType="java.lang.String">
        select distinct initials
        from sy_vehicle_model
        order by initials;
    </select>

    <!--2 List<String> selectDisplayForBrand();-->
    <!--//查询某个首字母下的汽车型号品牌-->
    <select id="selectDisplayForBrand" parameterType="java.lang.String" resultType="java.lang.String">
        select distinct brand
        from sy_vehicle_model
        where initials = #{initals}
    </select>

    <!--3 List<String> selectDisplayForSubbrand();-->
    <!--//查询某个首字母下的汽车型号品牌-->
    <select id="selectDisplayForSubbrand" parameterType="java.lang.String" resultType="java.lang.String">
        select distinct subbrand
        from sy_vehicle_model
        where brand = #{brand}
    </select>

    <!--4 List<String> selectDisplayForBirthday();-->
    <!--//查询某品牌下的汽车生产日期-->
    <select id="selectDisplayForBirthday" parameterType="java.lang.String" resultType="java.lang.String">
        select birthday
        from sy_vehicle_model
        where subbrand = #{subbrand}
    </select>


    <!-- 5 返回所有车辆类型列表
     List<String> displayVehicleTypeList();-->
    <select id="displayVehicleTypeList" resultType="java.lang.String">
        select distinct name
        from sy_vehicle_type;
    </select>

    <!--6 返回所有车辆车身颜色列表
    List<String> displayVehicleColorList();-->
    <select id="displayVehicleColorList" resultType="com.objecteye.pojo.NameValue">
        select distinct name,
                        value
        from sy_vehicle_color;
    </select>

    <!-- 7 返回所有车辆号牌类型列表
     List<String> displayVehiclePlateTypeList();-->
    <select id="displayVehiclePlateTypeList" resultType="com.objecteye.pojo.NameValue">
        select distinct name,
                        value
        from sy_vehicle_plate_type;
    </select>

    <!--8 返回所有车辆年检标个数列表
    List<String> displayVehicleNjbNumberList();-->
    <select id="displayVehicleNjbNumberList" resultType="java.lang.String">
        select distinct njb_number
        from sy_vehicle_njb_number;
    </select>


    <select id="selectByExample" parameterType="com.objecteye.entity.SyVehicleModelExample" resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from sy_vehicle_model
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from sy_vehicle_model
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete
        from sy_vehicle_model
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.objecteye.entity.SyVehicleModelExample">
        delete from sy_vehicle_model
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.objecteye.entity.SyVehicleModel">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sy_vehicle_model (initials, brand, subbrand,
        birthday)
        values (#{initials,jdbcType=VARCHAR}, #{brand,jdbcType=VARCHAR}, #{subbrand,jdbcType=VARCHAR},
        #{birthday,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.objecteye.entity.SyVehicleModel">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sy_vehicle_model
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="initials != null">
                initials,
            </if>
            <if test="brand != null">
                brand,
            </if>
            <if test="subbrand != null">
                subbrand,
            </if>
            <if test="birthday != null">
                birthday,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="initials != null">
                #{initials,jdbcType=VARCHAR},
            </if>
            <if test="brand != null">
                #{brand,jdbcType=VARCHAR},
            </if>
            <if test="subbrand != null">
                #{subbrand,jdbcType=VARCHAR},
            </if>
            <if test="birthday != null">
                #{birthday,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.objecteye.entity.SyVehicleModelExample"
            resultType="java.lang.Integer">
        select count(*) from sy_vehicle_model
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update sy_vehicle_model
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.initials != null">
                initials = #{record.initials,jdbcType=VARCHAR},
            </if>
            <if test="record.brand != null">
                brand = #{record.brand,jdbcType=VARCHAR},
            </if>
            <if test="record.subbrand != null">
                subbrand = #{record.subbrand,jdbcType=VARCHAR},
            </if>
            <if test="record.birthday != null">
                birthday = #{record.birthday,jdbcType=VARCHAR},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update sy_vehicle_model
        set id = #{record.id,jdbcType=INTEGER},
        initials = #{record.initials,jdbcType=VARCHAR},
        brand = #{record.brand,jdbcType=VARCHAR},
        subbrand = #{record.subbrand,jdbcType=VARCHAR},
        birthday = #{record.birthday,jdbcType=VARCHAR}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.objecteye.entity.SyVehicleModel">
        update sy_vehicle_model
        <set>
            <if test="initials != null">
                initials = #{initials,jdbcType=VARCHAR},
            </if>
            <if test="brand != null">
                brand = #{brand,jdbcType=VARCHAR},
            </if>
            <if test="subbrand != null">
                subbrand = #{subbrand,jdbcType=VARCHAR},
            </if>
            <if test="birthday != null">
                birthday = #{birthday,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.objecteye.entity.SyVehicleModel">
        update sy_vehicle_model
        set initials = #{initials,jdbcType=VARCHAR},
            brand    = #{brand,jdbcType=VARCHAR},
            subbrand = #{subbrand,jdbcType=VARCHAR},
            birthday = #{birthday,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>