<?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.gitee.gen.mapper.TypeConfigMapper">
    <resultMap id="BaseResultMap" type="com.gitee.gen.entity.TypeConfig">
        <result column="id" property="id"/>
        <result column="db_type" property="dbType"/>
        <result column="base_type" property="baseType"/>
        <result column="box_type" property="boxType"/>
    </resultMap>
    <!-- 表字段 -->
    <sql id="baseColumns">t.id , t.db_type , t.base_type , t.box_type</sql>
    <!-- 查询全部 -->
    <select id="listAll" resultMap="BaseResultMap">SELECT
        <include refid="baseColumns"/> FROM type_config t
    </select>
    <!-- 根据主键获取单条记录 -->
    <select id="getById" resultMap="BaseResultMap" parameterType="Integer">SELECT
        <include refid="baseColumns"/> FROM type_config t WHERE id = #{id}
    </select>
    <!-- 插入全部字段 -->
    <insert id="insert" parameterType="com.gitee.gen.entity.TypeConfig" keyProperty="id" keyColumn="id" useGeneratedKeys="true">INSERT INTO type_config
        <trim prefix="(" suffix=")" suffixOverrides=",">db_type, base_type, box_type,</trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">#{dbType}, #{baseType}, #{boxType},</trim>
    </insert>
    <!-- 插入不为NULL的字段 -->
    <insert id="insertIgnoreNull" parameterType="com.gitee.gen.entity.TypeConfig" keyProperty="id" keyColumn="id" useGeneratedKeys="true">INSERT INTO type_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dbType != null">db_type,</if>
            <if test="baseType != null">base_type,</if>
            <if test="boxType != null">box_type,</if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="dbType != null">#{dbType},</if>
            <if test="baseType != null">#{baseType},</if>
            <if test="boxType != null">#{boxType},</if>
        </trim>
    </insert>
    <!-- 更新,更新全部字段 -->
    <update id="update" parameterType="com.gitee.gen.entity.TypeConfig">UPDATE type_config
        <set>db_type=#{dbType}, base_type=#{baseType}, box_type=#{boxType},</set> WHERE id = #{id}
    </update>
    <!-- 更新不为NULL的字段 -->
    <update id="updateIgnoreNull" parameterType="com.gitee.gen.entity.TypeConfig">UPDATE type_config
        <set>
            <if test="dbType != null">db_type=#{dbType},</if>
            <if test="baseType != null">base_type=#{baseType},</if>
            <if test="boxType != null">box_type=#{boxType},</if>
        </set> WHERE id = #{id}
    </update>
    <!-- 根据主键删除记录 -->
    <delete id="delete" parameterType="com.gitee.gen.entity.TypeConfig">UPDATE type_config SET is_deleted=1 WHERE id = #{id}</delete>
</mapper>
