Merge branch 'sxy' into dev
This commit is contained in:
commit
f45aa0ebe0
@ -7,6 +7,7 @@ import (
|
||||
"exhibition-register/pkg/app"
|
||||
"exhibition-register/pkg/msg"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@ -79,12 +80,12 @@ func RecordList(in *exhibition.RecordListReq) (data []*model.RegisterRecord, tot
|
||||
if total == 0 {
|
||||
return
|
||||
}
|
||||
sortBy := "created_at desc"
|
||||
sortBy := "create_at %s,id %s"
|
||||
if in.SortKey == 1 {
|
||||
sortBy = fmt.Sprintf("created_at%s%s", " ", in.Sort)
|
||||
sortBy = fmt.Sprintf(sortBy, "ASC", "ASC")
|
||||
}
|
||||
if in.SortKey == 2 {
|
||||
sortBy = fmt.Sprintf("updated_at%s%s", " ", in.Sort)
|
||||
sortBy = fmt.Sprintf(sortBy, "DESC", "DESC")
|
||||
}
|
||||
|
||||
if err = dbLink.Order(sortBy).Limit(int(in.PageSize)).Offset(int(offset)).Find(&data).Error; err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user