/
DslHistoryController.go
54 lines (48 loc) · 1.39 KB
/
DslHistoryController.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package api
import (
"github.com/1340691923/ElasticView/model"
"github.com/1340691923/ElasticView/platform-basic-libs/jwt"
"github.com/1340691923/ElasticView/platform-basic-libs/response"
"github.com/1340691923/ElasticView/platform-basic-libs/util"
. "github.com/gofiber/fiber/v2"
)
// DSL语法查询历史记录
type DslHistoryController struct {
BaseController
}
// 查询DSL历史记录列表
func (this DslHistoryController) ListAction(ctx *Ctx) error {
c, err := jwt.ParseToken(ctx.Get("X-Token"))
if err != nil {
return this.Error(ctx, err)
}
gmDslHistoryModel := model.GmDslHistoryModel{}
err = ctx.BodyParser(&gmDslHistoryModel)
if err != nil {
return this.Error(ctx, err)
}
gmDslHistoryModel.Uid = int(c.ID)
list, err := gmDslHistoryModel.List()
if err != nil {
return this.Error(ctx, err)
}
count, err := gmDslHistoryModel.Count()
if err != nil {
return this.Error(ctx, err)
}
return this.Success(ctx, response.SearchSuccess, util.Map{"list": list, "count": count})
}
// 清空DSL查询记录
func (this DslHistoryController) CleanAction(ctx *Ctx) error {
c, err := jwt.ParseToken(ctx.Get("X-Token"))
if err != nil {
return this.Error(ctx, err)
}
gmDslHistoryModel := model.GmDslHistoryModel{}
gmDslHistoryModel.Uid = int(c.ID)
err = gmDslHistoryModel.Clean()
if err != nil {
return this.Error(ctx, err)
}
return this.Success(ctx, response.OperateSuccess, nil)
}