| <?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.hive.dao.SysSkinCheckRecordDao"> | 
|     <!-- 定义SysSkinCheckRecord 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.hive.bean.SysSkinCheckRecord" id="SysSkinCheckRecordMap"> | 
|         <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="shopId" column="shop_id" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="checkContent" column="check_content" /> | 
|         <result property="checkUser" column="check_user" /> | 
|         <result property="checkTime" column="check_time" /> | 
|         <result property="shopName" column="shopName" /> | 
|         <result property="telphone" column="telphone" /> | 
|         <result property="checkUserName" column="checkUserName" /> | 
|         <result property="userName" column="userName" /> | 
|             <result property="ext1" column="ext1" /> | 
|             <result property="ext2" column="ext2" /> | 
|             <result property="ext3" column="ext3" /> | 
|             <result property="ext4" column="ext4" /> | 
|         <result property="ext5" column="ext5" /> | 
|         <result property="sex" column="sex" /> | 
|         <collection property="skinDetails" ofType="com.matrix.system.hive.bean.SysSkinDetail" column="id"> | 
|             <id property="id" column="detailId" /> | 
|             <result property="checkId" column="check_id" /> | 
|             <result property="symptom" column="symptom" /> | 
|             <result property="percentage" column="percentage" /> | 
|             <result property="analysis" column="analysis" /> | 
|             <result property="solution" column="solution" /> | 
|             <result property="productIds" column="product_ids" /> | 
|             <result property="img" column="img" /> | 
|         </collection> | 
|         <collection property="analysisDetail" ofType="com.matrix.system.hive.bean.SysSkinDetail" column="id"> | 
|             <id property="id" column="analysisId" /> | 
|             <result property="checkId" column="check_id" /> | 
|             <result property="symptom" column="analysisSymptom" /> | 
|             <result property="percentage" column="analysisPercentage" /> | 
|             <result property="analysis" column="analysisAnalysis" /> | 
|             <result property="img" column="analysisImg" /> | 
|         </collection> | 
|      </resultMap> | 
|      | 
|      | 
|     <!-- 定义SysSkinCheckRecord 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.hive.bean.SysSkinCheckRecord" id="SysSkinCheckRecordSimpleMap"> | 
|         <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="shopId" column="shop_id" /> | 
|             <result property="userId" column="user_id" /> | 
|             <result property="checkContent" column="check_content" /> | 
|             <result property="checkUser" column="check_user" /> | 
|             <result property="ext1" column="ext1" /> | 
|             <result property="ext2" column="ext2" /> | 
|             <result property="ext3" column="ext3" /> | 
|             <result property="ext4" column="ext4" /> | 
|             <result property="ext5" column="ext5" /> | 
|     </resultMap> | 
|      | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             shop_id, | 
|             user_id, | 
|             check_content, | 
|             check_user, | 
|             telphone, | 
|             check_time, | 
|             ext1, | 
|             ext2, | 
|             ext3, | 
|             ext4, | 
|             ext5 | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.shopId}, | 
|             #{item.userId}, | 
|             #{item.checkContent}, | 
|             #{item.checkUser}, | 
|             #{item.telphone}, | 
|             #{item.checkTime}, | 
|             #{item.ext1}, | 
|             #{item.ext2}, | 
|             #{item.ext3}, | 
|             #{item.ext4}, | 
|             #{item.ext5} | 
|     </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.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                 and shop_id  = #{record.shopId} | 
|             </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.checkContent!=null and record.checkContent!='') or  (record.checkContent!='' and record.checkContent==0)  "> | 
|                 and check_content  = #{record.checkContent} | 
|             </if> | 
|             <if test="(record.checkUser!=null and record.checkUser!='') or  (record.checkUser!='' and record.checkUser==0)  "> | 
|                 and check_user  = #{record.checkUser} | 
|             </if> | 
|             <if test="(record.ext1!=null and record.ext1!='') or  (record.ext1!='' and record.ext1==0)  "> | 
|                 and ext1  = #{record.ext1} | 
|             </if> | 
|             <if test="(record.ext2!=null and record.ext2!='') or  (record.ext2!='' and record.ext2==0)  "> | 
|                 and ext2  = #{record.ext2} | 
|             </if> | 
|             <if test="(record.ext3!=null and record.ext3!='') or  (record.ext3!='' and record.ext3==0)  "> | 
|                 and ext3  = #{record.ext3} | 
|             </if> | 
|             <if test="(record.ext4!=null and record.ext4!='') or  (record.ext4!='' and record.ext4==0)  "> | 
|                 and ext4  = #{record.ext4} | 
|             </if> | 
|             <if test="(record.ext5!=null and record.ext5!='') or  (record.ext5!='' and record.ext5==0)  "> | 
|                 and ext5  = #{record.ext5} | 
|             </if> | 
|         </if> | 
|           | 
|     </sql> | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.hive.bean.SysSkinCheckRecord" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO sys_skin_check_record ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO sys_skin_check_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 sys_skin_check_record | 
|         <set> | 
|             <if test="_parameter.containsKey('shopId')"> | 
|                     shop_id = #{shopId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('userId')"> | 
|                     user_id = #{userId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('checkContent')"> | 
|                     check_content = #{checkContent}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('checkUser')"> | 
|                     check_user = #{checkUser}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('ext1')"> | 
|                     ext1 = #{ext1}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('ext2')"> | 
|                     ext2 = #{ext2}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('ext3')"> | 
|                     ext3 = #{ext3}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('ext4')"> | 
|                     ext4 = #{ext4}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('ext5')"> | 
|                     ext5 = #{ext5}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Long"> | 
|         UPDATE sys_skin_check_record | 
|         <set> | 
|             <if test="record.shopId != null "> | 
|                 shop_id  = #{record.shopId},  | 
|             </if> | 
|             <if test="record.userId != null "> | 
|                 user_id  = #{record.userId},  | 
|             </if> | 
|             <if test="record.checkContent != null and record.checkContent != '' "> | 
|                 check_content  = #{record.checkContent},  | 
|             </if> | 
|             <if test="record.checkUser != null "> | 
|                 check_user  = #{record.checkUser}, | 
|             </if> | 
|             <if test="record.checkTime != null "> | 
|                 check_time  = #{record.checkTime}, | 
|             </if> | 
|             <if test="record.ext1 != null and record.ext1 != '' "> | 
|                 ext1  = #{record.ext1},  | 
|             </if> | 
|             <if test="record.ext2 != null and record.ext2 != '' "> | 
|                 ext2  = #{record.ext2},  | 
|             </if> | 
|             <if test="record.ext3 != null and record.ext3 != '' "> | 
|                 ext3  = #{record.ext3},  | 
|             </if> | 
|             <if test="record.ext4 != null and record.ext4 != '' "> | 
|                 ext4  = #{record.ext4},  | 
|             </if> | 
|             <if test="record.ext5 != null and record.ext5 != '' "> | 
|                 ext5  = #{record.ext5},  | 
|             </if> | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from sys_skin_check_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 sys_skin_check_record | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.hive.bean.SysSkinCheckRecord"> | 
|         DELETE FROM sys_skin_check_record | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="SysSkinCheckRecordMap"> | 
|         select  t1.*, t2.vip_name userName, t3.shop_name shopName, t4.su_name checkUserName | 
|         from sys_skin_check_record t1 | 
|         inner join sys_vip_info t2 on t1.user_id=t2.id | 
|         inner join sys_shop_info t3 on t1.shop_id=t3.id | 
|         inner join sys_users t4 on t1.check_user=t4.su_id | 
|         <where> | 
|             <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.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                     and t1.shop_id  = #{record.shopId} | 
|                 </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.checkContent!=null and record.checkContent!='') or  (record.checkContent!='' and record.checkContent==0)  "> | 
|                     and check_content  = #{record.checkContent} | 
|                 </if> | 
|                 <if test="(record.checkUser!=null and record.checkUser!='') or  (record.checkUser!='' and record.checkUser==0)  "> | 
|                     and check_user  = #{record.checkUser} | 
|                 </if> | 
|                 <if test="(record.telphone!=null and record.telphone!='') or  (record.telphone!='' and record.telphone==0)  "> | 
|                     and telphone  = #{record.telphone} | 
|                 </if> | 
|                 <if test="record.beginTime != null and record.endTime!=null"> | 
|                     and (date(check_time) between #{record.beginTime} and #{record.endTime}) | 
|                 </if> | 
|             </if> | 
|          </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 sys_skin_check_record t1 | 
|         <where><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.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  "> | 
|                 and t1.shop_id  = #{record.shopId} | 
|             </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.checkContent!=null and record.checkContent!='') or  (record.checkContent!='' and record.checkContent==0)  "> | 
|                 and check_content  = #{record.checkContent} | 
|             </if> | 
|             <if test="(record.checkUser!=null and record.checkUser!='') or  (record.checkUser!='' and record.checkUser==0)  "> | 
|                 and check_user  = #{record.checkUser} | 
|             </if> | 
|             <if test="(record.telphone!=null and record.telphone!='') or  (record.telphone!='' and record.telphone==0)  "> | 
|                 and telphone  = #{record.telphone} | 
|             </if> | 
|             <if test="record.beginTime != null and record.endTime!=null"> | 
|                 and (date(check_time) between #{record.beginTime} and #{record.endTime}) | 
|             </if> | 
|         </if> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="SysSkinCheckRecordMap"> | 
|         select | 
|             t1.*, | 
|             t2.id detailId, | 
|             t2.symptom, | 
|             t2.percentage, | 
|             t2.analysis, | 
|             t2.solution, | 
|             t2.product_ids, | 
|             t2.img, | 
|             t3.id analysisId, | 
|             t3.symptom analysisSymptom, | 
|             t3.percentage analysisPercentage, | 
|             t3.analysis analysisAnalysis, | 
|             t3.img analysisImg, | 
|             t4.vip_name userName, | 
|             t4.sex sex | 
|         from sys_skin_check_record t1 | 
|         left join sys_skin_detail t2 on t1.id=t2.check_id and t2.t1=1 | 
|         left join sys_skin_detail t3 on t1.id=t3.check_id and t3.t1=2 | 
|         left join sys_vip_info t4 on t1.user_id=t4.id | 
|         where  t1.id=#{id} | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="SysSkinCheckRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from sys_skin_check_record | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="SysSkinCheckRecordMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from sys_skin_check_record | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
| </mapper> |