<?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.MasterCheckItemManageMapper">
<resultMap id="CheckItemManageMap" type="com.lyms.platform.permission.model.CheckItemManage">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="startweek" property="startWeek" jdbcType="INTEGER"/>
<result column="endweek" property="endWeek" jdbcType="INTEGER"/>
<result column="checkItemInfoId" property="checkItemInfoId" jdbcType="VARCHAR"/>
<result column="affiliate" property="affiliateId" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
</resultMap>
<select id="getCheckItemManageList" resultMap="CheckItemManageMap">
SELECT id,startweek,endweek,checkItemInfoId,affiliate,type from lyms_checkitem
</select>
<insert id="addCheckItem" parameterType="com.lyms.platform.permission.model.CheckItemManage">
<selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
INSERT INTO lyms_checkitem(startweek,endweek,checkItemInfoId,affiliate,modified,created,type)
VALUES(#{startWeek},#{endWeek},#{checkItemInfoId},#{affiliateId},#{modified},#{created},#{type})
</insert>
<select id="getCheckItemManage" resultMap="CheckItemManageMap" parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT id,startweek,endweek,checkItemInfoId,affiliate,type from lyms_checkitem where
affiliate=#{affiliateId}
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
</select>
<delete id="deleteCheckItemManage" parameterType="java.lang.Integer">
delete from lyms_checkitem where id = #{id,jdbcType=INTEGER}
</delete>
<update id="updateCheckItemManage" parameterType="com.lyms.platform.permission.model.CheckItemManage">
update lyms_checkitem
<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="checkItemInfoId!=null and checkItemInfoId!=''">
checkItemInfoId=#{checkItemInfoId,jdbcType=VARCHAR},
</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="queryCheckItemManage" resultMap="CheckItemManageMap"
parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT id,startweek,endweek,checkItemInfoId,affiliate,type from lyms_checkitem
<if test="affiliateId!=null and affiliateId!=''">
where
affiliate=#{affiliateId,jdbcType=VARCHAR}
</if>
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
<include refid="orderAndLimit"/>
</select>
<select id="queryCheckItemManageCount" resultType="int"
parameterType="com.lyms.platform.permission.model.CheckItemManageQuery">
SELECT count(id) from lyms_checkitem
<if test="affiliateId!=null and affiliateId!=''">
where
affiliate=#{affiliateId,jdbcType=VARCHAR}
</if>
<if test="type !=null">
and type=#{type,jdbcType=INTEGER}
</if>
</select>
</mapper>