<?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.lyms.platform.permission.dao.master.MasterCheckItemNoticeManageMapper">
<resultMap id="CheckItemNoticeManageMap" type="com.lyms.platform.permission.model.CheckItemNoticeManage">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="startweek" property="startWeek" jdbcType="INTEGER"/>
<result column="endweek" property="endWeek" jdbcType="INTEGER"/>
<result column="noticeinfo" property="noticeInfo" jdbcType="VARCHAR"/>
<result column="affiliate" property="affiliateId" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="enable" property="enable" jdbcType="INTEGER"/>
</resultMap>
<insert id="addCheckItemNoticeManage" parameterType="com.lyms.platform.permission.model.CheckItemNoticeManage">
<selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
INSERT INTO lyms_checkitem_notice(startweek,endweek,noticeinfo,affiliate,modified,created,type,enable)
VALUES(#{startWeek},#{endWeek},#{noticeInfo},#{affiliateId},#{modified},#{created},#{type},#{enable})
</insert>
<select id="getCheckItemNoticeManage" resultMap="CheckItemNoticeManageMap" parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT id,startweek,endweek,noticeinfo,affiliate,type from lyms_checkitem_notice
where affiliate=#{affiliateId}
and enable = 1
<if test="startNum !=null">
and startweek >= #{startNum,jdbcType=INTEGER}
and endweek <= #{startNum,jdbcType=INTEGER}
</if>a
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
</select>
<delete id="deleteCheckItemNoticeManage" parameterType="java.lang.Integer">
update lyms_checkitem_notice
set enable = 0
where id = #{id,jdbcType=INTEGER}
</delete>
<update id="updateCheckItemNoticeManage" parameterType="com.lyms.platform.permission.model.CheckItemNoticeManage">
update lyms_checkitem_notice
<set>
<if test="startWeek!=null and startWeek>=0">
startweek=#{startWeek,jdbcType=INTEGER},
</if>
<if test="endWeek!=null and endWeek>=0">
endweek=#{endWeek,jdbcType=INTEGER},
</if>
<if test="noticeinfo!=null and noticeinfo!=''">
noticeinfo=#{noticeInfo},
</if>
<if test="affiliateId!=null and affiliateId!=''">
affiliate=#{affiliateId,jdbcType=VARCHAR},
</if>
<if test="type != null">
type=#{type,jdbcType=INTEGER},
</if>
<if test="modified!=null">
modified=#{modified},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>
<select id="queryCheckItemNoticeManage" resultMap="CheckItemNoticeManageMap"
parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT id,startweek,endweek,noticeinfo,affiliate,type from lyms_checkitem_notice
where enable = 1
<if test="affiliateId!=null and affiliateId!=''">
and affiliate=#{affiliateId,jdbcType=VARCHAR}
</if>
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
<include refid="orderAndLimit"/>
</select>
<select id="queryCheckItemNoticeManageCount" resultType="int"
parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT count(id) from lyms_checkitem_notice
where enable = 1
<if test="affiliateId!=null and affiliateId!=''">
and affiliate=#{affiliateId,jdbcType=VARCHAR}
</if>
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
</select>
</mapper>