ganzi-api/inventory-dao/src/main/resources/mapper/DynamicMapper.xml
2022-09-16 15:07:17 +08:00

384 lines
14 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="com.rzyc.mapper.DynamicMapper">
<resultMap id="BaseResultMap" type="com.rzyc.model.Dynamic">
<id column="DynamicId" jdbcType="VARCHAR" property="dynamicid" />
<result column="Cover" jdbcType="VARCHAR" property="cover" />
<result column="DynamicType" jdbcType="INTEGER" property="dynamictype" />
<result column="Title" jdbcType="VARCHAR" property="title" />
<result column="unitName" jdbcType="VARCHAR" property="unitName" />
<result column="CreatedOn" jdbcType="TIMESTAMP" property="createdon" />
<result column="CreatedBy" jdbcType="VARCHAR" property="createdby" />
<result column="ModifiedOn" jdbcType="TIMESTAMP" property="modifiedon" />
<result column="ModifiedBy" jdbcType="VARCHAR" property="modifiedby" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.rzyc.model.Dynamic">
<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">
DynamicId, Cover, DynamicType, Title, unitName,CreatedOn, CreatedBy, ModifiedOn, ModifiedBy
</sql>
<sql id="Blob_Column_List">
Content
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.rzyc.model.DynamicExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from Dynamic
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.rzyc.model.DynamicExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from Dynamic
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
<if test="limit != null">
<if test="offset != null">
limit ${offset}, ${limit}
</if>
<if test="offset == null">
limit ${limit}
</if>
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from Dynamic
where DynamicId = #{dynamicid,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from Dynamic
where DynamicId = #{dynamicid,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.rzyc.model.DynamicExample">
delete from Dynamic
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.rzyc.model.Dynamic">
insert into Dynamic (DynamicId, Cover, DynamicType,
Title, unitName,CreatedOn, CreatedBy,
ModifiedOn, ModifiedBy, Content
)
values (#{dynamicid,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR}, #{dynamictype,jdbcType=INTEGER},
#{title,jdbcType=VARCHAR},
#{unitName,jdbcType=VARCHAR},
#{createdon,jdbcType=TIMESTAMP}, #{createdby,jdbcType=VARCHAR},
#{modifiedon,jdbcType=TIMESTAMP}, #{modifiedby,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.rzyc.model.Dynamic">
insert into Dynamic
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="dynamicid != null">
DynamicId,
</if>
<if test="cover != null">
Cover,
</if>
<if test="dynamictype != null">
DynamicType,
</if>
<if test="title != null">
Title,
</if>
<if test="unitName != null">
unitName,
</if>
<if test="createdon != null">
CreatedOn,
</if>
<if test="createdby != null">
CreatedBy,
</if>
<if test="modifiedon != null">
ModifiedOn,
</if>
<if test="modifiedby != null">
ModifiedBy,
</if>
<if test="content != null">
Content,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="dynamicid != null">
#{dynamicid,jdbcType=VARCHAR},
</if>
<if test="cover != null">
#{cover,jdbcType=VARCHAR},
</if>
<if test="dynamictype != null">
#{dynamictype,jdbcType=INTEGER},
</if>
<if test="title != null">
#{title,jdbcType=VARCHAR},
</if>
<if test="unitName != null">
#{unitName,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
#{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
#{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
#{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
#{modifiedby,jdbcType=VARCHAR},
</if>
<if test="content != null">
#{content,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.rzyc.model.DynamicExample" resultType="java.lang.Long">
select count(*) from Dynamic
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update Dynamic
<set>
<if test="record.dynamicid != null">
DynamicId = #{record.dynamicid,jdbcType=VARCHAR},
</if>
<if test="record.cover != null">
Cover = #{record.cover,jdbcType=VARCHAR},
</if>
<if test="record.dynamictype != null">
DynamicType = #{record.dynamictype,jdbcType=INTEGER},
</if>
<if test="record.title != null">
Title = #{record.title,jdbcType=VARCHAR},
</if>
<if test="record.unitName != null">
unitName = #{record.unitName,jdbcType=VARCHAR},
</if>
<if test="record.createdon != null">
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
</if>
<if test="record.createdby != null">
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
</if>
<if test="record.modifiedon != null">
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="record.modifiedby != null">
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
</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 Dynamic
set DynamicId = #{record.dynamicid,jdbcType=VARCHAR},
Cover = #{record.cover,jdbcType=VARCHAR},
DynamicType = #{record.dynamictype,jdbcType=INTEGER},
Title = #{record.title,jdbcType=VARCHAR},
unitName = #{record.unitName,jdbcType=VARCHAR},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR},
Content = #{record.content,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update Dynamic
set DynamicId = #{record.dynamicid,jdbcType=VARCHAR},
Cover = #{record.cover,jdbcType=VARCHAR},
DynamicType = #{record.dynamictype,jdbcType=INTEGER},
Title = #{record.title,jdbcType=VARCHAR},
unitName = #{record.unitName,jdbcType=VARCHAR},
CreatedOn = #{record.createdon,jdbcType=TIMESTAMP},
CreatedBy = #{record.createdby,jdbcType=VARCHAR},
ModifiedOn = #{record.modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{record.modifiedby,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.rzyc.model.Dynamic">
update Dynamic
<set>
<if test="cover != null">
Cover = #{cover,jdbcType=VARCHAR},
</if>
<if test="dynamictype != null">
DynamicType = #{dynamictype,jdbcType=INTEGER},
</if>
<if test="title != null">
Title = #{title,jdbcType=VARCHAR},
</if>
<if test="unitName != null">
unitName = #{unitName,jdbcType=VARCHAR},
</if>
<if test="createdon != null">
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
</if>
<if test="createdby != null">
CreatedBy = #{createdby,jdbcType=VARCHAR},
</if>
<if test="modifiedon != null">
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
</if>
<if test="modifiedby != null">
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
</if>
<if test="content != null">
Content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where DynamicId = #{dynamicid,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.rzyc.model.Dynamic">
update Dynamic
set Cover = #{cover,jdbcType=VARCHAR},
DynamicType = #{dynamictype,jdbcType=INTEGER},
Title = #{title,jdbcType=VARCHAR},
unitName = #{unitName,jdbcType=VARCHAR},
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
CreatedBy = #{createdby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR},
Content = #{content,jdbcType=LONGVARCHAR}
where DynamicId = #{dynamicid,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.rzyc.model.Dynamic">
update Dynamic
set Cover = #{cover,jdbcType=VARCHAR},
DynamicType = #{dynamictype,jdbcType=INTEGER},
Title = #{title,jdbcType=VARCHAR},
unitName = #{unitName,jdbcType=VARCHAR},
CreatedOn = #{createdon,jdbcType=TIMESTAMP},
CreatedBy = #{createdby,jdbcType=VARCHAR},
ModifiedOn = #{modifiedon,jdbcType=TIMESTAMP},
ModifiedBy = #{modifiedby,jdbcType=VARCHAR}
where DynamicId = #{dynamicid,jdbcType=VARCHAR}
</update>
<!--动态分页-->
<select id="dynamicPage" resultMap="ResultMapWithBLOBs">
SELECT <include refid="Base_Column_List" />
FROM `Dynamic` da WHERE
(da.Title LIKE #{condition}
or da.Content LIKE #{condition})
<if test="null != dynamicType and '' != dynamicType">
AND da.DynamicType = #{dynamicType}
</if>
ORDER BY da.CreatedOn DESC LIMIT #{start},#{end}
</select>
<!--动态总数-->
<select id="countDynamic" resultType="java.lang.Long">
SELECT count(1) FROM `Dynamic` da WHERE
(da.Title LIKE #{condition}
or da.Content LIKE #{condition})
<if test="null != dynamicType and '' != dynamicType">
AND da.DynamicType = #{dynamicType}
</if>
</select>
<!--动态详情-->
<select id="dynamicDetail" resultMap="ResultMapWithBLOBs">
SELECT * FROM `Dynamic` da WHERE da.DynamicId = #{dynamicId};
</select>
<!--最新动态-->
<select id="newestDynamic" resultMap="ResultMapWithBLOBs">
SELECT * FROM `Dynamic` da ORDER BY da.`CreatedOn` DESC LIMIT 1
</select>
</mapper>