<?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.SysWorktimeDao">
|
|
<resultMap type="SysWorktime" id="SysWorktimeMap">
|
<id property="id" column="id" />
|
<result property="shopId" column="shop_id" />
|
<result property="name" column="name"/>
|
<result property="startTime" column="start_time" />
|
<result property="endTime" column="end_time" />
|
<!-- 扩展属性 -->
|
<result property="shopName" column="shopName" />
|
</resultMap>
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="SysWorktime"
|
useGeneratedKeys="true" keyProperty="id">
|
INSERT INTO sys_worktime (
|
id,
|
shop_id,
|
start_time,
|
end_time,
|
name
|
)
|
VALUES (
|
#{id},
|
#{shopId},
|
#{startTime},
|
#{endTime},
|
#{name}
|
)
|
</insert>
|
|
|
<!-- 根据id更新 部分更新 -->
|
<update id="update" >
|
UPDATE sys_worktime
|
<set>
|
<if test="shopId != null and shopId !='' ">
|
shop_id = #{shopId},
|
</if>
|
<if test="startTime != null ">
|
start_time = #{startTime},
|
</if>
|
<if test="endTime != null ">
|
end_time = #{endTime},
|
</if>
|
<if test="name != null and name !='' ">
|
name = #{name}
|
</if>
|
</set>
|
WHERE id=#{id}
|
</update>
|
|
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from sys_worktime where id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<!-- 根据id删除-->
|
<delete id="deleteById" >
|
DELETE FROM sys_worktime
|
where id=#{id}
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="SysWorktimeMap">
|
select
|
id,
|
shop_id,
|
start_time,
|
end_time,
|
name,
|
(select shop_name from sys_shop_info b where shop_id=b.id) shopName
|
from sys_worktime
|
where 1=1
|
<if test="record!=null">
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id =#{record.shopId}
|
</if>
|
</if>
|
order by start_time
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<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 sys_worktime
|
where 1=1
|
<if test="record!=null">
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id =#{record.shopId}
|
</if>
|
</if>
|
</select>
|
|
<!-- 根据id查询-->
|
<select id="selectById" resultMap="SysWorktimeMap">
|
select
|
id,
|
shop_id,
|
start_time,
|
end_time,
|
name,
|
(select shop_name from sys_shop_info b where shop_id=b.id) shopName
|
from sys_worktime
|
where id=#{id} order by start_time
|
</select>
|
<!-- 根据id查询-->
|
<select id="findShopId" resultMap="SysWorktimeMap">
|
select
|
id,
|
shop_id,
|
start_time,
|
end_time,
|
name,
|
(select shop_name from sys_shop_info b where shop_id=b.id) shopName
|
from sys_worktime
|
where shop_id=#{shopId}
|
order by start_time
|
</select>
|
<!-- 根据对象查询-->
|
<select id="selectByModel" resultMap="SysWorktimeMap">
|
select
|
id,
|
shop_id,
|
start_time,
|
end_time,
|
name,
|
(select shop_name from sys_shop_info b where shop_id=b.id) shopName
|
from sys_worktime
|
where 1=1
|
<if test="record!=null">
|
<if test="record.shopId != null and record.shopId !='' ">
|
and shop_id =#{record.shopId}
|
</if>
|
</if>
|
order by start_time
|
</select>
|
|
<!-- 最晚下班时间 -->
|
<select id="selectMaxTime" resultType="java.util.Date">
|
SELECT MAX(end_time) from sys_worktime where shop_id=#{shopId};
|
</select>
|
<!-- 最早上班时间 -->
|
<select id="selectMinTime" resultType="java.util.Date">
|
SELECT MIN(start_time) from sys_worktime where shop_id=#{shopId};
|
</select>
|
|
|
|
</mapper>
|