| <?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.ShopActivitiesSalonAttrRecordDao"> | 
|     <!-- 定义ShopActivitiesSalonAttrRecord 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopActivitiesSalonAttrRecord" id="ShopActivitiesSalonAttrRecordMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="attrName" column="attr_name" /> | 
|         <result property="attrValue" column="attr_value" /> | 
|         <result property="asrId" column="asr_id" /> | 
|         <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|   | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         id, | 
|         attr_name, | 
|         attr_value, | 
|         asr_id, | 
|         company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.id}, | 
|         #{item.attrName}, | 
|         #{item.attrValue}, | 
|         #{item.asrId}, | 
|         #{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.attrName!=null and record.attrName!='') or  (record.attrName!='' and record.attrName==0)  "> | 
|                 and attr_name  = #{record.attrName} | 
|             </if> | 
|         </if> | 
|           | 
|     </sql> | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSalonAttrRecord" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO shop_activities_salon_attr_record ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_activities_salon_attr_record ( | 
|         <include refid="columns"></include>     | 
|         ) | 
|     VALUES  | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|         <include refid="propertys"></include>     | 
|     )</foreach> | 
|     </insert> | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Long"> | 
|         UPDATE shop_activities_salon_attr_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> | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_activities_salon_attr_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_attr_record | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSalonAttrRecord"> | 
|         DELETE FROM shop_activities_salon_attr_record | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShopActivitiesSalonAttrRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_salon_attr_record | 
|         <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> | 
|             <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_attr_record | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopActivitiesSalonAttrRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_salon_attr_record | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopActivitiesSalonAttrRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_salon_attr_record | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopActivitiesSalonAttrRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_salon_attr_record | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
|   | 
|     <select id="selectByActId" resultMap="ShopActivitiesSalonAttrRecordMap"> | 
|         select * from shop_activities_salon_attr_record | 
|         where act_id=#{actId} | 
|     </select> | 
| </mapper> |