Mybatis Learning Summary _12_mybatis+mysql Paging query

Source: Internet
Author: User

 PackageCn.tsjinrong.fastfile.util;/*** @ClassName: Page * @Description: TODO (parent of pagination component, common content and logic used to encapsulate paging) *@authorZhanghaiyang * @date January 14, 2016 afternoon 12:37:55 * @Copyright ©2016 Shanghai Tong Good internet Financial Information Service Co., Ltd.*/ Public classPage {//paging criteria entered by the userPrivate intCurrentPage = 1;//Current PagePrivate intPageSize = 15;//maximum number of rows per page//conditions for implementing paged SQL are calculated based on user input criteriaPrivate intbegin;Private intend;//automatically calculated total number of rowsPrivate introws;//calculates the total number of pages based on the row count and then outputs the total pages to the pagePrivate intTotalpage; Public intgetRows () {returnrows;} Public voidSetrows (introws) { This. rows =rows;} Public intGettotalpage () {//total number of pages calculated based on row Countif(rows% PageSize = = 0) {Totalpage= Rows/PageSize;} Else{totalpage= rows/pagesize + 1;}returntotalpage;} Public voidSettotalpage (inttotalpage) { This. Totalpage =totalpage;} Public intGetbegin () {//when Mapper.xml uses the Begin property, it is evaluatedBegin = (currentPage-1) *pageSize;returnbegin;} Public voidSetBegin (intbegin) { This. Begin =begin;} Public intGetend () {//when Mapper.xml uses the End property, it is evaluatedEnd = CurrentPage * pageSize + 1;returnend;} Public voidSetEnd (intend) { This. end =end;} Public intGetcurrentpage () {returncurrentpage;} Public voidSetcurrentpage (intcurrentpage) { This. currentpage =currentpage;} Public intgetpagesize () {returnpageSize;} Public voidSetPageSize (intpageSize) { This. pageSize =pageSize;}} PublicModelandview findvideosbypage (httpservletrequest request, httpservletresponse response, fileproperties FP) { Modelandview Model=NewModelandview ("/video/video_list"); Map<string, object> params =NewHashmap<string, Object> (3);if(Stringutils.isnotblank (Fp.getbusiid ())) {Params.put ("Busiid", Fp.getbusiid ());}if(Stringutils.isnotblank (Fp.getapplyname ())) {Params.put ("Applyname", Fp.getapplyname ());}if(Fp.getapplydatestart ()! =NULL&&Stringutils.isnotblank (Fp.getapplydatestart ())) {Params.put ("Applydatestart", Dateutil.parsedate (Fp.getapplydatestart ()));} Else{params.put ("Applydatestart", Dateutil.addday (NewDate (),-7));}if(Fp.getapplydateend ()! =NULL&&Stringutils.isnotblank (Fp.getapplydateend ())) {Params.put ("Applydateend", Dateutil.parsedate (Fp.getapplydateend ()));} Else{params.put ("Applydateend", Dateutil.format (NewDate ()));} Fp.setrows (Fastfilevideoservice.selectrows (params)); Model.addobject ("Fastfilevideoinfopage", FP); List<FastfileVideoInfo> Fastfilevideoinfos =fastfilevideoservice.selectbypage (FP); Model.addobject ("Fastfilevideoinfos", Fastfilevideoinfos); Model.addobject ("Applydatestart", Dateutil.format (Dateutil.addday (NewDate (),-7)) ; Model.addobject ("Applydateend", Dateutil.format (NewDate ()));returnmodel;}<select id= "Selectbypage" resultmap= "Baseresultmap" parametertype= "Cn.tsjinrong.fastfile.util.FileProperties" >Select<include refid= "Base_column_list"/>From Fastfile_video_info where1=1<ifTest= "BUSIID! = null and BUSIID! =" ">and busi_id= #{busiid,jdbctype=VARCHAR}</if><ifTest= "Applyname! = null and Applyname! =" ">and Apply_name=#{applyname,jdbctype=VARCHAR}</if><ifTest= "Applydatestart! = null and Applydatestart! =" ">and apply_date&gt;= #{applydatestart,jdbctype=DATE}</if><ifTest= "Applydateend! = null and Applydateend! =" ">and apply_date&lt;= #{applydateend,jdbctype=DATE}</if>and Del_flag= 0ORDER BY apply_date desc limit #{beginrow},#{pagesize}</select>

Mybatis Learning Summary _12_mybatis+mysql Paging query

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.