springboot 注解版案例
1、dao层
/**
* 查询列表
* @param dataRequest
* @return
*/
@SelectProvider(type = CuiShouSqlProvider.class, method = "cuiShouList")
@Options(useGeneratedKeys = true)
public List<Map<String,String>> selectCuiShouOrderList(@Param("CuiKuanRequest") CuiKuanRequest dataRequest);
//public List<Map<String,String>> selectCuiShouOrderList(@Param("CuiKuanRequest") CuiKuanRequest dataRequest); /**
* 查询条数
* @param dataRequest
* @return
*/
@SelectProvider(type = CuiShouSqlProvider.class, method = "cuiShouListCountNum")
@Options(useGeneratedKeys = true)
public int CuiShouOrderListCountNum(@Param("CuiKuanRequest") CuiKuanRequest dataRequest);
2、sql拼接类
/**
* @author wuhongpu
* 催收动态sql拼接
*/ public class CuiShouSqlProvider { private Logger logger = LoggerFactory.getLogger(CuiShouSqlProvider.class);
/**
* 查询list列表方法
* @param dataRequest
* @return
*/
public String cuiShouList(CuiKuanRequest dataRequest){
StringBuilder selectSql = new StringBuilder();
selectSql.append("select * from (SELECT w.`status` AS clearStatus,w.thirdType,w.createTime,o.uuid,o.`status` AS orderStatus,o.lendingTime,o.refundTime,o.amountApply,u.realName,u.mobileNumber,u.idCardNo,datediff(now(),DATE_FORMAT(o.refundTime, '%Y-%m-%d')) AS DAY ");
selectSql.append("FROM wk_cuishou w LEFT JOIN orderorder o ON w.orderNo = o.uuid LEFT JOIN useruser u ON o.userUuid = u.uuid)t where 1=1 "); StringBuilder conditionSql = this.generateCondition(dataRequest); if (dataRequest.getPageNo() != null && dataRequest.getPageSize() != null) {
Integer num = (dataRequest.getPageNo() - ) * dataRequest.getPageSize();
conditionSql.append(" limit ").append(num.toString()).append(",")
.append(dataRequest.getPageSize().toString());
} selectSql.append(conditionSql);
logger.info(selectSql.toString());
return selectSql.toString();
} /**
* 统计条数方法
* @param dataRequest
* @return
*/
public String cuiShouListCountNum(CuiKuanRequest dataRequest) {
StringBuilder selectSql = new StringBuilder();
selectSql.append("select count(1) from (SELECT w.`status` AS clearStatus,w.thirdType,w.createTime,o.uuid,o.`status` AS orderStatus,o.lendingTime,o.refundTime,o.amountApply,u.realName,u.mobileNumber,u.idCardNo,datediff(now(),DATE_FORMAT(o.refundTime, '%Y-%m-%d')) AS DAY ");
selectSql.append("FROM wk_cuishou w LEFT JOIN orderorder o ON w.orderNo = o.uuid LEFT JOIN useruser u ON o.userUuid = u.uuid)t where 1=1 "); StringBuilder conditionSql = this.generateCondition(dataRequest);
selectSql.append(conditionSql);
this.logger.info(selectSql.toString());
return selectSql.toString();
} /**
* 条数分页方法
* @param dataRequest
* @return
*/
public String cuiShouListListByPage(CuiKuanRequest dataRequest) {
StringBuilder selectSql = new StringBuilder();
selectSql.append("select * from (SELECT w.`status` AS clearStatus,w.thirdType,w.createTime,o.uuid,o.`status` AS orderStatus,o.lendingTime,o.refundTime,o.amountApply,u.realName,u.mobileNumber,u.idCardNo,datediff(now(),DATE_FORMAT(o.refundTime, '%Y-%m-%d')) AS DAY ");
selectSql.append("FROM wk_cuishou w LEFT JOIN orderorder o ON w.orderNo = o.uuid LEFT JOIN useruser u ON o.userUuid = u.uuid)t where 1=1 "); StringBuilder conditionSql = this.generateCondition(dataRequest); Integer num = (dataRequest.getPageNo() - ) * dataRequest.getPageSize();
conditionSql.append("limit ").append(num.toString()).append(",")
.append(dataRequest.getPageSize().toString()); selectSql.append(conditionSql);
logger.info(selectSql.toString());
return selectSql.toString();
} /**
* 参数动态拼接方法
* @param dataRequest
* @return
*/
private StringBuilder generateCondition(CuiKuanRequest dataRequest) {
StringBuilder conditionSql = new StringBuilder(); if(dataRequest.getOrderStatus()!=null){
conditionSql.append("t.orderStatus=#{CuiKuanRequest.orderStatus} and ");
}
if(dataRequest.getClearStatus()!=null){
conditionSql.append("t.clearStatus=#{CuiKuanRequest.clearStatus} and ");
}
if(dataRequest.getDay()!=null ){
if(dataRequest.getDay()>=){
conditionSql.append("t.day>#{CuiKuanRequest.day} ");
}else{
conditionSql.append("t.day=#{CuiKuanRequest.day} ");
} }
conditionSql.append("order by t.day desc"); return conditionSql;
}
}
springboot 注解版案例的更多相关文章
- SSM-Spring-17:Spring中aspectJ注解版
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- AspectJ AspectJ是一个面向切面的框架,它扩展了Java语言,定义了AOP 语法,能够在编译期提供 ...
- SpringBoot整合Mybatis【非注解版】
接上文:SpringBoot整合Mybatis[注解版] 一.项目创建 新建一个工程 选择Spring Initializr,配置JDK版本 输入项目名 选择构建web项目所需的state ...
- SpringBoot整合Mybatis注解版---update出现org.apache.ibatis.binding.BindingException: Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1, param2]
SpringBoot整合Mybatis注解版---update时出现的问题 问题描述: 1.sql建表语句 DROP TABLE IF EXISTS `department`; CREATE TABL ...
- SpringBoot Mybatis整合(注解版),SpringBoot集成Mybatis(注解版)
SpringBoot Mybatis整合(注解版),SpringBoot集成Mybatis(注解版) ================================ ©Copyright 蕃薯耀 2 ...
- SpringBoot集成Mybatis(0配置注解版)
Mybatis初期使用比较麻烦,需要各种配置文件.实体类.dao层映射关联.还有一大推其它配置.当然Mybatis也发现了这种弊端,初期开发了generator可以根据表结构自动生成实体类.配置文件和 ...
- SpringBoot + MyBatis(注解版),常用的SQL方法
一.新建项目及配置 1.1 新建一个SpringBoot项目,并在pom.xml下加入以下代码 <dependency> <groupId>org.mybatis.spring ...
- SpringBoot数据访问之整合mybatis注解版
SpringBoot数据访问之整合mybatis注解版 mybatis注解版: 贴心链接:Github 在网页下方,找到快速开始文档 上述链接方便读者查找. 通过快速开始文档,搭建环境: 创建数据库: ...
- springMVC(注解版笔记)
springMVC(注解版) 较之于非注解版本,发生一下变化: 1.配置文件需要配置的标签有: <!-- 包的扫描,此包下面的所有包都启用注解 --> <context:compon ...
- Spring Boot整合MyBatis(非注解版)
Spring Boot整合MyBatis(非注解版),开发时采用的时IDEA,JDK1.8 直接上图: 文件夹不存在,创建一个新的路径文件夹 创建完成目录结构如下: 本人第一步习惯先把需要的包结构创建 ...
随机推荐
- kettle 数据提取效率提升
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/xpliruizhi123/article/details/54580850 最近发现KETTLE抽数 ...
- python测试开发django-22.admin首页和title修改
前言 django的admin首页默认显示的"Django 管理",title显示的是"Django 站点管理员",这里的文案内容可以修改成自己项目的后台页面内 ...
- tomcat使用不同jdk的解决方法
1,修改bin文件夹下面的catalina.bat文件,把如下内容 rem ----- Execute The Requested Command -------------------------- ...
- 实用ExtJS教程100例-001:开天辟地的Hello World
ExtJS功能繁多,要想彻底的了解确实很困难.作为初学者,如何能找到一条快速的通道呢?我觉得,如果你有Javascript的基础,那就不要惧怕ExtJS的复杂,从动手开始,遇到问题,解决问题,积累经验 ...
- Spring MVC+Mybatis 多数据源配置
文章来自:https://www.jianshu.com/p/fddcc1a6b2d8 1. 继承AbstractRoutingDataSource AbstractRoutingDataSource ...
- poj 2240 Arbitrage 题解
Arbitrage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 21300 Accepted: 9079 Descri ...
- How to delete team project from TFS visual studio ?
/* Author: Jiangong SUN */ To delete team project from TFS Visual Studio, you need to use "TFSD ...
- 基于fasttext的情感分析,准备先做一版
博客文章地址: https://blog.csdn.net/sinat_33741547/article/details/78803766 代码地址: https://github.com/lpty/ ...
- html table奇偶行颜色设置 (CSS选择器)
:nth-child(n) 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型.n 可以是数字.关键词或公式. 下面的例子, 设置表格的奇偶行背景颜色不同:单独设置表格的第1列背景颜色不同. & ...
- .NET开发过程中的全文索引使用技巧之Solr(转)
前言:相信许多人都听说过.net开发过程中基于Lucene.net实现的全文索引,而Solr是一个高性能,基于Lucene的全文搜索服务器.同时对其进行了扩展,提供了比Lucene更为丰富的查询 ...