<?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.gic.haoban.manage.service.dao.mapper.SyncTaskMapper">
    <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
        <id column="task_id" jdbcType="VARCHAR" property="taskId"/>
        <result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/>
        <result column="task_name" jdbcType="VARCHAR" property="taskName"/>
        <result column="add_user" jdbcType="VARCHAR" property="addUser"/>
        <result column="task_desc" jdbcType="VARCHAR" property="taskDesc"/>
        <result column="task_type" jdbcType="INTEGER" property="taskType"/>
        <result column="status_flag" jdbcType="INTEGER" property="statusFlag"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>
    <sql id="Base_Column_List">
        task_id,wx_enterprise_id, task_name, add_user, task_desc,task_type, status_flag, create_time, update_time
  </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_sync_task
        where task_id = #{taskId,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        delete from tab_haoban_sync_task
        where task_id = #{taskId,jdbcType=VARCHAR}
    </delete>
    <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
        insert into tab_haoban_sync_task (task_id,wx_enterprise_id, task_name, add_user,
        task_desc, status_flag,task_type, create_time,
        update_time)
        values (#{taskId,jdbcType=VARCHAR},#{wxEnterpriseId}, #{taskName,jdbcType=VARCHAR}, #{addUser,jdbcType=VARCHAR},
        #{taskDesc,jdbcType=VARCHAR}, #{statusFlag,jdbcType=INTEGER},#{taskType}, now(),now())
    </insert>
    <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
        insert into tab_haoban_sync_task
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">
                task_id,
            </if>
            <if test="taskName != null">
                task_name,
            </if>
            <if test="addUser != null">
                add_user,
            </if>
            <if test="taskDesc != null">
                task_desc,
            </if>
            <if test="statusFlag != null">
                status_flag,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">
                #{taskId,jdbcType=VARCHAR},
            </if>
            <if test="taskName != null">
                #{taskName,jdbcType=VARCHAR},
            </if>
            <if test="addUser != null">
                #{addUser,jdbcType=VARCHAR},
            </if>
            <if test="taskDesc != null">
                #{taskDesc,jdbcType=VARCHAR},
            </if>
            <if test="statusFlag != null">
                #{statusFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
        update tab_haoban_sync_task
        <set>
            <if test="taskName != null">
                task_name = #{taskName,jdbcType=VARCHAR},
            </if>
            <if test="addUser != null">
                add_user = #{addUser,jdbcType=VARCHAR},
            </if>
            <if test="taskDesc != null">
                task_desc = #{taskDesc,jdbcType=VARCHAR},
            </if>
            <if test="statusFlag != null">
                status_flag = #{statusFlag,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where task_id = #{taskId,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabHaobanSyncTask">
        update tab_haoban_sync_task
        set task_name = #{taskName,jdbcType=VARCHAR},
        add_user = #{addUser,jdbcType=VARCHAR},
        task_desc = #{taskDesc,jdbcType=VARCHAR},
        status_flag = #{statusFlag,jdbcType=INTEGER},
        create_time = #{createTime,jdbcType=TIMESTAMP},
        update_time = #{updateTime,jdbcType=TIMESTAMP}
        where task_id = #{taskId,jdbcType=VARCHAR}
    </update>

    <select id="listPageByWxEid" parameterType="java.lang.String" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_sync_task
        where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
        and task_type != 4
        
         order by update_time desc
    </select>
    <select id="listTaskByType"  resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from tab_haoban_sync_task
        where status_flag = 0
        and task_type = #{taskType}
        group by wx_enterprise_id
    </select>
</mapper>