<?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.docus.server.collection.infrastructure.dao.mapper.PowerDeptMapper">
    <insert id="addDept">
        INSERT INTO `docus_system`.`power_dept`(`dept_id`,
                                                `dept_code`,
                                                `dept_name`,
                                                `create_date`,
                                                `creater`,
                                                `update_date`,
                                                `updater`)
        VALUES (#{dept.deptId},#{dept.deptCode},#{dept.deptName},now(),#{dept.authorName},now(),#{dept.authorName})
    </insert>
    <update id="updateDept">
        update `docus_system`.`power_dept` set
        `dept_name`=#{dept.deptName},
        `updater`=#{dept.authorName},
        `update_date`=now()
        where `dept_code`=#{dept.deptCode}
    </update>
    <delete id="delDeptByDeptCode">
        delete from `docus_system`.`power_dept` where `dept_code` = #{deptCode}
    </delete>

    <select id="getDeptByDeptCode" resultType="com.docus.server.collection.infrastructure.dao.entity.PowerDept">
        SELECT `dept_id`,`dept_code`,`dept_name` FROM `docus_system`.`power_dept`
        WHERE `dept_code` = #{deptCode}   LIMIT 1
    </select>
</mapper>
