mapper3.xml

<?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.paic.dbaudit.dao.prd.MapperUser">

    <select id="getUserByName"  resultType="com.paic.dbaudit.bean.User">
        select 
            u.user_id, 
            u.user_name, 
            u.user_name_cn, 
            u.dept_id,
            d.dep_name as dept_name,
            d.privilege_exception,
            u.role_ids,
            u.created_by,
            u.created_date
        from 
            DA_USER_FUN_INFO  u
        left join 
            sa_dep_um d
        on 
            d.dep_id = u.dept_id
        where 
            u.user_name = #{user_name}
    </select>

    <select id="getDeptManager"  resultType="com.paic.dbaudit.bean.User">
        select 
            u.user_id, 
            u.user_name, 
            u.user_name_cn, 
            u.dept_id,
            d.dep_name as dept_name,
            d.privilege_exception,
            u.role_ids,
            u.created_by,
            u.created_date
        from 
            DA_USER_FUN_INFO  u
        left join 
            sa_dep_um d
        on 
            d.dep_id = u.dept_id
        where 
            u.dept_id = #{dept_id, jdbcType = NUMERIC}
        and u.role_ids = '0'
    </select>

    <select id="getUsersByDept" resultType="com.paic.dbaudit.bean.User">
        select 
            user_id, 
            user_name, 
            user_name_cn, 
            dept_id, 
            role_ids,
            updated_by,
            updated_date
        from 
            DA_USER_FUN_INFO
        where 
            dept_id = #{dept_id, jdbcType = NUMERIC}
        and
            (role_ids != '0'
        or
            role_ids is null)
        order by
            user_name desc
    </select>

    <insert id="insertUser" parameterType="com.paic.dbaudit.bean.User">
        insert into DA_USER_FUN_INFO 
            (user_name, 
            user_name_cn,
            dept_id,
            role_ids,
            created_by, 
            created_date, 
            updated_by, 
            updated_date)
        values(
            #{user_name, jdbcType = VARCHAR},   
            #{user_name_cn, jdbcType = VARCHAR}, 
            #{dept_id, jdbcType = NUMERIC}, 
            #{role_ids, jdbcType = VARCHAR}, 
            #{created_by, jdbcType = VARCHAR}, 
            sysdate, 
            #{created_by, jdbcType = VARCHAR}, 
            sysdate 
        )
    </insert>

    <insert id="insertUsers" useGeneratedKeys="false" keyProperty="user_id" parameterType="com.paic.dbaudit.bean.User">
        insert into DA_USER_FUN_INFO 
            (user_name, 
            user_name_cn,
            dept_id, 
            created_by, 
            created_date, 
            updated_by, 
            updated_date)
        <foreach item="u" collection="list" separator="union">
        select 
            #{u.user_name, jdbcType = VARCHAR}, 
            #{u.user_name_cn, jdbcType = VARCHAR}, 
            #{u.dept_id, jdbcType = NUMERIC},   
            #{u.created_by, jdbcType = VARCHAR}, 
            sysdate, 
            #{u.created_by, jdbcType = VARCHAR}, 
            sysdate 
        from dual
        </foreach>
    </insert>

    <insert id="logLogin">
        insert into DA_USER_LOGIN_INFO
          (LOGIN_ID,
           USER_ID,
           DEP_ID,
           LOGIN_DATE,
           CREATED_DATE,
           CREATED_BY,
           UPDATED_DATE,
           UPDATED_BY)
        values
          (sys_guid(),
           #{user_name, jdbcType = VARCHAR},
           #{dept_id, jdbcType = NUMERIC},
           sysdate,
           sysdate,
           'dbaudit',
           sysdate,
           'dbaudit')
    </insert>

    <update id="updateUserRole" parameterType="com.paic.dbaudit.bean.User">
        update 
            DA_USER_FUN_INFO
        set
            role_ids =  #{role_ids,jdbcType=VARCHAR},
            updated_by = #{updated_by,jdbcType=VARCHAR},
            updated_date = sysdate
        where 
            user_id = #{user_id, jdbcType = NUMERIC}
    </update>

    <update id="updateUsersRole" parameterType="com.paic.dbaudit.bean.User">
        begin
        <foreach item="u" collection="list" separator="">
            update 
                DA_USER_FUN_INFO
            set
                role_ids =  #{u.role_ids,jdbcType=VARCHAR},
                updated_by = #{u.updated_by,jdbcType=VARCHAR},
                updated_date = sysdate
            where 
                user_id = #{u.user_id, jdbcType = NUMERIC};
        </foreach>
        end;
    </update>

    <update id="updateManagerRole">
        update 
            DA_USER_FUN_INFO
        set
            dept_id = #{dept_id,jdbcType=NUMERIC},
            role_ids = #{role_ids,jdbcType=VARCHAR},
            updated_by = #{updated_by,jdbcType=VARCHAR},
            updated_date = sysdate
        where 
            user_id = #{user_id, jdbcType = NUMERIC}
    </update>

    <delete id="deleteUser" parameterType="com.paic.dbaudit.bean.User">
        delete from
            DA_USER_FUN_INFO 
        where
            user_id = #{user_id, jdbcType = NUMERIC}
    </delete>

</mapper>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章