<?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="cn.superdesk.uniorder.dao.mapper.sys.role.SysUserRoleMapper">
	<resultMap id="BaseResultMap" type="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRole">
		<id column="user_id" property="userId" jdbcType="VARCHAR"/>
		<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
		<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
		<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
	</resultMap>
	<sql id="Base_Column_List">
    user_id, role_id, create_by, create_time
  </sql>
	<select id="selectByPrimaryKey" resultMap="BaseResultMap"
	        parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRoleKey">
		select
		<include refid="Base_Column_List"/>
		from sys_user_role
		where user_id = #{userId,jdbcType=VARCHAR}
		and role_id = #{roleId,jdbcType=VARCHAR}
	</select>
	<delete id="deleteByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRoleKey">
    delete from sys_user_role
    where user_id = #{userId,jdbcType=VARCHAR}
      
  </delete>
	<insert id="insert" parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRole">
    insert into sys_user_role (user_id, role_id, create_by, 
      create_time)
    values (#{userId,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, 
      #{createTime,jdbcType=TIMESTAMP})
  </insert>
	<insert id="insertSelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRole">
		insert into sys_user_role
		<trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="userId != null">
				user_id,
			</if>
			<if test="roleId != null">
				role_id,
			</if>
			<if test="createBy != null">
				create_by,
			</if>
			<if test="createTime != null">
				create_time,
			</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="userId != null">
				#{userId,jdbcType=VARCHAR},
			</if>
			<if test="roleId != null">
				#{roleId,jdbcType=VARCHAR},
			</if>
			<if test="createBy != null">
				#{createBy,jdbcType=VARCHAR},
			</if>
			<if test="createTime != null">
				#{createTime,jdbcType=TIMESTAMP},
			</if>
		</trim>
	</insert>
	<update id="updateByPrimaryKeySelective" parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRole">
		update sys_user_role
		<set>
			<if test="createBy != null">
				create_by = #{createBy,jdbcType=VARCHAR},
			</if>
			<if test="createTime != null">
				create_time = #{createTime,jdbcType=TIMESTAMP},
			</if>
		</set>
		where user_id = #{userId,jdbcType=VARCHAR}
		and role_id = #{roleId,jdbcType=VARCHAR}
	</update>
	<update id="updateByPrimaryKey" parameterType="cn.superdesk.uniorder.dao.entity.sys.role.SysUserRole">
    update sys_user_role
    set create_by = #{createBy,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where user_id = #{userId,jdbcType=VARCHAR}
      and role_id = #{roleId,jdbcType=VARCHAR}
  </update>
</mapper>