<?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.njcn.harmonic.mapper.DeptTempMapper">
    <update id="updateActivation">
        UPDATE sys_dept_temp
            SET activation = 1
        WHERE 1=1
        <if test="sysDeptTemp.deptId!=null and sysDeptTemp.deptId!=''">
            and dept_id = #{sysDeptTemp.deptId}
        </if>
        <if test="sysDeptTemp.tempId!=null and sysDeptTemp.tempId!=''">
            and temp_id = #{sysDeptTemp.tempId}
        </if>
    </update>

    <update id="updateAllActivation">
        UPDATE sys_dept_temp
            SET activation = 0
        WHERE
            dept_id = #{deptId}
    </update>

    <select id="getDeptTempByTempId" resultType="SysDeptTempVO">
        SELECT
            a.*,
            b.`Name` deptName
        FROM
            sys_dept_temp a
            LEFT JOIN sys_dept b ON a.dept_id = b.id
        WHERE
            a.temp_id = #{tempId}
    </select>

</mapper>
