| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471 |
- <?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.ssm.mapper.system.SysDepartmentMapper">
- <resultMap id="BaseResultMap" type="com.ssm.model.system.SysDepartment">
- <id column="DepID" property="depid" jdbcType="INTEGER" />
- <result column="DepCode" property="depcode" jdbcType="VARCHAR" />
- <result column="CreatedUserID" property="createduserid"
- jdbcType="INTEGER" />
- <result column="CreatedDatetime" property="createddatetime"
- jdbcType="TIMESTAMP" />
- <result column="LastUpdateUserID" property="lastupdateuserid"
- jdbcType="INTEGER" />
- <result column="LastUpdateDatetime" property="lastupdatedatetime"
- jdbcType="TIMESTAMP" />
- <result column="DepName" property="depname" jdbcType="VARCHAR" />
- <result column="LanguageType" property="languagetype" jdbcType="INTEGER" />
- <result column="ParentID" property="parentid" jdbcType="INTEGER" />
- <result column="IsDeleted" property="isdeleted" jdbcType="BIT" />
- <result column="Level" property="level" jdbcType="INTEGER" />
- <result column="DepartmentID" property="departmentid" jdbcType="INTEGER" />
- <result column="DeptRoleCode" property="deptrolecode" jdbcType="CLOB" />
- <collection property="positions" ofType="com.ssm.model.system.SysPosition">
- <id property="positionid" column="positionid" />
- <result property="positionname" column="positionname" />
- </collection>
- </resultMap>
- <resultMap id="ResultMapWithBLOBs" type="com.ssm.model.system.SysDepartment"
- extends="BaseResultMap">
- <result column="DeptRoleCode" property="deptrolecode" jdbcType="CLOB" />
- </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">
- DepID, DepCode, CreatedUserID, CreatedDatetime, LastUpdateUserID,
- LastUpdateDatetime,
- DepName, LanguageType, ParentID, IsDeleted,Level,DepartmentID
- </sql>
- <sql id="Blob_Column_List">
- DeptRoleCode
- </sql>
- <!-- 级联菜单 -->
- <select id="selectAll" resultMap="BaseResultMap" parameterType="com.ssm.model.system.SysDepartment">
- select sd.depid , sd.depname, sp.positionid, sp.positionname
- from
- SysDepartment sd
- , SysPosition sp
- where 1=1 and sd.depid = sp.depid and sd.isDeleted=0 and sp.isDeleted=0
- order by sd.depid asc
- </select>
- <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs"
- parameterType="com.ssm.model.system.SysDepartmentExample">
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- ,
- <include refid="Blob_Column_List" />
- from SysDepartment
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <select id="selectByExample" resultMap="BaseResultMap"
- parameterType="com.ssm.model.system.SysDepartmentExample">
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- from SysDepartment
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs"
- parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List" />
- ,
- <include refid="Blob_Column_List" />
- from SysDepartment
- where DepID = #{depid,jdbcType=INTEGER}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from SysDepartment
- where DepID = #{depid,jdbcType=INTEGER}
- </delete>
- <delete id="deleteByExample" parameterType="com.ssm.model.system.SysDepartmentExample">
- delete from SysDepartment
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </delete>
- <insert id="insert" parameterType="com.ssm.model.system.SysDepartment">
- insert into SysDepartment (DepID, DepCode, CreatedUserID,
- CreatedDatetime, LastUpdateUserID, LastUpdateDatetime,
- DepName, LanguageType, ParentID,
- IsDeleted, DeptRoleCode)
- values (#{depid,jdbcType=INTEGER}, #{depcode,jdbcType=VARCHAR},
- #{createduserid,jdbcType=INTEGER},
- #{createddatetime,jdbcType=TIMESTAMP},
- #{lastupdateuserid,jdbcType=INTEGER},
- #{lastupdatedatetime,jdbcType=TIMESTAMP},
- #{depname,jdbcType=VARCHAR}, #{languagetype,jdbcType=INTEGER}, #{parentid,jdbcType=INTEGER},
- #{isdeleted,jdbcType=BIT}, #{deptrolecode,jdbcType=CLOB})
- </insert>
- <insert id="insertSelective" parameterType="com.ssm.model.system.SysDepartment">
- insert into SysDepartment
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="depid != null">
- DepID,
- </if>
- <if test="depcode != null">
- DepCode,
- </if>
- <if test="createduserid != null">
- CreatedUserID,
- </if>
- <if test="createddatetime != null">
- CreatedDatetime,
- </if>
- <if test="lastupdateuserid != null">
- LastUpdateUserID,
- </if>
- <if test="lastupdatedatetime != null">
- LastUpdateDatetime,
- </if>
- <if test="depname != null">
- DepName,
- </if>
- <if test="languagetype != null">
- LanguageType,
- </if>
- <if test="parentid != null">
- ParentID,
- </if>
- <if test="isdeleted != null">
- IsDeleted,
- </if>
- <if test="deptrolecode != null">
- DeptRoleCode,
- </if>
- <if test="level != null">
- level,
- </if>
- <if test="departmentid != null">
- departmentid,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="depid != null">
- #{depid,jdbcType=INTEGER},
- </if>
- <if test="depcode != null">
- #{depcode,jdbcType=VARCHAR},
- </if>
- <if test="createduserid != null">
- #{createduserid,jdbcType=INTEGER},
- </if>
- <if test="createddatetime != null">
- #{createddatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="lastupdateuserid != null">
- #{lastupdateuserid,jdbcType=INTEGER},
- </if>
- <if test="lastupdatedatetime != null">
- #{lastupdatedatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="depname != null">
- #{depname,jdbcType=VARCHAR},
- </if>
- <if test="languagetype != null">
- #{languagetype,jdbcType=INTEGER},
- </if>
- <if test="parentid != null">
- #{parentid,jdbcType=INTEGER},
- </if>
- <if test="isdeleted != null">
- #{isdeleted,jdbcType=BIT},
- </if>
- <if test="deptrolecode != null">
- #{deptrolecode,jdbcType=CLOB},
- </if>
- <if test="level != null">
- #{level,jdbcType=INTEGER},
- </if>
- <if test="departmentid != null">
- #{departmentid,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="com.ssm.model.system.SysDepartmentExample"
- resultType="java.lang.Integer">
- select count(*) from SysDepartment
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </select>
- <update id="updateByExampleSelective" parameterType="map">
- update SysDepartment
- <set>
- <if test="record.depid != null">
- DepID = #{record.depid,jdbcType=INTEGER},
- </if>
- <if test="record.depcode != null">
- DepCode = #{record.depcode,jdbcType=VARCHAR},
- </if>
- <if test="record.createduserid != null">
- CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
- </if>
- <if test="record.createddatetime != null">
- CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="record.lastupdateuserid != null">
- LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
- </if>
- <if test="record.lastupdatedatetime != null">
- LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="record.depname != null">
- DepName = #{record.depname,jdbcType=VARCHAR},
- </if>
- <if test="record.languagetype != null">
- LanguageType = #{record.languagetype,jdbcType=INTEGER},
- </if>
- <if test="record.parentid != null">
- ParentID = #{record.parentid,jdbcType=INTEGER},
- </if>
- <if test="record.isdeleted != null">
- IsDeleted = #{record.isdeleted,jdbcType=BIT},
- </if>
- <if test="record.deptrolecode != null">
- DeptRoleCode = #{record.deptrolecode,jdbcType=CLOB},
- </if>
- </set>
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExampleWithBLOBs" parameterType="map">
- update SysDepartment
- set DepID = #{record.depid,jdbcType=INTEGER},
- DepCode = #{record.depcode,jdbcType=VARCHAR},
- CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
- CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
- LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
- LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
- DepName = #{record.depname,jdbcType=VARCHAR},
- LanguageType = #{record.languagetype,jdbcType=INTEGER},
- ParentID = #{record.parentid,jdbcType=INTEGER},
- IsDeleted = #{record.isdeleted,jdbcType=BIT},
- DeptRoleCode = #{record.deptrolecode,jdbcType=CLOB}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExample" parameterType="map">
- update SysDepartment
- set DepID = #{record.depid,jdbcType=INTEGER},
- DepCode = #{record.depcode,jdbcType=VARCHAR},
- CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
- CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
- LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
- LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
- DepName = #{record.depname,jdbcType=VARCHAR},
- LanguageType = #{record.languagetype,jdbcType=INTEGER},
- ParentID = #{record.parentid,jdbcType=INTEGER},
- IsDeleted = #{record.isdeleted,jdbcType=BIT}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.system.SysDepartment">
- update SysDepartment
- <set>
- <if test="depcode != null">
- DepCode = #{depcode,jdbcType=VARCHAR},
- </if>
- <if test="createduserid != null">
- CreatedUserID = #{createduserid,jdbcType=INTEGER},
- </if>
- <if test="createddatetime != null">
- CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="lastupdateuserid != null">
- LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
- </if>
- <if test="lastupdatedatetime != null">
- LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
- </if>
- <if test="depname != null">
- DepName = #{depname,jdbcType=VARCHAR},
- </if>
- <if test="languagetype != null">
- LanguageType = #{languagetype,jdbcType=INTEGER},
- </if>
- <if test="parentid != null">
- ParentID = #{parentid,jdbcType=INTEGER},
- </if>
- <if test="isdeleted != null">
- IsDeleted = #{isdeleted,jdbcType=BIT},
- </if>
- <if test="deptrolecode != null">
- DeptRoleCode = #{deptrolecode,jdbcType=CLOB},
- </if>
- <if test="level != null">
- level = #{level,jdbcType=INTEGER},
- </if>
- <if test="departmentid != null">
- departmentid = #{departmentid,jdbcType=INTEGER},
- </if>
- </set>
- where DepID = #{depid,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ssm.model.system.SysDepartment">
- update SysDepartment
- set DepCode = #{depcode,jdbcType=VARCHAR},
- CreatedUserID = #{createduserid,jdbcType=INTEGER},
- CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
- LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
- LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
- DepName = #{depname,jdbcType=VARCHAR},
- LanguageType = #{languagetype,jdbcType=INTEGER},
- ParentID = #{parentid,jdbcType=INTEGER},
- IsDeleted = #{isdeleted,jdbcType=BIT},
- DeptRoleCode = #{deptrolecode,jdbcType=CLOB}
- where DepID = #{depid,jdbcType=INTEGER}
- </update>
- <update id="updateByPrimaryKey" parameterType="com.ssm.model.system.SysDepartment">
- update SysDepartment
- set DepCode = #{depcode,jdbcType=VARCHAR},
- CreatedUserID = #{createduserid,jdbcType=INTEGER},
- CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
- LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
- LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
- DepName = #{depname,jdbcType=VARCHAR},
- LanguageType = #{languagetype,jdbcType=INTEGER},
- ParentID = #{parentid,jdbcType=INTEGER},
- IsDeleted = #{isdeleted,jdbcType=BIT}
- where DepID = #{depid,jdbcType=INTEGER}
- </update>
- <select id="sysDepartmentList" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from SysDepartment where IsDeleted=0
- </select>
-
- <!-- 根据父id查询 -->
- <select id="sysDepartmentParentid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List" />
- from SysDepartment
- where departmentid = #{parentid,jdbcType=INTEGER}
- </select>
- <select id="selectParentid" resultType="java.lang.Integer" parameterType="java.lang.Integer">
- select
- count(1)
- from SysDepartment
- where parentid = #{parentid}
- </select>
- <select id="selectMaxParentid" resultType="java.lang.Integer" parameterType="java.lang.Integer">
- select
- max(DepartmentID)
- from SysDepartment
- where parentid = #{parentid}
- </select>
- <!-- 分页查询 部门-->
- <select id="sysDepartmentQuery" resultMap="BaseResultMap">
- select * from SysDepartment WHERE IsDeleted=0
- <if test="departmentid != null and departmentid != '' and departmentid !=-1">
- AND DepartmentID LIKE CONCAT('%',#{departmentid},'%')
- </if>
- ORDER BY cast(DepartmentID as char(30))
- </select>
- <!-- <resultMap id="BaseResultMap5" type="com.ssm.model.system.SysDepartment" extends="BaseResultMap">
- <collection property="positions" ofType="com.ssm.model.system.SysPosition">
- <id property="positionid" column="positionid" />
- <result property="positionname" column="positionname" />
- <result property="positioncode" column="PositionCode" />
- </collection>
- </resultMap>
- <select id="sysDepartmentQuery" resultMap="BaseResultMap5">
- SELECT
- p.PositionName as positionname, 职位名称
- p.PositionCode as PositionCode,职位编码
- d.DepName as DepName,部门名称
- d.DepCode,部门编码
- p.IsDeleted,
- p.PositionID as positionid,
- d.DeptRoleCode,
- d.DepID as DepID
- FROM
- SysPosition p
- INNER JOIN SysDepartment d ON p.DepID=d.DepID
- ORDER BY d.DeptRoleCode
- </select> -->
- </mapper>
|