mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-09-26 20:11:11 +08:00
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package resources
|
|
|
|
import (
|
|
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/model"
|
|
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/service/actions"
|
|
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/service/searches"
|
|
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/template/resource"
|
|
"github.com/quarkcloudio/quark-go/v2/pkg/builder"
|
|
)
|
|
|
|
type File struct {
|
|
resource.Template
|
|
}
|
|
|
|
// 初始化
|
|
func (p *File) Init(ctx *builder.Context) interface{} {
|
|
|
|
// 标题
|
|
p.Title = "文件"
|
|
|
|
// 模型
|
|
p.Model = &model.File{}
|
|
|
|
// 分页
|
|
p.PerPage = 10
|
|
|
|
return p
|
|
}
|
|
|
|
// 字段
|
|
func (p *File) Fields(ctx *builder.Context) []interface{} {
|
|
field := &resource.Field{}
|
|
|
|
return []interface{}{
|
|
field.ID("id", "ID"),
|
|
field.Text("name", "名称"),
|
|
field.Text("size", "大小").SetSorter(true),
|
|
field.Text("ext", "扩展名"),
|
|
field.Datetime("created_at", "上传时间"),
|
|
}
|
|
}
|
|
|
|
// 搜索
|
|
func (p *File) Searches(ctx *builder.Context) []interface{} {
|
|
return []interface{}{
|
|
searches.Input("name", "名称"),
|
|
searches.DatetimeRange("created_at", "上传时间"),
|
|
}
|
|
}
|
|
|
|
// 行为
|
|
func (p *File) Actions(ctx *builder.Context) []interface{} {
|
|
return []interface{}{
|
|
actions.BatchDelete(),
|
|
actions.Delete(),
|
|
}
|
|
}
|