| <?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.LastestWorkBeatuistaffDao"> | 
|     <!-- 定义LastestWorkBeatuistaff 的复杂关联map --> | 
|     <resultMap type="LastestWorkBeatuistaff" id="LastestWorkBeatuistaffMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="staffId" column="staff_id" /> | 
|             <result property="staffName" column="staff_name" /> | 
|             <result property="changeDate" column="change_date" /> | 
|             <result property="shopId" column="shop_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义LastestWorkBeatuistaff 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="LastestWorkBeatuistaff" id="LastestWorkBeatuistaffSimpleMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="staffId" column="staff_id" /> | 
|             <result property="staffName" column="staff_name" /> | 
|             <result property="changeDate" column="change_date" /> | 
|             <result property="shopId" column="shop_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="LastestWorkBeatuistaff" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO lastest_work_beatuistaff ( | 
|             id, | 
|             staff_id, | 
|             staff_name, | 
|             change_date, | 
|             shop_id | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{staffId}, | 
|             #{staffName}, | 
|             #{changeDate}, | 
|             #{shopId} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO lastest_work_beatuistaff ( | 
|             id, | 
|             staff_id, | 
|             staff_name, | 
|             change_date, | 
|             shop_id | 
|         ) | 
|     VALUES  | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|             #{item.id}, | 
|             #{item.staffId}, | 
|             #{item.staffName}, | 
|             #{item.changeDate}, | 
|             #{item.shopId} | 
|     )</foreach> | 
|     </insert> | 
|      | 
|      | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE lastest_work_beatuistaff | 
|         <set> | 
|                 <if test="(staffId!=null and staffId!='') or (staffId!='' and staffId==0)"> | 
|                     staff_id = #{staffId}, | 
|                 </if>         | 
|                 <if test="(staffName!=null and staffName!='') or (staffName!='' and staffName==0)"> | 
|                     staff_name = #{staffName}, | 
|                 </if>         | 
|                 <if test="(changeDate!=null and changeDate!='') or (changeDate!='' and changeDate==0)"> | 
|                     change_date = #{changeDate}, | 
|                 </if> | 
|                 <if test="(shopId!=null and shopId!='') or (shopId!='' and shopId==0)"> | 
|                     shop_id = #{shopId}, | 
|                 </if> | 
|                          | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from lastest_work_beatuistaff where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM lastest_work_beatuistaff | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" > | 
|         DELETE FROM lastest_work_beatuistaff | 
|         where 1=1 | 
|         <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.staffId!=null and record.staffId!='') or (record.staffId!='' and record.staffId==0)"> | 
|                 and staff_id = #{record.staffId}  | 
|             </if> | 
|             <if test="(record.staffName!=null and record.staffName!='') or (record.staffName!='' and record.staffName==0)"> | 
|                 and staff_name = #{record.staffName}  | 
|             </if> | 
|             <if test="record.changeDate!=null  "> | 
|                 and change_date = #{record.changeDate}  | 
|             </if> | 
|             <if test="(record.shopId!=null and record.shopId!='') or (record.shopId!='' and record.shopId==0)"> | 
|                 and shop_id = #{record.shopId}  | 
|             </if> | 
|         </if> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="LastestWorkBeatuistaffMap"> | 
|         select  | 
|             id, | 
|             staff_id, | 
|             change_date, | 
|             shop_id, | 
|             (select su_name from sys_users t where t.su_id=f.staff_id) as staff_name | 
|         from lastest_work_beatuistaff f | 
|         where 1=1 | 
|         <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.staffId!=null and record.staffId!='') or (record.staffId!='' and record.staffId==0)"> | 
|                 and f.staff_id  = #{record.staffId} | 
|             </if> | 
|             <if test="(record.staffName!=null and record.staffName!='') or (record.staffName!='' and record.staffName==0)"> | 
|                 and staff_name  = #{record.staffName}  | 
|             </if> | 
|             <if test="record.changeDate!=null  "> | 
|                 and change_date  = #{record.changeDate}  | 
|             </if> | 
|             <if test="(record.shopId!=null and record.shopId!='') or (record.shopId!='' and record.shopId==0)"> | 
|                 and shop_id = #{record.shopId}  | 
|             </if> | 
|         </if> | 
|         <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"    resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from lastest_work_beatuistaff | 
|         where 1=1 | 
|         <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.staffId!=null and record.staffId!='') or (record.staffId!='' and record.staffId==0)"> | 
|             and staff_id = #{record.staffId}  | 
|             </if> | 
|             <if test="(record.staffName!=null and record.staffName!='') or (record.staffName!='' and record.staffName==0)"> | 
|             and staff_name = #{record.staffName}  | 
|             </if> | 
|             <if test="record.changeDate!=null  "> | 
|             and change_date = #{record.changeDate}  | 
|             </if> | 
|             <if test="(record.shopId!=null and record.shopId!='') or (record.shopId!='' and record.shopId==0)"> | 
|                 and shop_id = #{record.shopId}  | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="LastestWorkBeatuistaffMap"> | 
|         select  | 
|             id, | 
|             staff_id, | 
|             change_date, | 
|             shop_id, | 
|             (select su_name from sys_users t where t.su_id=f.staff_id) as staff_name | 
|         from lastest_work_beatuistaff f | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据对象查询 这里修改成只查询今天的--> | 
|     <select id="selectByModel" resultMap="LastestWorkBeatuistaffMap"> | 
|         select  | 
|             id, | 
|             f.staff_id, | 
|             change_date, | 
|             shop_id, | 
|             (select su_name from sys_users t where t.su_id=f.staff_id) as staff_name | 
|         from lastest_work_beatuistaff f | 
|         where change_date > date_format(now(),'%y-%m-%d') | 
|                 and shop_id = #{record.shopId}  | 
|     </select> | 
| </mapper> |