<?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.mapper.PowerUserMapper">
    <insert id="addUser">
        INSERT INTO `docus_system`.`power_user`(`user_id`,
                                                `user_name`,
                                                `name`,
                                                `user_pwd`,
                                                `user_position`,
                                                `role_id`,
                                                `dept_id`,
                                                `create_date`,
                                                `creater`,
                                                `update_date`,
                                                `updater`)
        VALUES (#{user.userId},#{user.userName},#{user.name},#{user.userPwd},#{user.position},#{user.roleId}
        ,#{user.deptId},now(),#{user.authorName},now(),#{user.authorName})
    </insert>
    <update id="updateUser">
        update `docus_system`.`power_user` set
        `updater`=#{user.authorName},
        `dept_id`=#{user.deptId},
        `user_position`=#{user.position},
        `name`=#{user.name},
        `update_date`=now()
        where `user_id`=#{user.userId}
    </update>
    <delete id="delUserByUserName">
        delete from `docus_system`.`power_user` where `user_name` = #{userName}
    </delete>

    <select id="getUserByUserName" resultType="com.docus.server.collection.entity.PowerUser">
        SELECT `user_id`,`user_name`,`user_pwd` FROM `docus_system`.`power_user`
        WHERE `user_name` = #{userName}   LIMIT 1
    </select>
</mapper>
