<?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.dgtis.dorm.manager.db.dao.AdminRoleMapper">
  <resultMap id="BaseResultMap" type="com.dgtis.dorm.manager.db.domain.AdminRole">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="admin_id" jdbcType="INTEGER" property="adminId" />
    <result column="role_id" jdbcType="INTEGER" property="roleId" />
  </resultMap>

  <sql id="Base_Column_List">
    id, admin_id, role_id
  </sql>
  <select id="selectByExample" parameterType="com.dgtis.dorm.manager.db.domain.AdminRole" resultMap="BaseResultMap">
    select distinct
    <include refid="Base_Column_List" />
    from zhll_sys_admin_role
    <where>
      <if test="adminId != null and adminId != ''">
        admin_id = #{adminId}
      </if>
    </where>
  </select>

  <delete id="deleteByExample" parameterType="com.dgtis.dorm.manager.db.domain.AdminRole">
    delete from zhll_sys_admin_role
    <where>
        admin_id = #{adminId}
    </where>
  </delete>

  <insert id="insertSelective" parameterType="com.dgtis.dorm.manager.db.domain.AdminRole">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into zhll_sys_admin_role
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="adminId != null">
        admin_id,
      </if>
      <if test="roleId != null">
        role_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="adminId != null">
        #{adminId,jdbcType=INTEGER},
      </if>
      <if test="roleId != null">
        #{roleId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>

</mapper>