SqlServer分页工具类
public
s
sqlserver
内容
分页
工具
详细
无详细内容 无 public String findArticle(TArticle article, Integer pageNo,Integer pageSize, String sortName, String sortOrder, Integer num) {StringBuffer sql = new StringBuffer("select top 5 a.id,a.title,a.cate_one,m.parent_id,a.cate_two,m.n
public String findArticle(TArticle article, Integer pageNo, Integer pageSize, String sortName, String sortOrder, Integer num) { StringBuffer sql = new StringBuffer( "select top 5 a.id,a.title,a.cate_one,m.parent_id,a.cate_two,m.name as cate_two_name," + "a.content,a.rank,a.check_status,a.check_time,a.creator,a.create_time,a.updator,a.update_time " + "from t_article a left join t_menu m on a.cate_two = m.id"); if (!CommonUtils.isNullOrLessThanOne(pageNo) && !CommonUtils.isNullOrLessThanOne(pageSize)) { int start = (pageNo-1)*pageSize; int limit = pageSize; String tableName = "t_article a left join t_menu m on a.cate_two = m.id"; String fields = "a.id,a.title,a.cate_one,m.parent_id,a.cate_two,m.name as cate_two_name," + "a.content,a.rank,a.check_status,a.check_time,a.creator,a.create_time,a.updator,a.update_time"; StringBuffer filter = new StringBuffer("1 = 1"); if(article != null){ if (StringUtils.hasLength(article.getTitle())) filter.append(" and a.title like '%").append(article.getTitle()) .append("%'"); if (article.getCateOne() != null && article.getCateOne() != 0) filter.append(" and a.cate_one=").append(article.getCateOne()); if (article.getCateTwo() != null && article.getCateTwo() != 0) filter.append(" and a.cate_two=").append(article.getCateTwo()); if (article.getCreator() != null) filter.append(" and a.creator=").append(article.getCreator()); if (article.getCheckStatus() != null){ if(article.getCheckStatus() == -1) filter.append(" and a.check_status in (0,1,2)"); else{ filter.append(" and a.check_status=").append( article.getCheckStatus()); } } } StringBuffer orderBy = new StringBuffer(""); if (StringUtils.hasLength(sortName) && StringUtils.hasLength(sortOrder)) { orderBy.append("a.").append(this.getColumnPropertyMap().get(sortName)) .append(" ").append(sortOrder); } sql = SqlString.getPaginationSql(start,limit,tableName,fields,filter.toString(),orderBy.toString()); }else{ if (article != null) { sql.append(" where 1=1 "); if (StringUtils.hasLength(article.getTitle())) sql.append(" and a.title like '%").append(article.getTitle()) .append("%'"); if (article.getCateOne() != null) sql.append(" and a.cate_one=").append(article.getCateOne()); if (article.getCateTwo() != null) sql.append(" and a.cate_two=").append(article.getCateTwo()); if (article.getCreator() != null) sql.append(" and a.creator=").append(article.getCreator()); if (article.getCheckStatus() != null) sql.append(" and a.check_status=").append( article.getCheckStatus()); } if (StringUtils.hasLength(sortName) && StringUtils.hasLength(sortOrder)) { sql.append(" order by rank desc,") .append(this.getColumnPropertyMap().get(sortName)) .append(" ").append(sortOrder); } } return sql; }
登录后复制
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章
R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
刺客信条阴影:贝壳谜语解决方案
2 周前
By DDD
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前
By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
3 周前
By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

GiteePages静态网站部署失败:404错误排查与解决在使用Gitee...

H5页面需要持续维护,这是因为代码漏洞、浏览器兼容性、性能优化、安全更新和用户体验提升等因素。有效维护的方法包括建立完善的测试体系、使用版本控制工具、定期监控页面性能、收集用户反馈和制定维护计划。

关于Flex布局中紫色斜线区域的疑问在使用Flex布局时,你可能会遇到一些令人困惑的现象,比如在开发者工具(d...

如何在爬虫时获取58同城工作页面的动态数据?在使用爬虫工具爬取58同城的某个工作页面时,可能会遇到这样�...

JavaScript代码换行技巧详解在编写JavaScript代码时,我们经常会遇到一行代码过长的情况,这不仅影响代码的可读�...
