<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="DepartmentInfoModel" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  >   <alias>
    <typeAlias alias="DepartmentInfoModel" type="Dscf.Global.Employee.Model.DepartmentInfoModel,Dscf.Global" />
  </alias>   <!--门店树 传参-->
  <parameterMaps>
    <parameterMap id="selectMap_Dept_DeptInfo" class="DepartmentInfoModel">
      <parameter property="Idenid" column="Idenid"/>
    </parameterMap>
  </parameterMaps>   <resultMaps>
    <resultMap id="selectMap_T_DepartmentInfo" class="DepartmentInfoModel">
      <result property="DepId" column="DepId"/>
      <result property="DepName" column="DepName"/>
      <result property="ParentDepId" column="ParentDepId"/>
      <result property="DepCode" column="DepCode"/>
      <result property="CustomerServicePhone" column="CustomerServicePhone"/>
      <result property="RevolvingLoanPhone" column="RevolvingLoanPhone"/>
      <result property="EarlyRepayPhone" column="EarlyRepayPhone"/>
      <result property="Email" column="Email"/>
      <result property="SignAddress" column="SignAddress"/>
      <result property="SignZipCode" column="SignZipCode"/>
      <result property="IsDeleted" column="IsDeleted"/>
      <result property="SignCity" column="SignCity"/>
      <result property="IsEnable" column="IsEnable"/>
      <result property="LastOperateId" column="LastOperateId"/>
      <result property="LastUpdateTime" column="LastUpdateTime"/>
      <result property="CreateTime" column="CreateTime"/>
      <result property="OperateId" column="OperateId"/>
      <result property="IsReceiveEmail" column="IsReceiveEmail"/>
    </resultMap>     <!--门店树 返回值 -->
    <resultMap id="selectMap_T_DepartmentInfoTree" class="DepartmentInfoModel">
      <result property="DepId" column="DepId"/>
      <result property="SignZipCode" column="SignZipCode"/>
      <result property="IsDeleted" column="IsDeleted"/>
      <result property="SignCity" column="SignCity"/>
      <result property="IsEnable" column="IsEnable"/>
      <result property="LastOperateId" column="LastOperateId"/>
      <result property="LastUpdateTime" column="LastUpdateTime"/>
      <result property="CreateTime" column="CreateTime"/>
      <result property="OperateId" column="OperateId"/>
      <result property="DepName" column="DepName"/>
      <result property="ParentDepId" column="ParentDepId"/>
      <result property="DepCode" column="DepCode"/>
      <result property="CustomerServicePhone" column="CustomerServicePhone"/>
      <result property="RevolvingLoanPhone" column="RevolvingLoanPhone"/>
      <result property="EarlyRepayPhone" column="EarlyRepayPhone"/>
      <result property="Email" column="Email"/>
      <result property="SignAddress" column="SignAddress"/>       <result property="ParentName" column="ParentName"/>
      <result property="sort" column="sort"/>
      <result property="level" column="level"/>
      <result property="IsReceiveEmail" column="IsReceiveEmail"/>
    </resultMap>
  </resultMaps>   <statements>
    <!-- 查询  需要后动修改分页时的排序字段 -->
    <select id="select_T_DepartmentInfo" resultMap="selectMap_T_DepartmentInfo"   resultClass="DepartmentInfoModel"      parameterClass="DepartmentInfoModel">
      SELECT
      <isNotNull property="TopNums">
        <![CDATA[ top $TopNums$]]>
      </isNotNull>
      MAX(row_n) over(partition by ) as TotalItems, *
      FROM
      (
      <!-- ********* 必须要修改 order by a.Id ********* -->
      SELECT ROW_NUMBER() OVER ( PARTITION BY  ORDER BY a.DepId) AS row_n,a.DepId,a.DepName,a.ParentDepId,a.DepCode,a.CustomerServicePhone,a.RevolvingLoanPhone,a.EarlyRepayPhone,a.Email,a.SignAddress,a.SignZipCode,a.IsDeleted,a.SignCity,a.IsEnable,a.LastOperateId,a.LastUpdateTime,a.CreateTime,a.OperateId,a.IsReceiveEmail
      FROM  T_DepartmentInfo as a
      <dynamic prepend="where">         <isNotNull prepend="and" property="DepId">
          <![CDATA[ a.DepId=#DepId#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="IsReceiveEmail">
          <![CDATA[ a.IsReceiveEmail=#IsReceiveEmail#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="DepName">
          <![CDATA[ a.DepName=#DepName#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="ParentDepId">
          <![CDATA[ a.ParentDepId=#ParentDepId#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="DepCode">
          <![CDATA[ a.DepCode=#DepCode#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="CustomerServicePhone">
          <![CDATA[ a.CustomerServicePhone=#CustomerServicePhone#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="RevolvingLoanPhone">
          <![CDATA[ a.RevolvingLoanPhone=#RevolvingLoanPhone#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="EarlyRepayPhone">
          <![CDATA[ a.EarlyRepayPhone=#EarlyRepayPhone#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="Email">
          <![CDATA[ a.Email=#Email#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="SignAddress">
          <![CDATA[ a.SignAddress=#SignAddress#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="SignZipCode">
          <![CDATA[ a.SignZipCode=#SignZipCode#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="IsDeleted">
          <![CDATA[ a.IsDeleted=#IsDeleted#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="SignCity">
          <![CDATA[ a.SignCity=#SignCity#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="IsEnable">
          <![CDATA[ a.IsEnable=#IsEnable#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="LastOperateId">
          <![CDATA[ a.LastOperateId=#LastOperateId#  ]]>
        </isNotNull>         <isNotNull prepend="and" property="LastUpdateTime_B">
          <![CDATA[ a.LastUpdateTime>=#LastUpdateTime_B# ]]>
        </isNotNull>
        <isNotNull prepend="and" property="LastUpdateTime_E">
          <![CDATA[ a.LastUpdateTime<=#LastUpdateTime_E# ]]>
        </isNotNull>         <isNotNull prepend="and" property="CreateTime_B">
          <![CDATA[ a.CreateTime>=#CreateTime_B# ]]>
        </isNotNull>
        <isNotNull prepend="and" property="CreateTime_E">
          <![CDATA[ a.CreateTime<=#CreateTime_E# ]]>
        </isNotNull>         <isNotNull prepend="and" property="OperateId">
          <![CDATA[ a.OperateId=#OperateId#  ]]>
        </isNotNull>         <!-- 一个例子 -->
        <!--<isNotEmpty prepend="and" property="属性名">
                       字段名 like  #属性名# 
               </isNotEmpty>-->
      </dynamic>
      ) as a
      <dynamic prepend="where">
        <isNotNull property="PrevPageNums">
          <![CDATA[ a.row_n>$PrevPageNums$]]>
        </isNotNull>
      </dynamic>     </select>     <!-- 数据分析 树-->
    <procedure id="select_T_DepartmentInfoTree" parameterMap="selectMap_Dept_DeptInfo"  resultMap="selectMap_T_DepartmentInfoTree" >
      Proc_LoanStorDept
    </procedure>     <!-- 添加 -->
    <insert id="insert_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
      <selectKey property="DepId" type="post" resultClass="int">
        ${selectKey}
      </selectKey>
      INSERT INTO T_DepartmentInfo
      (
      DepName,ParentDepId,DepCode,CustomerServicePhone,RevolvingLoanPhone,EarlyRepayPhone,Email,SignAddress,SignZipCode,IsDeleted,SignCity,IsEnable,LastOperateId,LastUpdateTime,CreateTime,OperateId,IsReceiveEmail
      ) VALUES
      (
      #DepName#,#ParentDepId#,#DepCode#,#CustomerServicePhone#,#RevolvingLoanPhone#,#EarlyRepayPhone#,#Email#,#SignAddress#,#SignZipCode#,#IsDeleted#,#SignCity#,#IsEnable#,#LastOperateId#,#LastUpdateTime#,#CreateTime#,#OperateId#,#IsReceiveEmail#
      )     </insert>     <!-- 更新  -->
    <update id="update_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
      UPDATE T_DepartmentInfo SET       DepName=#DepName#,
      ParentDepId=#ParentDepId#,
      DepCode=#DepCode#,
      CustomerServicePhone=#CustomerServicePhone#,
      RevolvingLoanPhone=#RevolvingLoanPhone#,
      EarlyRepayPhone=#EarlyRepayPhone#,
      Email=#Email#,
      SignAddress=#SignAddress#,
      SignZipCode=#SignZipCode#,
      IsDeleted=#IsDeleted#,
      SignCity=#SignCity#,
      IsEnable=#IsEnable#,
      LastOperateId=#LastOperateId#,
      LastUpdateTime=#LastUpdateTime#,
      CreateTime=#CreateTime#,
      OperateId=#OperateId#,
      IsReceiveEmail=#IsReceiveEmail#
      <!--  -->
      WHERE T_DepartmentInfo.DepId=#DepId#
    </update>     <!--删除-->
    <delete id="delete_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
      DELETE FROM T_DepartmentInfo where DepId=#DepId#
    </delete>     <!-- 删除-->
    <delete id="delete_flag_T_DepartmentInfo" parameterClass="DepartmentInfoModel">
      UPDATE  T_DepartmentInfo set IsDeleted =  where DepId=#DepId#
    </delete>
  </statements>
</sqlMap>   

ibatis 存储过程写法的更多相关文章

  1. SQL组合查询的存储过程写法

    最进一个项目 里面有个查询的功能,它是进行组合查询的, 而且用的是存储过程写.写这样的存储过程,需要注意单引号的使用,请看本人下面的例子,假如你以后写的话 记得注意写就行: create proc s ...

  2. mysql数据库-定义函数-存储过程写法

    ------------- mysql  定义自定义函数写法 DELIMITER $$ USE `iwmsdb`$$ DROP FUNCTION IF EXISTS `F_WM_DBNAME`$$ C ...

  3. oracle ibatis 存储过程 返回游标 嵌套表

    自己解决问题了 问题总结: 1.index by表不能存储在数据库中的type中,故选择嵌套表. 2.ibatis不支持oracle的复合数据类型的返回.(个人理解) 3.替代方案:用返回oracle ...

  4. SQL Server分页的存储过程写法以及性能比较

    ------创建数据库data_Test ----- create database data_Test GO use data_Test GO create table tb_TestTable - ...

  5. iBATIS存储过程

    使用iBATIS配置来调用存储过程.为了理解这一章,首先需要了解我们是如何在MySQL中创建一个存储过程. 在继续对本章学习之前,可以通过MySQL存储过程. 我们已经在MySQL下有EMPLOYEE ...

  6. Oracle存储过程写法

    create or replace procedure QIANFEIGL_JIAOKUANDY( cebenh varchar2, kehuh varchar2, hetongh varchar2, ...

  7. mysql存储过程写法—动态参数运用

    --删除 双击代码全选 1 drop procedure if exists up_common_select --创建 双击代码全选 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...

  8. Oracle常用存储过程写法

    写在前面 这段时间工作最长接触到的就是Oracle数据库,不论查数据,还是统计.运行job,都离不开PL/SQL 存储过程,下面就整理下经常用到的知识. 一.Function函数 函数是执行非查询语句 ...

  9. 【Oracle】存储过程写法小例子

    1.存储过程的基本语法: CREATE OR REPLACE PROCEDURE 存储过程名(param1 in type,param2 out type) IS 变量1 类型(值范围); 变量2 类 ...

随机推荐

  1. Shell 重定向 &>file,2>&1,1>&2 的区别

    Shell上:0表示标准输入1表示标准输出2表示标准错误输出> 默认为标准输出重定向,与1>相同2>&1 意思是 把标准错误输出重定向到标准输出1>&2 意思是 ...

  2. memcpy

    函数原型 void *memcpy(void*dest, const void *src, size_t n); 功能 由src指向地址为起始地址的连续n个字节的数据复制到以destin指向地址为起始 ...

  3. java多线程的使用2

    1.join与interrupt的用法 class Sleeper extends Thread { private int duration; public Sleeper(String name, ...

  4. Java调用ffmepg+mencoder视频格式转换(*)

    PS: 建议大家在官网下载最新的资源 其他格式转FLV格式,可以用Java调用ffmpeg和memcoder实现 ffmepg: D:\ffmpeg\bin\ffmpeg.exe -i E:\1.mp ...

  5. C++学习19 类的多继承

    在前面的例子中,派生类都只有一个基类,称为单继承.除此之外,C++也支持多继承,即一个派生类可以有两个或多个基类. 多继承容易让代码逻辑复杂.思路混乱,一直备受争议,中小型项目中较少使用,后来的 Ja ...

  6. java 反射技术

    什么是反射?反射就是将字节码中的各种成分映射到相应的java类中来,java反射技术自JDK1.1以来就出现了,目前大多数流行的框架都采用了这种技术,可见其重要性,这篇文章将详细介绍我对java反射技 ...

  7. PYTHON ASYNCIO: FUTURE, TASK AND THE EVENT LOOP

    from :http://masnun.com/2015/11/20/python-asyncio-future-task-and-the-event-loop.html Event Loop On ...

  8. Mysql中的count()与sum()区别

    首先创建个表说明问题 CREATE TABLE `result` ( `name` varchar(20) default NULL, `subject` varchar(20) default NU ...

  9. onmousemove和onmouseout事件的调用,和js使用双引号、单引号的时候应该注意的问题

    使用js的时候,统一使用双引号,然后通过反斜杠进行转义 ①如果同时使用单引号.和双引号的情况下容易出现问题,导致标签中表示的事件不能调用, ②导致由于标签没有封口而出现样式布局错误 <!DOCT ...

  10. Spark核心概念之RDD

    RDD: Resilient Distributed Dataset RDD的特点: 1.A list of partitions       一系列的分片:比如说64M一片:类似于Hadoop中的s ...