<?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. 转--Android资源总结(环境搭建/ 反编译工具)

    在Android发展前景相当好的情况下,本人最近搜集了一些关于Android的相关资源,当然包含以前发布的博客内容,进行了一次大整合,希望对和我一样是Android的初学者管用,如在文章中有所错误,敬 ...

  2. How To Easily Call WCF Services Properly z

    Please note: this article has been superceded by the documentation for the ChannelAdam WCF Library. ...

  3. zookeeper 监控 —— 阿里taokeeper

    TaoKeeper是一个围绕ZooKeeper做的监控与报表系统. 主要功能如下: 能够统计ZK集群连接数,Watcher数目 ,节点数等系列信息,并按一定规则进行一些聚合操作; 能够通过设置一些阈值 ...

  4. buildbot 自动启动

    buildbot的master或者slave,一般配置好了之后, 总希望永久可用,即使机器因为某些原因重启了,也会自动启动. 官网文档不推荐使用root启动master. 而是使用用户级别的cront ...

  5. android 4.4 状态栏隐藏

    这个是Android Developer上的原文 反正我也看得不是很懂 我知道的就是实现和导航栏和状态栏的透明 带一些渐变效果 1. 设置主题 <style name="Theme.T ...

  6. Net文章汇总帖

    DevExpress:Data Grid ExamplesHow to: Initialize Cells in Newly Created RowsHow to: Set a Cell Value ...

  7. Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException

    org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean ...

  8. http://www.cnblogs.com/chillsrc/category/49632.html

    http://www.cnblogs.com/chillsrc/category/49632.html

  9. C - Fractal(3.4.1)

    Description A fractal is an object or quantity that displays self-similarity, in a somewhat technica ...

  10. sqoop安装

    环境:Hadoop 2.3.0 sqoop 1.4.5 1.下载并解压sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz (解压完,名字会很长,可以根据需要自己修改下 ...