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>= #{applydatestart,jdbctype=DATE}</if><ifTest= "Applydateend! = null and Applydateend! =" ">and apply_date<= #{applydateend,jdbctype=DATE}</if>and Del_flag= 0ORDER BY apply_date desc limit #{beginrow},#{pagesize}</select>
Mybatis Learning Summary _12_mybatis+mysql Paging query