参考mybatis sql:

<select id="xxx" resultType="com.xxxx.xxx.vo.xx.xx" parameterType="com.xxx.xx.req.xxx">
SELECT
apply.apply_no,
apply.loan_apply_code,
cust.cust_name,
cust.id_no,
cust.mobile,
apply.loan_amount,
CONCAT(apply.init_period, CASE WHEN (apply.period_unit_code='1') then '天' WHEN (apply.period_unit_code='2') then '月' END) as init_period_str,
apply.contract_rate,
apply.apply_status,
(SELECT dict_value FROM aim_t_sys_dict_data WHERE dict_code = apply.apply_status AND dict_type = 'APPLY_STATUS' AND deleted='0' LIMIT 1) as apply_status_str,
apply.assets_code,
<!-- apply.assets_platform_code, -->
platform.platform_name,
<!-- apply.product_code, -->
product.product_name,
account.create_time,
apply.agreement_confirm_time
FROM aim_t_loan_apply apply
LEFT JOIN aim_t_cust_base cust ON apply.cust_code = cust.cust_code
LEFT JOIN aim_t_loan_assets assets ON apply.apply_no = assets.apply_no
LEFT JOIN aim_t_assets_platform platform on apply.assets_platform_code = platform.platform_code
LEFT JOIN aim_t_product product on apply.product_code = product.product_code
LEFT JOIN aim_t_cust_sub_account account on cust.id_no=account.id_no and cust.id_type=account.id_type
<where>
<if test="userPlatformCodeList != null and userPlatformCodeList.size > 0">
AND apply.assets_platform_code in
<foreach collection="userPlatformCodeList" index="userPlatformCode" item="userPlatformCode"
open="(" separator="," close=")">
#{userPlatformCode,jdbcType=VARCHAR}
</foreach>
</if>
<if test="custName != null and custName != ''">
AND cust.cust_name = #{custName,jdbcType=VARCHAR}
</if>
<if test="mobile != null and mobile != ''">
AND cust.mobile = #{mobile,jdbcType=VARCHAR}
</if>
<if test="idNo != null and idNo !=''">
AND cust.id_no = #{idNo,jdbcType=VARCHAR}
</if>
<if test="loanApplyCode != null and loanApplyCode != ''">
AND apply.loan_apply_code = #{loanApplyCode,jdbcType=VARCHAR}
</if>
<if test="assetsPlatformCode != null and assetsPlatformCode !=''">
AND apply.assets_platform_code = #{assetsPlatformCode,jdbcType=VARCHAR}
</if>
<if test="productCode != null and productCode != ''">
AND apply.product_code = #{productCode,jdbcType=VARCHAR}
</if>
<if test="initPeriod != null">
AND apply.init_period = #{initPeriod,jdbcType=INTEGER}
</if>
<if test="periodUnitCode != null and periodUnitCode != ''">
AND apply.period_unit_code = #{periodUnitCode,jdbcType=VARCHAR}
</if>
<if test="loanApplyStartTime != null and loanApplyStartTime != '' and loanApplyEndTime != null and loanApplyEndTime != ''">
AND apply.loan_apply_time BETWEEN #{loanApplyStartTime,jdbcType=VARCHAR} and #{loanApplyEndTime,jdbcType=VARCHAR}
</if>
<if test="applyStatus != null and applyStatus != ''">
AND apply.apply_status = #{applyStatus,jdbcType=VARCHAR}
</if>
<if test="approveStatus != null and approveStatus != ''">
AND apply.approve_status = #{approveStatus,jdbcType=VARCHAR}
</if>
<if test="isOpen != null and isOpen !=''">
AND apply.is_open = #{isOpen,jdbcType=VARCHAR}
</if>
<if test='agreementConfirmStatus != null and agreementConfirmStatus=="0"'>
AND (apply.agreement_confirm_time IS NULL or apply.agreement_confirm_time = '')
</if>
<if test='agreementConfirmStatus != null and agreementConfirmStatus=="1"'>
AND apply.agreement_confirm_time IS NOT NULL
</if>
<if test="loanStartTime != null and loanStartTime != ''">
AND assets.loan_time <![CDATA[>=]]> #{loanStartTime,jdbcType=VARCHAR}
</if>
<if test="loanEndTime != null and loanEndTime !=''">
AND assets.loan_time <![CDATA[<=]]> #{loanEndTime,jdbcType=VARCHAR}
</if>
AND apply.deleted = '0'

mybatis sql参考的更多相关文章

  1. Mybatis sql映射文件浅析 Mybatis简介(三)

    简介 除了配置相关之外,另一个核心就是SQL映射,MyBatis 的真正强大也在于它的映射语句. Mybatis创建了一套规则以XML为载体映射SQL 之前提到过,各项配置信息将Mybatis应用的整 ...

  2. Mybatis sql映射文件浅析 Mybatis简介(三) 简介

    Mybatis sql映射文件浅析 Mybatis简介(三)   简介 除了配置相关之外,另一个核心就是SQL映射,MyBatis 的真正强大也在于它的映射语句. Mybatis创建了一套规则以XML ...

  3. Mybatis SQL映射文件详解

    Mybatis SQL映射文件详解 mybatis除了有全局配置文件,还有映射文件,在映射文件中可以编写以下的顶级元素标签: cache – 该命名空间的缓存配置. cache-ref – 引用其它命 ...

  4. ibatis mybatis sql语句配置 符号不兼容 大于号 小于号<!CDATA[ ]>

    ibatis mybatis sql语句配置 符号不兼容 大于号 小于号<!CDATA[ ]> 因为这个是xml格式的,所以不允许出现类似">"这样的字符,但是都 ...

  5. MyBatis SQL xml处理小于号与大于号

    MyBatis SQL xml处理小于号与大于号 当我们需要通过xml格式处理sql语句时,经常会用到< ,<=,>,>=等符号,但是很容易引起xml格式的错误,这样会导致后台 ...

  6. mybatis 参数为list时,校验list是否为空, mybatis ${}与#{}的区别,Mybatis sql in

    1.mybatis 参数为list时,校验list是否为空 2. mybatis ${}与#{}的区别 简单来说#{} 解析的是占位符?可以防止SQL注入, 比如打印出来的语句 select * fr ...

  7. SpringMVC4+MyBatis+SQL Server2014 基于SqlSession实现读写分离(也可以实现主从分离)

    前言 上篇文章我觉的使用拦截器虽然方便快捷,但是在使用读串还是写串上你无法控制,我更希望我们像jdbc那样可以手动控制我使用读写串,那么这篇则在sqlsession的基础上实现读写分离, 这种方式则需 ...

  8. SQL 参考

    本主题将介绍 ArcGIS 中的选择表达式所用的常规查询的各个元素.ArcGIS 中的查询表达式使用常规 SQL 语法. 警告: SQL 语法不适用于使用字段计算器计算字段. 字段 在 SQL 表达式 ...

  9. mybatis 学习笔记(二):mybatis SQL注入问题

    mybatis 学习笔记(二):mybatis SQL注入问题 SQL 注入攻击 首先了解下概念,什么叫SQL 注入: SQL注入攻击,简称SQL攻击或注入攻击,是发生于应用程序之数据库层的安全漏洞. ...

随机推荐

  1. redis设置过期时间

  2. Ubuntu 17.10 安装Caffe(cpu)并配置Matlab接口

    (1)安装依赖: sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-ser ...

  3. win10下VM 中centos 安装共享文件

    一.  安装VMware Tools VMwareTools的安装脚本是要使用到perl的,而CentOS 6自身不带perl,所以需要自己安装.可以自己下载源代码编译,也可以直接用yum来安装. y ...

  4. spring集成jedis简单实例

    jedis是redis的java客户端,spring将redis连接池作为一个bean配置. redis连接池分为两种,一种是“redis.clients.jedis.ShardedJedisPool ...

  5. es6学习日记5-对象的扩展

    属性的简洁表示法 ES6 允许直接写入变量和函数,作为对象的属性和方法.这样的书写更加简洁. const foo = 'bar'; const baz = {foo}; baz // {foo: &q ...

  6. Python全栈之路----函数进阶----装饰器

    Python之路,Day4 - Python基础4 (new版) 装饰器 user_status = False #用户登录后改为True def login(func): #传入想调用的函数名 de ...

  7. 为什么要将Apache与Tomcat集成?(或不)

    Why should I integrate Apache with Tomcat? (or not) There are many reasons to integrate Tomcat with ...

  8. Spring Boot 非常好的学习资料

    from@https://gitee.com/didispace/SpringBoot-Learning Spring Boot 2.0 新特性学习 简介与概览 Spring Boot 2.0 正式发 ...

  9. java设计模式--UML类图

    2016-06-07 22:46:16 下面简单介绍UML类图:(图是截取的,大家可以用UML工具去画) 1.描述类的类图 类:Person 属性:name   age   sex 访问权限:-  表 ...

  10. day056-58 django多表增加和查询基于对象和基于双下划线的多表查询聚合 分组查询 自定义标签过滤器 外部调用django环境 事务和锁

    一.多表的创建 from django.db import models # Create your models here. class Author(models.Model): id = mod ...