<?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.matrix.system.shopXcx.dao.ShopProductParamDao">
|
<!-- 定义ShopProductParam 的复杂关联map -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopProductParam" id="ShopProductParamMap">
|
<id property="paramId" column="param_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="paramName" column="param_name" />
|
<result property="paramType" column="param_type" />
|
<result property="isStart" column="is_start" />
|
<result property="sort" column="sort" />
|
<result property="companyId" column="company_id" />
|
</resultMap>
|
|
|
<!-- 定义ShopProductParam 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopProductParam" id="ShopProductParamSimpleMap">
|
<id property="paramId" column="param_id" />
|
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time" />
|
<result property="paramName" column="param_name" />
|
<result property="paramType" column="param_type" />
|
<result property="isStart" column="is_start" />
|
<result property="sort" column="sort" />
|
<result property="companyId" column="company_id" />
|
</resultMap>
|
|
<!-- 字段sql -->
|
<sql id="columns">
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
param_id,
|
param_name,
|
param_type,
|
is_start,
|
sort,
|
company_id
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.createBy},
|
now(),
|
#{item.updateBy},
|
now(),
|
#{item.paramId},
|
#{item.paramName},
|
#{item.paramType},
|
#{item.isStart},
|
#{item.sort},
|
#{item.companyId}
|
</sql>
|
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0) ">
|
and param_id = #{record.paramId}
|
</if>
|
<if test="(record.paramName!=null and record.paramName!='') or (record.paramName!='' and record.paramName==0) ">
|
and param_name like concat('%',#{record.paramName},'%')
|
</if>
|
<if test="(record.paramType!=null and record.paramType!='') or (record.paramType!='' and record.paramType==0) ">
|
and param_type = #{record.paramType}
|
</if>
|
<if test="(record.isStart!=null and record.isStart!='') or (record.isStart!='' and record.isStart==0) ">
|
and is_start = #{record.isStart}
|
</if>
|
<if test="(record.sort!=null and record.sort!='') or (record.sort!='' and record.sort==0) ">
|
and sort = #{record.sort}
|
</if>
|
|
<if test="record.companyId != null and record.companyId !='' ">
|
and company_id = #{record.companyId}
|
</if>
|
</if>
|
|
</sql>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopProductParam"
|
useGeneratedKeys="true" keyProperty="item.paramId">
|
INSERT INTO shop_product_param (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shop_product_param (
|
<include refid="columns"></include>
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
<include refid="propertys"></include>
|
)</foreach>
|
</insert>
|
|
|
|
|
|
<!-- 根据Map更新 部分更新 -->
|
<update id="updateByMap" parameterType="java.util.HashMap" >
|
UPDATE shop_product_param
|
<set>
|
param_name = #{paramName},
|
|
param_type = #{paramType},
|
|
is_start = #{isStart},
|
|
sort = #{sort},
|
</set>
|
WHERE param_id=#{paramId}
|
</update>
|
|
|
<!--根据id批量修改-->
|
<update id="updateByIds" parameterType="java.util.List">
|
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
update shop_product_param
|
<set>
|
<if test="status != null ">
|
is_start = #{status},
|
</if>
|
</set>
|
where param_id = #{item}
|
</foreach>
|
</update>
|
|
<!-- 根据对象更新 部分更新 -->
|
<update id="updateByModel" parameterType="Integer">
|
UPDATE shop_product_param
|
<set>
|
<if test="record.paramName != null and record.paramName != '' ">
|
param_name = #{record.paramName},
|
</if>
|
<if test="record.paramType != null ">
|
param_type = #{record.paramType},
|
</if>
|
<if test="record.isStart != null ">
|
is_start = #{record.isStart},
|
</if>
|
sort = #{record.sort},
|
</set>
|
WHERE param_id=#{record.paramId}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shop_product_param where param_id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" parameterType="Integer">
|
DELETE FROM shop_product_param
|
where param_id=#{paramId}
|
</delete>
|
|
<!-- 根据对象删除-->
|
<delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopProductParam">
|
DELETE FROM shop_product_param
|
<where>
|
<include refid="where_sql" ></include>
|
</where>
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShopProductParamMap">
|
select
|
<include refid="columns" ></include>
|
from shop_product_param
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<!--<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>-->
|
<choose>
|
<when test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</when>
|
<otherwise>
|
order by sort
|
</otherwise>
|
</choose>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer">
|
select count(*)
|
from shop_product_param
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="ShopProductParamMap">
|
select
|
<include refid="columns" ></include>
|
from shop_product_param
|
where param_id=#{paramId}
|
</select>
|
|
|
<!-- 根据id 锁表查询-->
|
<select id="selectForUpdate" resultMap="ShopProductParamMap">
|
select
|
<include refid="columns" ></include>
|
from shop_product_param
|
where param_id=#{param_id}
|
for update
|
</select>
|
|
|
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="ShopProductParamMap">
|
select
|
<include refid="columns" ></include>
|
from shop_product_param
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
order by sort
|
</select>
|
</mapper>
|