| <?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.matrix.system.hive.dao.AreaDao"> | 
|      | 
|     <resultMap type="Area" id="AreaMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="name" column="name" /> | 
|             <result property="parentId" column="parent_id" /> | 
|     </resultMap> | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="Area" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO area ( | 
|             id, | 
|             name, | 
|             parent_id | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{name}, | 
|             #{parentId} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE area | 
|         <set> | 
|                 <if test="name != null and name !='' "> | 
|                     name = #{name}, | 
|                 </if>         | 
|                 <if test="parentId != null and parentId !='' "> | 
|                     parent_id = #{parentId}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from area where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM area | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="AreaMap"> | 
|         select  | 
|             id, | 
|             name, | 
|             parent_id | 
|         from area | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and name | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|                 and parent_id | 
|             </if> | 
|         </if> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|      | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord"    resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from area | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|             and id | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|             and name | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|             and parent_id | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="AreaMap"> | 
|         select  | 
|             id, | 
|             name, | 
|             parent_id | 
|         from area | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|     <!-- 根据parentId查询--> | 
|     <select id="selectByParentId" resultMap="AreaMap"> | 
|         select  | 
|             id, | 
|             name, | 
|             parent_id | 
|         from area | 
|         where  parent_id=#{parentId} | 
|     </select>     | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="AreaMap"> | 
|         select  | 
|             id, | 
|             name, | 
|             parent_id | 
|         from area | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and id  =#{record.id} | 
|             </if> | 
|             <if test="record.name != null and record.name !='' "> | 
|                 and name  =#{record.name} | 
|             </if> | 
|             <if test="record.parentId != null and record.parentId !='' "> | 
|                 and parent_id  =#{record.parentId} | 
|             </if> | 
|         </if> | 
|     </select> | 
|      | 
|      | 
|      | 
|   | 
|      | 
|      | 
|      | 
|      | 
|      | 
|      | 
| </mapper> |