调整indexAction路径,允许用户自定义接收的slice,配合gorm只能搜索

This commit is contained in:
linwenxiang committed 2020-08-31 21:56:29 +08:00
1 parent b98997a69f
commit 4e39e915ea
4 files changed
+9 -13

No files matched your search

+3 -4
View File
@@ -2,9 +2,8 @@ package actions
import (
"errors"
"go-admin/dto"
"github.com/gin-gonic/gin"
"go-admin/dto"
"gorm.io/gorm"
"go-admin/tools"
@@ -13,8 +12,9 @@ import (
)
// IndexAction 通用查询动作
func IndexAction(m model.ActiveRecord, d dto.Dtor) gin.HandlerFunc {
func IndexAction(m model.ActiveRecord, d dto.Dtor, f func() interface{}) gin.HandlerFunc {
return func(c *gin.Context) {
list := f()
object := m.Generate()
req := d.Generate()
var err error
@@ -23,7 +23,6 @@ func IndexAction(m model.ActiveRecord, d dto.Dtor) gin.HandlerFunc {
err = errors.New("db connect not exist")
tools.HasError(err, "", 500)
}
list := object.GenerateList()
var count int64
switch idb.(type) {
case *gorm.DB: