-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathexport.go
More file actions
40 lines (34 loc) · 868 Bytes
/
export.go
File metadata and controls
40 lines (34 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package guard
import (
"github.com/GoAdminGroup/go-admin/context"
"github.com/GoAdminGroup/go-admin/modules/db"
"github.com/GoAdminGroup/go-admin/plugins/admin/modules/table"
"strings"
)
type ExportParam struct {
Panel table.Table
Id []string
Prefix string
IsAll bool
}
func Export(conn db.Connection) context.Handler {
return func(ctx *context.Context) {
prefix := ctx.Query("__prefix")
panel := table.Get(prefix)
if !panel.GetExportable() {
alert(ctx, panel, "operation not allow", conn)
ctx.Abort()
return
}
ctx.SetUserValue("export_param", &ExportParam{
Panel: panel,
Id: strings.Split(ctx.FormValue("id"), ","),
Prefix: prefix,
IsAll: ctx.FormValue("is_all") == "true",
})
ctx.Next()
}
}
func GetExportParam(ctx *context.Context) *ExportParam {
return ctx.UserValue["export_param"].(*ExportParam)
}