<?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="org.jeecg.modules.apply.mapper.ApplyProcessMapper">

    <resultMap type="org.jeecg.common.base.entity.BaseTaskEntity" id="BaseResult">
<!--        <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>-->
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="deptId" column="dept_id" jdbcType="VARCHAR"/>
        <result property="processKey" column="process_key" jdbcType="VARCHAR"/>
        <result property="processInstanceId" column="process_instance_id" jdbcType="VARCHAR"/>
        <result property="processInstanceName" column="process_instance_name" jdbcType="VARCHAR"/>
        <result property="userId" column="user_id" jdbcType="VARCHAR"/>
        <result property="userName" column="user_name" jdbcType="VARCHAR"/>
        <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
<!--        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>-->
<!--        <result property="createBy" column="create_by" jdbcType="VARCHAR"/>-->
<!--        <result property="modifyBy" column="modify_by" jdbcType="VARCHAR"/>-->
<!--        <result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>-->
<!--        <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>-->
    </resultMap>

    <update id="updateProcessResult">
        update ${tableName}
        set apply_status = #{applyStatus},
        result = #{result},
        complete_time = #{completeTime}
        <if test="opinionStr != '' and opinionStr != null">
            , opinion_str = #{opinionStr}
        </if>
        where
        id = #{id}
    </update>

    <update id="updateContactProcessResult">
        update ${tableName}
        set apply_status = #{applyStatus},
        state = #{state},
        result = #{result},
        complete_time = #{completeTime}
        <if test="opinionStr != '' and opinionStr != null">
            , opinion_str = #{opinionStr}
        </if>
        where
        id = #{id}
    </update>

    <update id="updateContactState">
        update zshb_contact
        set state = #{state}
        where
        id = #{id}
        and
        (select count(0) from zshb_contact_problem  WHERE PARENT_ID = #{id})
	    =
        (select count(0) from zshb_contact_problem  WHERE PARENT_ID = #{id} and STATE =#{state})
    </update>

</mapper>