<?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.neusoft.smart.pos.user.persistent.mapper.PermissionGroupPermissionMapper">
    <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionKey">
        <id column="permission_group" jdbcType="INTEGER" property="permissionGroup"/>
        <id column="permission" jdbcType="INTEGER" property="permission"/>
    </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">
        permission_group, permission
    </sql>
    <select id="selectByExample"
            parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from permission_group_permission
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="offset != null and limit != null">
            limit ${offset}, ${limit}
        </if>
    </select>
    <delete id="deleteByPrimaryKey"
            parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionKey">
        delete from permission_group_permission
        where permission_group = #{permissionGroup,jdbcType=INTEGER}
        and permission = #{permission,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample"
            parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionExample">
        delete from permission_group_permission
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionKey">
        insert into permission_group_permission (permission_group, permission)
        values (#{permissionGroup,jdbcType=INTEGER}, #{permission,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective"
            parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionKey">
        insert into permission_group_permission
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="permissionGroup != null">
                permission_group,
            </if>
            <if test="permission != null">
                permission,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="permissionGroup != null">
                #{permissionGroup,jdbcType=INTEGER},
            </if>
            <if test="permission != null">
                #{permission,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample"
            parameterType="com.neusoft.smart.pos.user.persistent.domain.PermissionGroupPermissionExample"
            resultType="java.lang.Integer">
        select count(*) from permission_group_permission
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update permission_group_permission
        <set>
            <if test="record.permissionGroup != null">
                permission_group = #{record.permissionGroup,jdbcType=INTEGER},
            </if>
            <if test="record.permission != null">
                permission = #{record.permission,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update permission_group_permission
        set permission_group = #{record.permissionGroup,jdbcType=INTEGER},
        permission = #{record.permission,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
</mapper>