RoleMapper.xml 7.4 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.tianbo.mapper.RoleMapper" >
  <resultMap id="BaseResultMap" type="com.tianbo.model.Role" >
    <id column="ROLE_ID" property="roleId" jdbcType="DECIMAL" />
    <result column="ROLE_NAME" property="roleName" jdbcType="VARCHAR" />
    <result column="ROLE_SIGN" property="roleSign" jdbcType="VARCHAR" />
    <result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" 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="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    ROLE_ID, ROLE_NAME, ROLE_SIGN, DESCRIPTION
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.tianbo.model.RoleExample" >
    <include refid="OracleDialectPrefix" />
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
    <include refid="OracleDialectSuffix" />
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.math.BigDecimal" >
    select 
    <include refid="Base_Column_List" />
    from ROLE
    where ROLE_ID = #{roleId,jdbcType=DECIMAL}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal" >
    delete from ROLE
    where ROLE_ID = #{roleId,jdbcType=DECIMAL}
  </delete>
  <delete id="deleteByExample" parameterType="com.tianbo.model.RoleExample" >
    delete from ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.tianbo.model.Role" >
    insert into ROLE (ROLE_ID, ROLE_NAME, ROLE_SIGN, 
      DESCRIPTION)
    values (#{roleId,jdbcType=DECIMAL}, #{roleName,jdbcType=VARCHAR}, #{roleSign,jdbcType=VARCHAR}, 
      #{description,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.tianbo.model.Role" >
    insert into ROLE
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="roleId != null" >
        ROLE_ID,
      </if>
      <if test="roleName != null" >
        ROLE_NAME,
      </if>
      <if test="roleSign != null" >
        ROLE_SIGN,
      </if>
      <if test="description != null" >
        DESCRIPTION,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="roleId != null" >
        #{roleId,jdbcType=DECIMAL},
      </if>
      <if test="roleName != null" >
        #{roleName,jdbcType=VARCHAR},
      </if>
      <if test="roleSign != null" >
        #{roleSign,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        #{description,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.tianbo.model.RoleExample" resultType="java.lang.Integer" >
    select count(*) from ROLE
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update ROLE
    <set >
      <if test="record.roleId != null" >
        ROLE_ID = #{record.roleId,jdbcType=DECIMAL},
      </if>
      <if test="record.roleName != null" >
        ROLE_NAME = #{record.roleName,jdbcType=VARCHAR},
      </if>
      <if test="record.roleSign != null" >
        ROLE_SIGN = #{record.roleSign,jdbcType=VARCHAR},
      </if>
      <if test="record.description != null" >
        DESCRIPTION = #{record.description,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update ROLE
    set ROLE_ID = #{record.roleId,jdbcType=DECIMAL},
      ROLE_NAME = #{record.roleName,jdbcType=VARCHAR},
      ROLE_SIGN = #{record.roleSign,jdbcType=VARCHAR},
      DESCRIPTION = #{record.description,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.tianbo.model.Role" >
    update ROLE
    <set >
      <if test="roleName != null" >
        ROLE_NAME = #{roleName,jdbcType=VARCHAR},
      </if>
      <if test="roleSign != null" >
        ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
      </if>
      <if test="description != null" >
        DESCRIPTION = #{description,jdbcType=VARCHAR},
      </if>
    </set>
    where ROLE_ID = #{roleId,jdbcType=DECIMAL}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.tianbo.model.Role" >
    update ROLE
    set ROLE_NAME = #{roleName,jdbcType=VARCHAR},
      ROLE_SIGN = #{roleSign,jdbcType=VARCHAR},
      DESCRIPTION = #{description,jdbcType=VARCHAR}
    where ROLE_ID = #{roleId,jdbcType=DECIMAL}
  </update>
  <sql id="OracleDialectPrefix" >
    <if test="page != null" >
      select * from ( select row_.*, rownum rownum_ from ( 
    </if>
  </sql>
  <sql id="OracleDialectSuffix" >
    <if test="page != null" >
      <![CDATA[ ) row_ ) where rownum_ > #{page.begin} and rownum_ <= #{page.end} ]]>
    </if>
  </sql>
</mapper>