3
0

upd(crm): fix page as zero based index

This commit is contained in:
Tit Petric
2018-12-04 16:38:42 +01:00
parent 0c5f1ea97e
commit bb4fee2dde

View File

@@ -67,8 +67,8 @@ func (r *content) FindByID(id uint64) (*types.Content, error) {
}
func (r *content) Find(moduleID uint64, query string, page int, perPage int) (*FindResponse, error) {
if page < 1 {
page = 1
if page < 0 {
page = 0
}
if perPage <= 0 {
perPage = 50
@@ -95,7 +95,7 @@ func (r *content) Find(moduleID uint64, query string, page int, perPage int) (*F
sqlWhere := "WHERE module_id=? and deleted_at IS NULL"
sqlOrder := "ORDER BY id DESC"
sqlLimit := fmt.Sprintf("LIMIT %d, %d", (page-1)*perPage, perPage)
sqlLimit := fmt.Sprintf("LIMIT %d, %d", page*perPage, perPage)
switch true {
case query != "":