udpate mapper

This commit is contained in:
shuzheng 2016-10-13 14:06:44 +08:00
parent 18e4c2c7fb
commit 848567edba
3 changed files with 161 additions and 621 deletions

View File

@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zheng.cms.mapper.BookMapper"> <mapper namespace="com.zheng.cms.mapper.BookMapper" >
<resultMap id="BaseResultMap" type="com.zheng.cms.model.Book"> <resultMap id="BaseResultMap" type="com.zheng.cms.model.Book" >
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" property="id" jdbcType="INTEGER" />
<result column="userid" jdbcType="INTEGER" property="userid" /> <result column="userid" property="userid" jdbcType="INTEGER" />
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" property="name" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause" >
<where> <where >
<foreach collection="oredCriteria" item="criteria" separator="or"> <foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid"> <if test="criteria.valid" >
<trim prefix="(" prefixOverrides="and" suffix=")"> <trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion"> <foreach collection="criteria.criteria" item="criterion" >
<choose> <choose >
<when test="criterion.noValue"> <when test="criterion.noValue" >
and ${criterion.condition} and ${criterion.condition}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue" >
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -35,25 +35,25 @@
</foreach> </foreach>
</where> </where>
</sql> </sql>
<sql id="Update_By_Example_Where_Clause"> <sql id="Update_By_Example_Where_Clause" >
<where> <where >
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid"> <if test="criteria.valid" >
<trim prefix="(" prefixOverrides="and" suffix=")"> <trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion"> <foreach collection="criteria.criteria" item="criterion" >
<choose> <choose >
<when test="criterion.noValue"> <when test="criterion.noValue" >
and ${criterion.condition} and ${criterion.condition}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue" >
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -64,292 +64,115 @@
</foreach> </foreach>
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List" >
id, userid, name id, userid, name
</sql> </sql>
<select id="selectByExample" parameterType="com.zheng.cms.model.BookExample" resultMap="BaseResultMap"> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.zheng.cms.model.BookExample" >
select select
<if test="distinct"> <if test="distinct" >
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from book from book
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null" >
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from book from book
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from book delete from book
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.model.BookExample"> <delete id="deleteByExample" parameterType="com.zheng.cms.model.BookExample" >
delete from book delete from book
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.zheng.cms.model.Book"> <insert id="insert" parameterType="com.zheng.cms.model.Book" >
insert into book (id, userid, name insert into book (id, userid, name
) )
values (#{id,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR} values (#{id,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}
) )
</insert> </insert>
<insert id="insertSelective" parameterType="com.zheng.cms.model.Book"> <insert id="insertSelective" parameterType="com.zheng.cms.model.Book" >
insert into book insert into book
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null"> <if test="id != null" >
id, id,
</if> </if>
<if test="userid != null"> <if test="userid != null" >
userid, userid,
</if> </if>
<if test="name != null"> <if test="name != null" >
name, name,
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null"> <if test="id != null" >
#{id,jdbcType=INTEGER}, #{id,jdbcType=INTEGER},
</if> </if>
<if test="userid != null"> <if test="userid != null" >
#{userid,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER},
</if> </if>
<if test="name != null"> <if test="name != null" >
#{name,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.zheng.cms.model.BookExample" resultType="java.lang.Integer"> <select id="countByExample" parameterType="com.zheng.cms.model.BookExample" resultType="java.lang.Integer" >
select count(*) from book select count(*) from book
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map" >
update book update book
<set> <set >
<if test="record.id != null"> <if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER}, id = #{record.id,jdbcType=INTEGER},
</if> </if>
<if test="record.userid != null"> <if test="record.userid != null" >
userid = #{record.userid,jdbcType=INTEGER}, userid = #{record.userid,jdbcType=INTEGER},
</if> </if>
<if test="record.name != null"> <if test="record.name != null" >
name = #{record.name,jdbcType=VARCHAR}, name = #{record.name,jdbcType=VARCHAR},
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map" >
update book update book
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=INTEGER},
userid = #{record.userid,jdbcType=INTEGER}, userid = #{record.userid,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR} name = #{record.name,jdbcType=VARCHAR}
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.Book"> <update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.Book" >
update book update book
<set> <set >
<if test="userid != null"> <if test="userid != null" >
userid = #{userid,jdbcType=INTEGER}, userid = #{userid,jdbcType=INTEGER},
</if> </if>
<if test="name != null"> <if test="name != null" >
name = #{name,jdbcType=VARCHAR}, name = #{name,jdbcType=VARCHAR},
</if> </if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.Book"> <update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.Book" >
update book
set userid = #{userid,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<resultMap id="BaseResultMap" type="com.zheng.cms.model.Book">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="userid" jdbcType="INTEGER" property="userid" />
<result column="name" jdbcType="VARCHAR" property="name" />
</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, userid, name
</sql>
<select id="selectByExample" parameterType="com.zheng.cms.model.BookExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from book
<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 book
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from book
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.model.BookExample">
delete from book
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.zheng.cms.model.Book">
insert into book (id, userid, name
)
values (#{id,jdbcType=INTEGER}, #{userid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.zheng.cms.model.Book">
insert into book
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userid != null">
userid,
</if>
<if test="name != null">
name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="userid != null">
#{userid,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.zheng.cms.model.BookExample" resultType="java.lang.Integer">
select count(*) from book
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update book
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.userid != null">
userid = #{record.userid,jdbcType=INTEGER},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update book
set id = #{record.id,jdbcType=INTEGER},
userid = #{record.userid,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.Book">
update book
<set>
<if test="userid != null">
userid = #{userid,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.Book">
update book update book
set userid = #{userid,jdbcType=INTEGER}, set userid = #{userid,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR} name = #{name,jdbcType=VARCHAR}

View File

@ -1,36 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zheng.cms.mapper.UserMapper"> <mapper namespace="com.zheng.cms.mapper.UserMapper" >
<resultMap id="BaseResultMap" type="com.zheng.cms.model.User"> <resultMap id="BaseResultMap" type="com.zheng.cms.model.User" >
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" property="id" jdbcType="INTEGER" />
<result column="username" jdbcType="VARCHAR" property="username" /> <result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" jdbcType="VARCHAR" property="password" /> <result column="password" property="password" jdbcType="VARCHAR" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" /> <result column="nickname" property="nickname" jdbcType="VARCHAR" />
<result column="sex" jdbcType="INTEGER" property="sex" /> <result column="sex" property="sex" jdbcType="INTEGER" />
<result column="ctime" jdbcType="BIGINT" property="ctime" /> <result column="ctime" property="ctime" jdbcType="BIGINT" />
</resultMap> </resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.zheng.cms.model.User"> <resultMap id="ResultMapWithBLOBs" type="com.zheng.cms.model.User" extends="BaseResultMap" >
<result column="content" jdbcType="LONGVARCHAR" property="content" /> <result column="content" property="content" jdbcType="LONGVARCHAR" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause" >
<where> <where >
<foreach collection="oredCriteria" item="criteria" separator="or"> <foreach collection="oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid"> <if test="criteria.valid" >
<trim prefix="(" prefixOverrides="and" suffix=")"> <trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion"> <foreach collection="criteria.criteria" item="criterion" >
<choose> <choose >
<when test="criterion.noValue"> <when test="criterion.noValue" >
and ${criterion.condition} and ${criterion.condition}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue" >
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -41,25 +41,25 @@
</foreach> </foreach>
</where> </where>
</sql> </sql>
<sql id="Update_By_Example_Where_Clause"> <sql id="Update_By_Example_Where_Clause" >
<where> <where >
<foreach collection="example.oredCriteria" item="criteria" separator="or"> <foreach collection="example.oredCriteria" item="criteria" separator="or" >
<if test="criteria.valid"> <if test="criteria.valid" >
<trim prefix="(" prefixOverrides="and" suffix=")"> <trim prefix="(" suffix=")" prefixOverrides="and" >
<foreach collection="criteria.criteria" item="criterion"> <foreach collection="criteria.criteria" item="criterion" >
<choose> <choose >
<when test="criterion.noValue"> <when test="criterion.noValue" >
and ${criterion.condition} and ${criterion.condition}
</when> </when>
<when test="criterion.singleValue"> <when test="criterion.singleValue" >
and ${criterion.condition} #{criterion.value} and ${criterion.condition} #{criterion.value}
</when> </when>
<when test="criterion.betweenValue"> <when test="criterion.betweenValue" >
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when> </when>
<when test="criterion.listValue"> <when test="criterion.listValue" >
and ${criterion.condition} and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
#{listItem} #{listItem}
</foreach> </foreach>
</when> </when>
@ -70,43 +70,43 @@
</foreach> </foreach>
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List" >
id, username, password, nickname, sex, ctime id, username, password, nickname, sex, ctime
</sql> </sql>
<sql id="Blob_Column_List"> <sql id="Blob_Column_List" >
content content
</sql> </sql>
<select id="selectByExampleWithBLOBs" parameterType="com.zheng.cms.model.UserExample" resultMap="ResultMapWithBLOBs"> <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs" parameterType="com.zheng.cms.model.UserExample" >
select select
<if test="distinct"> <if test="distinct" >
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
, ,
<include refid="Blob_Column_List" /> <include refid="Blob_Column_List" />
from user from user
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null" >
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByExample" parameterType="com.zheng.cms.model.UserExample" resultMap="BaseResultMap"> <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.zheng.cms.model.UserExample" >
select select
<if test="distinct"> <if test="distinct" >
distinct distinct
</if> </if>
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from user from user
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
<if test="orderByClause != null"> <if test="orderByClause != null" >
order by ${orderByClause} order by ${orderByClause}
</if> </if>
</select> </select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs"> <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
, ,
@ -114,17 +114,17 @@
from user from user
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer"> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from user delete from user
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</delete> </delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.model.UserExample"> <delete id="deleteByExample" parameterType="com.zheng.cms.model.UserExample" >
delete from user delete from user
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.zheng.cms.model.User"> <insert id="insert" parameterType="com.zheng.cms.model.User" >
insert into user (id, username, password, insert into user (id, username, password,
nickname, sex, ctime, nickname, sex, ctime,
content) content)
@ -132,91 +132,91 @@
#{nickname,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER}, #{ctime,jdbcType=BIGINT}, #{nickname,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER}, #{ctime,jdbcType=BIGINT},
#{content,jdbcType=LONGVARCHAR}) #{content,jdbcType=LONGVARCHAR})
</insert> </insert>
<insert id="insertSelective" parameterType="com.zheng.cms.model.User"> <insert id="insertSelective" parameterType="com.zheng.cms.model.User" >
insert into user insert into user
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null"> <if test="id != null" >
id, id,
</if> </if>
<if test="username != null"> <if test="username != null" >
username, username,
</if> </if>
<if test="password != null"> <if test="password != null" >
password, password,
</if> </if>
<if test="nickname != null"> <if test="nickname != null" >
nickname, nickname,
</if> </if>
<if test="sex != null"> <if test="sex != null" >
sex, sex,
</if> </if>
<if test="ctime != null"> <if test="ctime != null" >
ctime, ctime,
</if> </if>
<if test="content != null"> <if test="content != null" >
content, content,
</if> </if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null"> <if test="id != null" >
#{id,jdbcType=INTEGER}, #{id,jdbcType=INTEGER},
</if> </if>
<if test="username != null"> <if test="username != null" >
#{username,jdbcType=VARCHAR}, #{username,jdbcType=VARCHAR},
</if> </if>
<if test="password != null"> <if test="password != null" >
#{password,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
</if> </if>
<if test="nickname != null"> <if test="nickname != null" >
#{nickname,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR},
</if> </if>
<if test="sex != null"> <if test="sex != null" >
#{sex,jdbcType=INTEGER}, #{sex,jdbcType=INTEGER},
</if> </if>
<if test="ctime != null"> <if test="ctime != null" >
#{ctime,jdbcType=BIGINT}, #{ctime,jdbcType=BIGINT},
</if> </if>
<if test="content != null"> <if test="content != null" >
#{content,jdbcType=LONGVARCHAR}, #{content,jdbcType=LONGVARCHAR},
</if> </if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.zheng.cms.model.UserExample" resultType="java.lang.Integer"> <select id="countByExample" parameterType="com.zheng.cms.model.UserExample" resultType="java.lang.Integer" >
select count(*) from user select count(*) from user
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map" >
update user update user
<set> <set >
<if test="record.id != null"> <if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER}, id = #{record.id,jdbcType=INTEGER},
</if> </if>
<if test="record.username != null"> <if test="record.username != null" >
username = #{record.username,jdbcType=VARCHAR}, username = #{record.username,jdbcType=VARCHAR},
</if> </if>
<if test="record.password != null"> <if test="record.password != null" >
password = #{record.password,jdbcType=VARCHAR}, password = #{record.password,jdbcType=VARCHAR},
</if> </if>
<if test="record.nickname != null"> <if test="record.nickname != null" >
nickname = #{record.nickname,jdbcType=VARCHAR}, nickname = #{record.nickname,jdbcType=VARCHAR},
</if> </if>
<if test="record.sex != null"> <if test="record.sex != null" >
sex = #{record.sex,jdbcType=INTEGER}, sex = #{record.sex,jdbcType=INTEGER},
</if> </if>
<if test="record.ctime != null"> <if test="record.ctime != null" >
ctime = #{record.ctime,jdbcType=BIGINT}, ctime = #{record.ctime,jdbcType=BIGINT},
</if> </if>
<if test="record.content != null"> <if test="record.content != null" >
content = #{record.content,jdbcType=LONGVARCHAR}, content = #{record.content,jdbcType=LONGVARCHAR},
</if> </if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExampleWithBLOBs" parameterType="map"> <update id="updateByExampleWithBLOBs" parameterType="map" >
update user update user
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR}, username = #{record.username,jdbcType=VARCHAR},
@ -225,11 +225,11 @@
sex = #{record.sex,jdbcType=INTEGER}, sex = #{record.sex,jdbcType=INTEGER},
ctime = #{record.ctime,jdbcType=BIGINT}, ctime = #{record.ctime,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARCHAR} content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map" >
update user update user
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR}, username = #{record.username,jdbcType=VARCHAR},
@ -237,35 +237,35 @@
nickname = #{record.nickname,jdbcType=VARCHAR}, nickname = #{record.nickname,jdbcType=VARCHAR},
sex = #{record.sex,jdbcType=INTEGER}, sex = #{record.sex,jdbcType=INTEGER},
ctime = #{record.ctime,jdbcType=BIGINT} ctime = #{record.ctime,jdbcType=BIGINT}
<if test="_parameter != null"> <if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
</update> </update>
<update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.User"> <update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.User" >
update user update user
<set> <set >
<if test="username != null"> <if test="username != null" >
username = #{username,jdbcType=VARCHAR}, username = #{username,jdbcType=VARCHAR},
</if> </if>
<if test="password != null"> <if test="password != null" >
password = #{password,jdbcType=VARCHAR}, password = #{password,jdbcType=VARCHAR},
</if> </if>
<if test="nickname != null"> <if test="nickname != null" >
nickname = #{nickname,jdbcType=VARCHAR}, nickname = #{nickname,jdbcType=VARCHAR},
</if> </if>
<if test="sex != null"> <if test="sex != null" >
sex = #{sex,jdbcType=INTEGER}, sex = #{sex,jdbcType=INTEGER},
</if> </if>
<if test="ctime != null"> <if test="ctime != null" >
ctime = #{ctime,jdbcType=BIGINT}, ctime = #{ctime,jdbcType=BIGINT},
</if> </if>
<if test="content != null"> <if test="content != null" >
content = #{content,jdbcType=LONGVARCHAR}, content = #{content,jdbcType=LONGVARCHAR},
</if> </if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.zheng.cms.model.User"> <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.zheng.cms.model.User" >
update user update user
set username = #{username,jdbcType=VARCHAR}, set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR}, password = #{password,jdbcType=VARCHAR},
@ -275,290 +275,7 @@
content = #{content,jdbcType=LONGVARCHAR} content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.User"> <update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.User" >
update user
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
nickname = #{nickname,jdbcType=VARCHAR},
sex = #{sex,jdbcType=INTEGER},
ctime = #{ctime,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER}
</update>
<resultMap id="BaseResultMap" type="com.zheng.cms.model.User">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="username" jdbcType="VARCHAR" property="username" />
<result column="password" jdbcType="VARCHAR" property="password" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="sex" jdbcType="INTEGER" property="sex" />
<result column="ctime" jdbcType="BIGINT" property="ctime" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.zheng.cms.model.User">
<result column="content" jdbcType="LONGVARCHAR" property="content" />
</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, username, password, nickname, sex, ctime
</sql>
<sql id="Blob_Column_List">
content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.zheng.cms.model.UserExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.zheng.cms.model.UserExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from user
<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="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from user
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from user
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.model.UserExample">
delete from user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.zheng.cms.model.User">
insert into user (id, username, password,
nickname, sex, ctime,
content)
values (#{id,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{nickname,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER}, #{ctime,jdbcType=BIGINT},
#{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.zheng.cms.model.User">
insert into user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="username != null">
username,
</if>
<if test="password != null">
password,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="sex != null">
sex,
</if>
<if test="ctime != null">
ctime,
</if>
<if test="content != null">
content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="username != null">
#{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="sex != null">
#{sex,jdbcType=INTEGER},
</if>
<if test="ctime != null">
#{ctime,jdbcType=BIGINT},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.zheng.cms.model.UserExample" resultType="java.lang.Integer">
select count(*) from user
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update user
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.username != null">
username = #{record.username,jdbcType=VARCHAR},
</if>
<if test="record.password != null">
password = #{record.password,jdbcType=VARCHAR},
</if>
<if test="record.nickname != null">
nickname = #{record.nickname,jdbcType=VARCHAR},
</if>
<if test="record.sex != null">
sex = #{record.sex,jdbcType=INTEGER},
</if>
<if test="record.ctime != null">
ctime = #{record.ctime,jdbcType=BIGINT},
</if>
<if test="record.content != null">
content = #{record.content,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update user
set id = #{record.id,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR},
nickname = #{record.nickname,jdbcType=VARCHAR},
sex = #{record.sex,jdbcType=INTEGER},
ctime = #{record.ctime,jdbcType=BIGINT},
content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update user
set id = #{record.id,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR},
nickname = #{record.nickname,jdbcType=VARCHAR},
sex = #{record.sex,jdbcType=INTEGER},
ctime = #{record.ctime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.model.User">
update user
<set>
<if test="username != null">
username = #{username,jdbcType=VARCHAR},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=INTEGER},
</if>
<if test="ctime != null">
ctime = #{ctime,jdbcType=BIGINT},
</if>
<if test="content != null">
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.zheng.cms.model.User">
update user
set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR},
nickname = #{nickname,jdbcType=VARCHAR},
sex = #{sex,jdbcType=INTEGER},
ctime = #{ctime,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.model.User">
update user update user
set username = #{username,jdbcType=VARCHAR}, set username = #{username,jdbcType=VARCHAR},
password = #{password,jdbcType=VARCHAR}, password = #{password,jdbcType=VARCHAR},

View File

@ -31,10 +31,10 @@ public class UserServiceTest {
public void index() { public void index() {
// 自定义接口调用 // 自定义接口调用
UserVO userVO = userService.selectUserWithBook(1); UserVO userVO = userService.selectUserWithBook(1);
System.out.println(userVO.getBooks().size()); System.out.println(null == userVO ? "null" : userVO.getBooks().size());
// 自动生成接口调用 // 自动生成接口调用
User user = userService.getMapper().selectByPrimaryKey(1); User user = userService.getMapper().selectByPrimaryKey(1);
System.out.println(user.getNickname()); System.out.println(null == user ? "null" :user.getNickname());
} }
} }