All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mapper.SortTestMapper.xml Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
<?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.github.freegeese.maven.plugin.autocode.demo.mapper.SortTestMapper">
    <resultMap id="BaseResultMap" type="com.github.freegeese.maven.plugin.autocode.demo.model.SortTest">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="id" jdbcType="INTEGER" property="id" />
        <result column="sort" jdbcType="INTEGER" property="sort" />
        <result column="name" jdbcType="VARCHAR" property="name" />
    </resultMap>

    <sql id="Base_Column_List">
        id, sort, name
    </sql>

    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        insert into t_sort_test (sort, name)
        values (#{sort,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
    </insert>

    <insert id="insertSelective" keyProperty="id" useGeneratedKeys="true">
        insert into t_sort_test
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sort != null">
                sort,
            </if>
            <if test="name != null">
                name,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sort != null">
                #{sort,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        delete from t_sort_test
        where id = #{id,jdbcType=INTEGER}
    </delete>

    <delete id="deleteByPrimaryKeys">
        delete from t_sort_test where id in
        <foreach close=")" collection="list" item="item" open="(" separator=",">
        #{item}
        </foreach>
    </delete>

    <update id="updateByPrimaryKey">
        update t_sort_test
        <set>
            sort = #{sort,jdbcType=INTEGER},
            name = #{name,jdbcType=VARCHAR}
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <update id="updateByPrimaryKeySelective">
        update t_sort_test
        <set>
            <if test="sort != null">
                sort = #{sort,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR}
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_sort_test
        where id = #{id,jdbcType=INTEGER}
    </select>

    <select id="selectByPrimaryKeys" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_sort_test where id in
        <foreach close=")" collection="list" item="item" open="(" separator=",">
            #{item}
        </foreach>
    </select>

    <select id="selectByRecord" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_sort_test
        <where>
            <if test="sort != null">
                and sort = #{sort}
            </if>
            <if test="name != null">
                and name = #{name}
            </if>
        </where>
            order by sort
    </select>

    <select id="selectByConditions" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_sort_test
        <where>
            <if test="sort != null">
                and sort ${sort}
            </if>
            <if test="name != null">
                and name ${name}
            </if>
        </where>
            order by sort
    </select>

    <select id="selectAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from t_sort_test
        order by sort
    </select>

    <insert id="batchInsert" keyProperty="id" useGeneratedKeys="true">
        insert into t_sort_test (sort, name) values
        <foreach collection="list" item="item" separator=",">
            (
            #{item.sort,jdbcType=INTEGER},
            #{item.name,jdbcType=VARCHAR}
            )
        </foreach>
    </insert>

    <update id="batchUpdate">
        <foreach close="" collection="list" item="item" open="" separator=";">
            update t_sort_test
            <set>
                <if test="item.sort != null">
                    sort = #{item.sort,jdbcType=INTEGER},
                </if>
                <if test="item.name != null">
                    name = #{item.name,jdbcType=VARCHAR}
                </if>
            </set>
            where id = #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>

    <select id="count" resultType="java.lang.Long">
        select count(*)
        from t_sort_test
    </select>

    <update id="exchange">
        <if test="source.id != target.id">
            UPDATE t_sort_test SET sort = #{target.sort} WHERE id = #{source.id};
            UPDATE t_sort_test SET sort = #{source.sort} WHERE id = #{target.id};
        </if>
    </update>

    <update id="move">
        <if test="from.id != to.id">
            <if test="from.sort > to.sort">
                UPDATE t_sort_test SET sort = sort + 1
                WHERE sort >= #{to.sort} and sort <![CDATA[ < ]]> #{from.sort};
            </if>
            <if test="to.sort > from.sort">
                UPDATE t_sort_test SET sort = sort - 1
                WHERE sort > #{from.sort} and sort <![CDATA[ <= ]]> #{to.sort};
            </if>
            UPDATE t_sort_test SET sort = #{to.sort} WHERE id = #{from.id}
        </if>
    </update>

    <select id="selectPrevious" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM t_sort_test WHERE sort = (
            SELECT MAX(sort) FROM t_sort_test WHERE sort <![CDATA[ < ]]> #{sort}
        )
    </select>

    <select id="selectNext" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM t_sort_test WHERE sort = (
            SELECT MIN(sort) FROM t_sort_test WHERE sort <![CDATA[ > ]]> #{sort}
        )
    </select>

    <select id="selectFirst" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM t_sort_test WHERE sort = (
            SELECT MIN(sort) FROM t_sort_test
        )
    </select>

    <select id="selectLast" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List" />
        FROM t_sort_test WHERE sort = (
            SELECT MAX(sort) FROM t_sort_test
        )
    </select>
</mapper>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy