<?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.xinxincaravan.caravan.vehicle.mapper.ConstantMapper">

    <select id="getAllConstantTypes" resultType="java.lang.Integer">
        select distinct `type` from constant
    </select>

    <update id="updateByTypeAndCode" parameterType="com.xinxincaravan.caravan.vehicle.entity.Constant" >
        update constant set val = #{val} where type = #{type} and code = #{code}
    </update>

    <delete id="delByTypeAndCode" parameterType="com.xinxincaravan.caravan.vehicle.entity.Constant">
        delete from constant where type = #{type} and code = #{code};
    </delete>

    <insert id="insertIgnoreOnDuplicate" parameterType="com.xinxincaravan.caravan.vehicle.entity.Constant">
        insert ignore into constant(type,code,val) values (#{type},#{code},#{val})
    </insert>

    <select id="getTypebyname" resultType="java.lang.Integer">
        select distinct `code` from constant where type=#{type} and val like  CONCAT('%',#{name},'%') limit 1
    </select>


</mapper>