SysRoleMenuMapper.xml 8.18 KB
<?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.glsx.usercenter.mapper.SysRoleMenuMapper">
    <resultMap id="BaseResultMap" type="com.glsx.usercenter.pojo.role.SysRoleMenu">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="role_id" jdbcType="INTEGER" property="roleId"/>
        <result column="menu_id" jdbcType="INTEGER" property="menuId"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        id, role_id, menu_id
    </sql>
    <select id="selectByExample" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenuExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        'false' as QUERYID,
        <include refid="Base_Column_List"/>
        from sys_role_menu
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from sys_role_menu
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        DELETE FROM sys_role_menu
        WHERE id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenuExample">
        delete from sys_role_menu
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenu">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sys_role_menu (role_id, menu_id)
        values (#{roleId,jdbcType=INTEGER}, #{menuId,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenu">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into sys_role_menu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="roleId != null">
                role_id,
            </if>
            <if test="menuId != null">
                menu_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="roleId != null">
                #{roleId,jdbcType=INTEGER},
            </if>
            <if test="menuId != null">
                #{menuId,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenuExample"
            resultType="java.lang.Long">
        select count(*) from sys_role_menu
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update sys_role_menu
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.roleId != null">
                role_id = #{record.roleId,jdbcType=INTEGER},
            </if>
            <if test="record.menuId != null">
                menu_id = #{record.menuId,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update sys_role_menu
        set id = #{record.id,jdbcType=INTEGER},
        role_id = #{record.roleId,jdbcType=INTEGER},
        menu_id = #{record.menuId,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenu">
        update sys_role_menu
        <set>
            <if test="roleId != null">
                role_id = #{roleId,jdbcType=INTEGER},
            </if>
            <if test="menuId != null">
                menu_id = #{menuId,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.glsx.usercenter.pojo.role.SysRoleMenu">
        UPDATE sys_role_menu
        SET role_id = #{roleId,jdbcType=INTEGER},
            menu_id = #{menuId,jdbcType=INTEGER}
        WHERE id = #{id,jdbcType=INTEGER}
    </update>

    <delete id="deleteByRoleId">
        DELETE FROM sys_role_menu
        WHERE role_id = #{roleId,jdbcType=INTEGER}
    </delete>
</mapper>