SSM--ModuleMapper.xml

<?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.xunpoit.oa.dao.ModuleMapper" >
  <resultMap id="BaseResultMap" type="com.xunpoit.oa.entity.Module" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="sn" property="sn" jdbcType="VARCHAR" />
    <result column="url" property="url" jdbcType="VARCHAR" />
    <result column="orderNo" property="orderno" jdbcType="INTEGER" />
    
    <!-- 父模块 -->
    <association property="parent"
                 javaType="com.xunpoit.oa.entity.Module" 
                 select="selectParentByID"
                 column="pid"/>
    
    <!-- 子模块 -->
    <collection property="childList"
                ofType="com.xunpoit.oa.entity.Module" 
                select="selectChildList"
                column="id"/>


  </resultMap>
  <sql id="Base_Column_List" >
    id, name, sn, url, orderNo, pid
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_module
    where id = #{id,jdbcType=INTEGER}
  </select>
  
  <!-- 找父模块 -->
  <select id="selectParentByID" resultType="com.xunpoit.oa.entity.Module" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_module
    where id = #{id,jdbcType=INTEGER}
  </select>
  
  <!-- 找子模块 -->
  <select id="selectChildList" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from t_module
    where pid = #{id}
  </select>
  
  <!--查找所有模块 -->
  <select id="findAllModulesListKey" resultMap="BaseResultMap" parameterType="java.util.List" >
    select 
    <include refid="Base_Column_List" />
    from t_module
    <if test="list.size>0">
      where id in 
       <foreach collection="list" open="(" close=")" separator="," item="id">
         #{id}
       </foreach>
    </if>
     <if test="list.size==0">
       where 1=2
     </if>
  </select>
  
  <!--分页所有模块 -->
  <select id="findAllModules" resultMap="BaseResultMap" parameterType="java.util.Map" >
    select 
    <include refid="Base_Column_List" />
    from t_module
    <if test="pid== 0" >
     where pid is null
    </if>
    <if test="pid > 0" >
     where pid = #{pid}
    </if>
    limit #{offset},#{pageSize}
  </select>
  
  <!--查找条数 -->
  <select id="selectCounts" resultType="java.lang.Long" parameterType="java.lang.Integer" >
    select count(*) 
    from t_module
    <if test="_parameter== 0" >
     where pid is null
    </if>
    <if test="_parameter> 0" >
     where pid = #{id,jdbcType=INTEGER}
    </if>
  </select>
  
  <!--删除 -->
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from t_module
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.xunpoit.oa.entity.Module" >
    insert into t_module (id, name, sn, 
      url, orderNo, pid)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sn,jdbcType=VARCHAR}, 
      #{url,jdbcType=VARCHAR}, #{orderno,jdbcType=INTEGER}, #{parent.id,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.xunpoit.oa.entity.Module" >
    insert into t_module
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="sn != null" >
        sn,
      </if>
      <if test="url != null" >
        url,
      </if>
      <if test="orderno != null" >
        orderNo,
      </if>
      <if test="parent != null" >
        pid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="sn != null" >
        #{sn,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        #{url,jdbcType=VARCHAR},
      </if>
      <if test="orderno != null" >
        #{orderno,jdbcType=INTEGER},
      </if>
      <if test="parent != null" >
        #{parent.id,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.xunpoit.oa.entity.Module" >
    update t_module
    <set >
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="sn != null" >
        sn = #{sn,jdbcType=VARCHAR},
      </if>
      <if test="url != null" >
        url = #{url,jdbcType=VARCHAR},
      </if>
      <if test="orderno != null" >
        orderNo = #{orderno,jdbcType=INTEGER},
      </if>
      <if test="parent != null" >
        pid = #{parent.id,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.xunpoit.oa.entity.Module" >
    update t_module
    set name = #{name,jdbcType=VARCHAR},
      sn = #{sn,jdbcType=VARCHAR},
      url = #{url,jdbcType=VARCHAR},
      orderNo = #{orderno,jdbcType=INTEGER},
      pid = #{parent.id,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值