mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-05 08:50:25 +08:00
40 lines
931 B
Go
40 lines
931 B
Go
package api
|
|
|
|
import (
|
|
"mayfly-go/internal/db/application"
|
|
"mayfly-go/internal/db/domain/entity"
|
|
"mayfly-go/pkg/biz"
|
|
"mayfly-go/pkg/req"
|
|
"mayfly-go/pkg/utils/collx"
|
|
|
|
"github.com/may-fly/cast"
|
|
|
|
"strings"
|
|
)
|
|
|
|
type DbSqlExec struct {
|
|
dbSqlExecApp application.DbSqlExec `inject:"T"`
|
|
}
|
|
|
|
func (d *DbSqlExec) ReqConfs() *req.Confs {
|
|
reqs := [...]*req.Conf{
|
|
// 获取所有数据库sql执行记录列表
|
|
req.NewGet("/sql-execs", d.DbSqlExecs),
|
|
}
|
|
|
|
return req.NewConfs("/dbs", reqs[:]...)
|
|
}
|
|
|
|
func (d *DbSqlExec) DbSqlExecs(rc *req.Ctx) {
|
|
queryCond, page := req.BindQueryAndPage(rc, new(entity.DbSqlExecQuery))
|
|
|
|
if statusStr := rc.Query("status"); statusStr != "" {
|
|
queryCond.Status = collx.ArrayMap[string, int8](strings.Split(statusStr, ","), func(val string) int8 {
|
|
return cast.ToInt8(val)
|
|
})
|
|
}
|
|
res, err := d.dbSqlExecApp.GetPageList(queryCond, page, new([]entity.DbSqlExec))
|
|
biz.ErrIsNil(err)
|
|
rc.ResData = res
|
|
}
|