<?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>
<!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>