novel/src/main/resources/mybatis/mapping/CategoryMapper.xml
2019-09-04 18:44:04 +08:00

211 lines
7.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="xyz.zinglizingli.books.mapper.CategoryMapper" >
<resultMap id="BaseResultMap" type="xyz.zinglizingli.books.po.Category" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="sort" property="sort" jdbcType="TINYINT" />
<result column="get_url" property="getUrl" jdbcType="VARCHAR" />
<result column="req_url" property="reqUrl" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
<where >
<foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid" >
<trim prefix="(" suffix=")" prefixOverrides="and" >
<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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
<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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List" >
id, name, sort, get_url, req_url
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="xyz.zinglizingli.books.po.CategoryExample" >
select
<if test="distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from category
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null" >
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from category
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from category
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="xyz.zinglizingli.books.po.CategoryExample" >
delete from category
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="xyz.zinglizingli.books.po.Category" >
insert into category (id, name, sort,
get_url, req_url)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sort,jdbcType=TINYINT},
#{getUrl,jdbcType=VARCHAR}, #{reqUrl,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="xyz.zinglizingli.books.po.Category" >
insert into category
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="sort != null" >
sort,
</if>
<if test="getUrl != null" >
get_url,
</if>
<if test="reqUrl != null" >
req_url,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="sort != null" >
#{sort,jdbcType=TINYINT},
</if>
<if test="getUrl != null" >
#{getUrl,jdbcType=VARCHAR},
</if>
<if test="reqUrl != null" >
#{reqUrl,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="xyz.zinglizingli.books.po.CategoryExample" resultType="java.lang.Integer" >
select count(*) from category
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map" >
update category
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.name != null" >
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.sort != null" >
sort = #{record.sort,jdbcType=TINYINT},
</if>
<if test="record.getUrl != null" >
get_url = #{record.getUrl,jdbcType=VARCHAR},
</if>
<if test="record.reqUrl != null" >
req_url = #{record.reqUrl,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map" >
update category
set id = #{record.id,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=TINYINT},
get_url = #{record.getUrl,jdbcType=VARCHAR},
req_url = #{record.reqUrl,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="xyz.zinglizingli.books.po.Category" >
update category
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="sort != null" >
sort = #{sort,jdbcType=TINYINT},
</if>
<if test="getUrl != null" >
get_url = #{getUrl,jdbcType=VARCHAR},
</if>
<if test="reqUrl != null" >
req_url = #{reqUrl,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="xyz.zinglizingli.books.po.Category" >
update category
set name = #{name,jdbcType=VARCHAR},
sort = #{sort,jdbcType=TINYINT},
get_url = #{getUrl,jdbcType=VARCHAR},
req_url = #{reqUrl,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>