• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

SqlServer分页工具类

mysql 搞代码 4年前 (2022-01-09) 36次浏览 已收录 0个评论

无详细内容 无 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

<style> .CodeEntity .code_pieces ul.piece_anchor{width:25px;position:absolute;top:25px;left:-30px;z-index:1000;} .CodeEntity .code_pieces ul.piece_anchor li{width:25px;background: #efe;margin-bottom:2px;} .CodeEntity .code_pieces ul.piece_anchor li{border-left:3px #40AA63 solid;border-right:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li:hover{border-right:3px #40AA63 solid;border-left:3px #efe solid;} .CodeEntity .code_pieces ul.piece_anchor li a{color: #333;padding: 3px 10px;} .CodeEntity .code_pieces .jump_to_code{visibility:hidden;position:relative;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code{visibility:visible;} .CodeEntity .code_pieces .code_piece:hover .jump_to_code a{text-decoration:none;} .CodeEntity .code_pieces h2 i{float:right;font-style:normal;font-weight:normal;} .CodeEntity .code_pieces h2 i a{font-size:9pt;background: #FFFFFF;color:#00A;padding: 2px 5px;text-decoration:none;} </style> <!—ecms

    –> <!—ecms

  • $velocityCount
  • –> <!—ecms

–>

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,<strong style="color:transparent">本文来源gaodai#ma#com搞@@代~&码网^</strong>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;	}

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:SqlServer分页工具类
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址