Ipage 分頁踩坑 避雷

2021-10-19 21:47:49 字數 3442 閱讀 3250

注!!!

沒啥事的時候,總結出了一點點 相關的筆記, 有需要的拿去!!! 不需要的, 路過就行 ! ! !

/**

* **標籤集合

*/private list

tagids;

``

當我封裝好物件時 ,寫完sql時進行分頁查詢時測試時發現分頁的資料不準確,分頁總條數不準確 因為內巢狀陣列原因,mybatis會自動進行聚合,和在資料庫顯示的條數不一致,在顯示json資訊時,比如資料庫的sql查詢時顯示10條資訊 , json分頁顯示時為8條資訊 , json分頁顯示總頁數為10條資訊 這樣就造成了總頁數不準確,前端獲取分頁時產生分頁bug解決sql如下

"query**********select" resulttype=

"com.zx.erp.media.entity.**********selectentity"

>

select

*from

(select

mu.**********_title as title,

mu.**********_id as **********id,

mu.file_type as filetype,

le.lecturer as lecturer,

le.lecturer_desc as lecturerdesc,

mu.**********_type as **********type,

mu.file_path as filepath,

le.good_skills as goodskills,

le.`desc` as `desc`,

mu.create_time as createtime,

mu.update_time as updatetime,

mu.create_user as createuser,

mu.update_user as updateuser,

us.user_name updatename,

cs.user_name createname,

mu.local_file_name as localfilename

from

********** mu

left join lecturer le on le.**********_id = mu.**********_id

left join **********_tag_relation mtr on mtr.**********_id = le.**********_id

left join `user` cs on cs.user_id = mu.create_user

left join `user` us on us.user_id = mu.update_user

<

if test=

"dto.title != null and dto.title !=''"

>

and mu.**********_title like concat

('%',#,

'%')

>

<

if test=

"dto.lecturer != null and dto.lecturer !=''"

>

and le.lecturer like concat

('%',#,

'%')

>

<

if test=

"dto.type !=null and dto.type != ''"

>

and mu.**********_type= #

>

<

if test=

"dto.createstarttime !=null"

>

and mu.create_time >= #

>

<

if test=

"dto.createendtime !=null"

>

and mu.create_time <

= #>

<

if test=

"dto.unupdatemessage == 1 and dto.unupdatemessage!=null "

>

and (le.lecturer_desc is not null and le.good_skills is not null and le.desc is not null)

>

<

if test=

"dto.unupdatemessage == 2 and dto.unupdatemessage!=null "

>

and (le.lecturer_desc is null and le.good_skills is null and le.desc is null)

>

<

if test=

"dto.unchooselabel ==1 and dto.unchooselabel!=null "

>

and mtr.tag_id is not null

>

<

if test=

"dto.unchooselabel ==2 and dto.unchooselabel!=null "

>

and mtr.tag_id is null

>

<

if test=

"dto.tagid != null and dto.tagid.size != 0 "

>

and mtr.tag_id in

"dto.tagid" item=

"tagid" open=

"(" separator=

"," close=

")">(#)

<

/foreach>

>

<

/where>

group by mu.**********_id) as a

order by a.createtime desc

<

/select>

"selecttagids" resulttype=

"com.zx.erp.media.entity.tagidslist"

>

select

tag_id as tagid

from **********_tag_relation

where

**********_id=#

<

/select>

Ipage分頁和PageHelper分頁

兩個都用於分頁,常用的應該是pagehelper了,使用方法是 pagehelper.startpage 然後後邊寫sql就可以。緊接著的乙個sql起作用。ipage則需要在dao層傳入ipage的實現類page物件,該物件實現了ipage。區別 pagehelper內部原理是將傳入的頁碼和條數賦值...

systemtap embedded C 踩坑筆記

官方文件 systemtap的embedded c中,不能 include 也不能用printf和print。那怎麼列印呢?用stap printf。用法與printf一樣。還可以訪問cript中的全域性變數。官方文件中的示例 global var global var2 100 function ...

Aggregation MongoDB踩坑記錄

對某些篩選條件進行分頁查詢,開始每一頁的有效data都不足pagesize,最後發現,aggregation 的pipeline是有先後順序的。錯誤 agg aggregation.newaggregation aggregation.skip curpage 1 pagesize aggregat...