<?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.yanzhu.jh.project.mapper.SurProjectAttendanceGroupMapper">
    
    <resultMap type="SurProjectAttendanceGroup" id="SurProjectAttendanceGroupResult">
        <result property="id"    column="id"    />
        <result property="cfgid"    column="cfgid"    />
        <result property="appId"    column="app_id"    />
        <result property="serverid"    column="serverid"    />
        <result property="bizLicense"    column="bizLicense"    />
        <result property="companyCode"    column="companyCode"    />
        <result property="companyId"    column="companyId"    />
        <result property="companyName"    column="companyName"    />
        <result property="companyTypeId"    column="companyTypeId"    />
        <result property="vendorId"    column="vendorId"    />
        <result property="name"    column="name"    />
        <result property="leaderName"    column="leaderName"    />
        <result property="leaderPhone"    column="leaderPhone"    />
        <result property="teamId"    column="teamId"    />
        <result property="teamName"    column="teamName"    />
        <result property="type"    column="type"    />
        <result property="leaderId"    column="leaderId"    />
        <result property="deleted"    column="deleted"    />
        <result property="createTimestamp"    column="createTimestamp"    />
        <result property="platformGroupId"    column="platformGroupId"    />
        <result property="platformTeamId"    column="platformTeamId"    />
        <result property="enterDate"    column="enterDate"    />
        <result property="exitDate"    column="exitDate"    />
        <result property="remark"    column="remark"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectSurProjectAttendanceGroupVo">
        select id, cfgid, app_id, serverid, bizLicense, companyCode, companyId, companyName, companyTypeId, vendorId, name, leaderName, leaderPhone, teamId, teamName, type, leaderId, deleted, createTimestamp, platformGroupId, platformTeamId, enterDate, exitDate, remark, is_del, create_by, create_time, update_by, update_time
        from view_sur_project_attendance_group
    </sql>

    <select id="selectSurProjectAttendanceGroupViewList" parameterType="SurProjectAttendanceGroup" resultMap="SurProjectAttendanceGroupResult">
        <include refid="selectSurProjectAttendanceGroupVo"/>
        <where>  
            <if test="cfgid != null "> and cfgid = #{cfgid}</if>
            <if test="appId != null "> and app_id = #{appId}</if>
            <if test="serverid != null "> and serverid = #{serverid}</if>
            <if test="bizLicense != null  and bizLicense != ''"> and bizLicense = #{bizLicense}</if>
            <if test="companyCode != null  and companyCode != ''"> and companyCode = #{companyCode}</if>
            <if test="companyId != null "> and companyId = #{companyId}</if>
            <if test="companyName != null  and companyName != ''"> and companyName like concat('%', #{companyName}, '%')</if>
            <if test="companyTypeId != null  and companyTypeId != ''"> and companyTypeId = #{companyTypeId}</if>
            <if test="vendorId != null "> and vendorId = #{vendorId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="leaderName != null  and leaderName != ''"> and leaderName like concat('%', #{leaderName}, '%')</if>
            <if test="leaderPhone != null  and leaderPhone != ''"> and leaderPhone = #{leaderPhone}</if>
            <if test="teamId != null "> and teamId = #{teamId}</if>
            <if test="teamName != null  and teamName != ''"> and teamName like concat('%', #{teamName}, '%')</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="leaderId != null "> and leaderId = #{leaderId}</if>
            <if test="deleted != null "> and deleted = #{deleted}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="platformGroupId != null "> and platformGroupId = #{platformGroupId}</if>
            <if test="platformTeamId != null "> and platformTeamId = #{platformTeamId}</if>
            <if test="enterDate != null "> and enterDate = #{enterDate}</if>
            <if test="exitDate != null "> and exitDate = #{exitDate}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>

    <select id="selectSurProjectAttendanceGroupList" parameterType="SurProjectAttendanceGroup" resultMap="SurProjectAttendanceGroupResult">
        select id, cfgid, app_id, serverid, bizLicense, companyCode, companyId, companyName, companyTypeId, vendorId, name, leaderName, leaderPhone, teamId, teamName, type, leaderId, deleted, createTimestamp, platformGroupId, platformTeamId, enterDate, exitDate, remark, is_del, create_by, create_time, update_by, update_time
        from sur_project_attendance_group
        <where>
            <if test="cfgid != null "> and cfgid = #{cfgid}</if>
            <if test="appId != null "> and app_id = #{appId}</if>
            <if test="serverid != null "> and serverid = #{serverid}</if>
            <if test="bizLicense != null  and bizLicense != ''"> and bizLicense = #{bizLicense}</if>
            <if test="companyCode != null  and companyCode != ''"> and companyCode = #{companyCode}</if>
            <if test="companyId != null "> and companyId = #{companyId}</if>
            <if test="companyName != null  and companyName != ''"> and companyName like concat('%', #{companyName}, '%')</if>
            <if test="companyTypeId != null  and companyTypeId != ''"> and companyTypeId = #{companyTypeId}</if>
            <if test="vendorId != null "> and vendorId = #{vendorId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="leaderName != null  and leaderName != ''"> and leaderName like concat('%', #{leaderName}, '%')</if>
            <if test="leaderPhone != null  and leaderPhone != ''"> and leaderPhone = #{leaderPhone}</if>
            <if test="teamId != null "> and teamId = #{teamId}</if>
            <if test="teamName != null  and teamName != ''"> and teamName like concat('%', #{teamName}, '%')</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="leaderId != null "> and leaderId = #{leaderId}</if>
            <if test="deleted != null "> and deleted = #{deleted}</if>
            <if test="createTime != null "> and createTime = #{createTime}</if>
            <if test="platformGroupId != null "> and platformGroupId = #{platformGroupId}</if>
            <if test="platformTeamId != null "> and platformTeamId = #{platformTeamId}</if>
            <if test="enterDate != null "> and enterDate = #{enterDate}</if>
            <if test="exitDate != null "> and exitDate = #{exitDate}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectSurProjectAttendanceGroupById" parameterType="Long" resultMap="SurProjectAttendanceGroupResult">
        <include refid="selectSurProjectAttendanceGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertSurProjectAttendanceGroup" parameterType="SurProjectAttendanceGroup" useGeneratedKeys="true" keyProperty="id">
        insert into sur_project_attendance_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="cfgid != null">cfgid,</if>
            <if test="appId != null">app_id,</if>
            <if test="serverid != null">serverid,</if>
            <if test="bizLicense != null">bizLicense,</if>
            <if test="companyCode != null">companyCode,</if>
            <if test="companyId != null">companyId,</if>
            <if test="companyName != null">companyName,</if>
            <if test="companyTypeId != null">companyTypeId,</if>
            <if test="vendorId != null">vendorId,</if>
            <if test="name != null">name,</if>
            <if test="leaderName != null">leaderName,</if>
            <if test="leaderPhone != null">leaderPhone,</if>
            <if test="teamId != null">teamId,</if>
            <if test="teamName != null">teamName,</if>
            <if test="type != null">type,</if>
            <if test="leaderId != null">leaderId,</if>
            <if test="deleted != null">deleted,</if>
            <if test="createTimestamp != null">createTimestamp,</if>
            <if test="platformGroupId != null">platformGroupId,</if>
            <if test="platformTeamId != null">platformTeamId,</if>
            <if test="enterDate != null">enterDate,</if>
            <if test="exitDate != null">exitDate,</if>
            <if test="remark != null">remark,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="cfgid != null">#{cfgid},</if>
            <if test="appId != null">#{appId},</if>
            <if test="serverid != null">#{serverid},</if>
            <if test="bizLicense != null">#{bizLicense},</if>
            <if test="companyCode != null">#{companyCode},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyName != null">#{companyName},</if>
            <if test="companyTypeId != null">#{companyTypeId},</if>
            <if test="vendorId != null">#{vendorId},</if>
            <if test="name != null">#{name},</if>
            <if test="leaderName != null">#{leaderName},</if>
            <if test="leaderPhone != null">#{leaderPhone},</if>
            <if test="teamId != null">#{teamId},</if>
            <if test="teamName != null">#{teamName},</if>
            <if test="type != null">#{type},</if>
            <if test="leaderId != null">#{leaderId},</if>
            <if test="deleted != null">#{deleted},</if>
            <if test="createTimestamp != null">#{createTimestamp},</if>
            <if test="platformGroupId != null">#{platformGroupId},</if>
            <if test="platformTeamId != null">#{platformTeamId},</if>
            <if test="enterDate != null">#{enterDate},</if>
            <if test="exitDate != null">#{exitDate},</if>
            <if test="remark != null">#{remark},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateSurProjectAttendanceGroup" parameterType="SurProjectAttendanceGroup">
        update sur_project_attendance_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="cfgid != null">cfgid = #{cfgid},</if>
            <if test="appId != null">app_id = #{appId},</if>
            <if test="serverid != null">serverid = #{serverid},</if>
            <if test="bizLicense != null">bizLicense = #{bizLicense},</if>
            <if test="companyCode != null">companyCode = #{companyCode},</if>
            <if test="companyId != null">companyId = #{companyId},</if>
            <if test="companyName != null">companyName = #{companyName},</if>
            <if test="companyTypeId != null">companyTypeId = #{companyTypeId},</if>
            <if test="vendorId != null">vendorId = #{vendorId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="leaderName != null">leaderName = #{leaderName},</if>
            <if test="leaderPhone != null">leaderPhone = #{leaderPhone},</if>
            <if test="teamId != null">teamId = #{teamId},</if>
            <if test="teamName != null">teamName = #{teamName},</if>
            <if test="type != null">type = #{type},</if>
            <if test="leaderId != null">leaderId = #{leaderId},</if>
            <if test="deleted != null">deleted = #{deleted},</if>
            <if test="createTimestamp != null">createTimestamp = #{createTimestamp},</if>
            <if test="platformGroupId != null">platformGroupId = #{platformGroupId},</if>
            <if test="platformTeamId != null">platformTeamId = #{platformTeamId},</if>
            <if test="enterDate != null">enterDate = #{enterDate},</if>
            <if test="exitDate != null">exitDate = #{exitDate},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSurProjectAttendanceGroupById" parameterType="Long">
        delete from sur_project_attendance_group where id = #{id}
    </delete>

    <delete id="deleteSurProjectAttendanceGroupByIds" parameterType="String">
        delete from sur_project_attendance_group where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteSurProjectAttendanceGroupByParams" parameterType="String">
        delete from sur_project_attendance_group where CONCAT(app_id,'-',serverid) in
        <foreach collection="list" item="item" separator=","  open="(" close=")">
            #{item}
        </foreach>
    </delete>

    <insert id="batchSurProjectAttendanceGroup">
        insert into sur_project_attendance_group(id,cfgid,app_id,serverid,bizLicense,companyCode,companyId,companyName,companyTypeId,vendorId,name,leaderName,leaderPhone,teamId,teamName,type,leaderId,deleted,createTimestamp,platformGroupId,platformTeamId,enterDate,exitDate,remark,create_by,create_time,update_by,update_time) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.id}, #{item.cfgid}, #{item.appId}, #{item.serverid}, #{item.bizLicense}, #{item.companyCode}, #{item.companyId}, #{item.companyName},#{item.companyTypeId}, #{item.vendorId}, #{item.name}, #{item.leaderName}, #{item.leaderPhone}, #{item.teamId}, #{item.teamName}, #{item.type}, #{item.leaderId}, #{item.deleted}, #{item.createTimestamp}, #{item.platformGroupId}, #{item.platformTeamId}, #{item.enterDate},
              #{item.exitDate}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
        </foreach>
    </insert>

</mapper>