<?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.xmomen.module.resource.entity.mapper.ResourceMapper" >
  <resultMap id="BaseResultMap" type="com.xmomen.module.resource.entity.Resource" >
    <id column="ID" property="id" jdbcType="VARCHAR" />
    <result column="ENTITY_TYPE" property="entityType" jdbcType="VARCHAR" />
    <result column="ENTITY_ID" property="entityId" jdbcType="VARCHAR" />
    <result column="PATH" property="path" jdbcType="VARCHAR" />
    <result column="RESOURCE_TYPE" property="resourceType" jdbcType="VARCHAR" />
    <result column="IS_DEFAULT" property="isDefault" jdbcType="INTEGER" />
  </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" >
    ID, ENTITY_TYPE, ENTITY_ID, PATH, RESOURCE_TYPE, IS_DEFAULT
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.xmomen.module.resource.entity.ResourceExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cd_resource
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <delete id="deleteByExample" parameterType="com.xmomen.module.resource.entity.ResourceExample" >
    delete from cd_resource
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insertSelective" parameterType="com.xmomen.module.resource.entity.Resource" useGeneratedKeys="true" keyProperty="id" keyColumn="ID" >
    <selectKey resultType="java.lang.String" keyProperty="id" order="BEFORE" >
      SELECT replace(UUID(),'-','')
    </selectKey>
    insert into cd_resource
    <trim prefix="(" suffix=")" suffixOverrides="," >
      ID,
      <if test="entityType != null" >
        ENTITY_TYPE,
      </if>
      <if test="entityId != null" >
        ENTITY_ID,
      </if>
      <if test="path != null" >
        PATH,
      </if>
      <if test="resourceType != null" >
        RESOURCE_TYPE,
      </if>
      <if test="isDefault != null" >
        IS_DEFAULT,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      #{id,jdbcType=VARCHAR},
      <if test="entityType != null" >
        #{entityType,jdbcType=VARCHAR},
      </if>
      <if test="entityId != null" >
        #{entityId,jdbcType=VARCHAR},
      </if>
      <if test="path != null" >
        #{path,jdbcType=VARCHAR},
      </if>
      <if test="resourceType != null" >
        #{resourceType,jdbcType=VARCHAR},
      </if>
      <if test="isDefault != null" >
        #{isDefault,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.xmomen.module.resource.entity.ResourceExample" resultType="java.lang.Integer" >
    select count(*) from cd_resource
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cd_resource
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.entityType != null" >
        ENTITY_TYPE = #{record.entityType,jdbcType=VARCHAR},
      </if>
      <if test="record.entityId != null" >
        ENTITY_ID = #{record.entityId,jdbcType=VARCHAR},
      </if>
      <if test="record.path != null" >
        PATH = #{record.path,jdbcType=VARCHAR},
      </if>
      <if test="record.resourceType != null" >
        RESOURCE_TYPE = #{record.resourceType,jdbcType=VARCHAR},
      </if>
      <if test="record.isDefault != null" >
        IS_DEFAULT = #{record.isDefault,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
</mapper>