<?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.ShopActivitiesSalonRecordDao">
|
<!-- 定义ShopActivitiesSalonRecord 的复杂关联map -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopActivitiesSalonRecord" id="ShopActivitiesSalonRecordMap">
|
<id property="id" column="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="actId" column="act_id" />
|
<result property="userId" column="user_id" />
|
<result property="remark" column="remark" />
|
<result property="status" column="status" />
|
<result property="nickName" column="nick_name" />
|
<result property="shopName" column="shop_short_name" />
|
<result property="phone" column="phone" />
|
<collection property="salonAttr" ofType="com.matrix.system.shopXcx.bean.ShopActivitiesSalonAttrRecord">
|
<id property="id" column="asd_id" />
|
<result property="attrName" column="attr_name" />
|
<result property="attrValue" column="attr_value" />
|
<result property="asrId" column="asr_id" />
|
</collection>
|
</resultMap>
|
|
|
<!-- 定义ShopActivitiesSalonRecord 的简单map ,本map不添加其他的关联属性 -->
|
<resultMap type="com.matrix.system.shopXcx.bean.ShopActivitiesSalonRecord" id="ShopActivitiesSalonRecordSimpleMap">
|
<id property="id" column="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="actId" column="act_id" />
|
<result property="userId" column="user_id" />
|
<result property="remark" column="remark" />
|
</resultMap>
|
|
<!-- 字段sql -->
|
<sql id="columns">
|
create_by,
|
create_time,
|
update_by,
|
update_time,
|
id,
|
act_id,
|
user_id,
|
remark,
|
shop_id,
|
status,
|
company_id
|
</sql>
|
|
<!-- 属性sql -->
|
<sql id="propertys">
|
#{item.createBy},
|
now(),
|
#{item.updateBy},
|
now(),
|
#{item.id},
|
#{item.actId},
|
#{item.userId},
|
#{item.remark},
|
#{item.shopId},
|
#{item.status},
|
#{item.companyId}
|
</sql>
|
|
<!-- where sql -->
|
<sql id="where_sql">
|
|
<if test="record!=null">
|
<if test="(record.id!=null and record.id!='') or (record.id!='' and record.id==0) ">
|
and id = #{record.id}
|
</if>
|
<if test="(record.companyId!=null and record.companyId!='') or (record.companyId!='' and record.companyId==0) ">
|
and company_id = #{record.companyId}
|
</if>
|
<if test="(record.actId!=null and record.actId!='') or (record.actId!='' and record.actId==0) ">
|
and act_id = #{record.actId}
|
</if>
|
<if test="(record.userId!=null and record.userId!='') or (record.userId!='' and record.userId==0) ">
|
and user_id = #{record.userId}
|
</if>
|
<if test="(record.remark!=null and record.remark!='') or (record.remark!='' and record.remark==0) ">
|
and remark = #{record.remark}
|
</if>
|
</if>
|
|
</sql>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSalonRecord"
|
useGeneratedKeys="true" keyProperty="item.id">
|
INSERT INTO shop_activities_salon_record (
|
<include refid="columns"></include>
|
)
|
VALUES (
|
<include refid="propertys"></include>
|
)
|
</insert>
|
|
|
|
<!-- 批量插入 -->
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO shop_activities_salon_record (
|
<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_activities_salon_record
|
<set>
|
<if test="_parameter.containsKey('actId')">
|
act_id = #{actId},
|
</if>
|
<if test="_parameter.containsKey('userId')">
|
user_id = #{userId},
|
</if>
|
<if test="_parameter.containsKey('remark')">
|
remark = #{remark},
|
</if>
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
<!-- 根据对象更新 部分更新 -->
|
<update id="updateByModel" parameterType="Long">
|
UPDATE shop_activities_salon_record
|
<set>
|
<if test="record.actId != null ">
|
act_id = #{record.actId},
|
</if>
|
<if test="record.userId != null ">
|
user_id = #{record.userId},
|
</if>
|
<if test="record.remark != null and record.remark != '' ">
|
remark = #{record.remark},
|
</if>
|
<if test="record.status != null and record.status != '' ">
|
status = #{record.status},
|
</if>
|
</set>
|
WHERE id=#{record.id}
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from shop_activities_salon_record where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" parameterType="Long">
|
DELETE FROM shop_activities_salon_record
|
where id=#{id}
|
</delete>
|
|
<!-- 根据对象删除-->
|
<delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSalonRecord">
|
DELETE FROM shop_activities_salon_record
|
<where>
|
<include refid="where_sql" ></include>
|
</where>
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="ShopActivitiesSalonRecordMap">
|
select t1.*, t3.nick_name, t3.phone, t4.shop_short_name, t2.id asd_id, t2.attr_name, t2.attr_value, t2.asr_id
|
from shop_activities_salon_record t1
|
inner join shop_activities_salon_attr_record t2 on t1.id=t2.asr_id
|
left join sys_vip_info t3 on t1.user_id=id
|
left join sys_shop_info t4 on t1.shop_id=t4.id
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
t1.${pageVo.sort} ${pageVo.order}
|
</if>
|
<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_activities_salon_record
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="ShopActivitiesSalonRecordMap">
|
select
|
<include refid="columns" ></include>
|
from shop_activities_salon_record
|
where id=#{id}
|
</select>
|
|
|
<!-- 根据id 锁表查询-->
|
<select id="selectForUpdate" resultMap="ShopActivitiesSalonRecordMap">
|
select
|
<include refid="columns" ></include>
|
from shop_activities_salon_record
|
where id=#{id}
|
for update
|
</select>
|
|
|
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="ShopActivitiesSalonRecordMap">
|
select
|
<include refid="columns" ></include>
|
from shop_activities_salon_record
|
<where>
|
<include refid="where_sql"></include>
|
</where>
|
</select>
|
|
<select id="selectSalonRecordByUserIdAndActId" resultMap="ShopActivitiesSalonRecordMap">
|
select * from shop_activities_salon_record
|
where user_id=#{userId} and act_id=#{actId}
|
</select>
|
</mapper>
|