mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-03 16:00:25 +08:00
refactor: 分页组件统一替换&其他优化
This commit is contained in:
@@ -78,6 +78,7 @@ func createSqlExecRecord(execSqlReq *DbSqlExecReq) *entity.DbSqlExec {
|
||||
func (d *dbSqlExecAppImpl) Exec(execSqlReq *DbSqlExecReq) (*DbSqlExecRes, error) {
|
||||
sql := execSqlReq.Sql
|
||||
dbSqlExecRecord := createSqlExecRecord(execSqlReq)
|
||||
dbSqlExecRecord.Type = entity.DbSqlExecTypeOther
|
||||
var execRes *DbSqlExecRes
|
||||
isSelect := false
|
||||
|
||||
|
||||
@@ -16,8 +16,9 @@ type DbSqlExec struct {
|
||||
}
|
||||
|
||||
const (
|
||||
DbSqlExecTypeUpdate int8 = 1 // 更新类型
|
||||
DbSqlExecTypeDelete int8 = 2 // 删除类型
|
||||
DbSqlExecTypeInsert int8 = 3 // 插入类型
|
||||
DbSqlExecTypeQuery int8 = 4 // 查询类型,如select、show等
|
||||
DbSqlExecTypeOther int8 = -1 // 其他类型
|
||||
DbSqlExecTypeUpdate int8 = 1 // 更新类型
|
||||
DbSqlExecTypeDelete int8 = 2 // 删除类型
|
||||
DbSqlExecTypeInsert int8 = 3 // 插入类型
|
||||
DbSqlExecTypeQuery int8 = 4 // 查询类型,如select、show等
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"mayfly-go/pkg/req"
|
||||
"mayfly-go/pkg/utils"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -42,12 +43,15 @@ func (m *MachineScript) SaveMachineScript(rc *req.Ctx) {
|
||||
}
|
||||
|
||||
func (m *MachineScript) DeleteMachineScript(rc *req.Ctx) {
|
||||
msa := m.MachineScriptApp
|
||||
sid := GetMachineScriptId(rc.GinCtx)
|
||||
ms := msa.GetById(sid)
|
||||
biz.NotNil(ms, "该脚本不存在")
|
||||
rc.ReqParam = fmt.Sprintf("[scriptId: %d, name: %s, desc: %s, script: %s]", sid, ms.Name, ms.Description, ms.Script)
|
||||
msa.Delete(sid)
|
||||
idsStr := ginx.PathParam(rc.GinCtx, "scriptId")
|
||||
rc.ReqParam = idsStr
|
||||
ids := strings.Split(idsStr, ",")
|
||||
|
||||
for _, v := range ids {
|
||||
value, err := strconv.Atoi(v)
|
||||
biz.ErrIsNilAppendErr(err, "string类型转换为int异常: %s")
|
||||
m.MachineScriptApp.Delete(uint64(value))
|
||||
}
|
||||
}
|
||||
|
||||
func (m *MachineScript) RunMachineScript(rc *req.Ctx) {
|
||||
|
||||
@@ -115,9 +115,9 @@ func (r *Redis) RedisInfo(rc *req.Ctx) {
|
||||
var res string
|
||||
var err error
|
||||
if section == "" {
|
||||
res, err = ri.Cli.Info(ctx).Result()
|
||||
res, err = redisCli.Info(ctx).Result()
|
||||
} else {
|
||||
res, err = ri.Cli.Info(ctx, section).Result()
|
||||
res, err = redisCli.Info(ctx, section).Result()
|
||||
}
|
||||
|
||||
biz.ErrIsNilAppendErr(err, "获取redis info失败: %s")
|
||||
|
||||
@@ -346,13 +346,13 @@ func (r *RedisInstance) Close() {
|
||||
mode := r.Info.Mode
|
||||
if mode == entity.RedisModeStandalone || mode == entity.RedisModeSentinel {
|
||||
if err := r.Cli.Close(); err != nil {
|
||||
global.Log.Errorf("关闭redis单机实例[%d]连接失败: %s", r.Id, err.Error())
|
||||
global.Log.Errorf("关闭redis单机实例[%s]连接失败: %s", r.Id, err.Error())
|
||||
}
|
||||
r.Cli = nil
|
||||
}
|
||||
if mode == entity.RedisModeCluster {
|
||||
if err := r.ClusterCli.Close(); err != nil {
|
||||
global.Log.Errorf("关闭redis集群实例[%d]连接失败: %s", r.Id, err.Error())
|
||||
global.Log.Errorf("关闭redis集群实例[%s]连接失败: %s", r.Id, err.Error())
|
||||
}
|
||||
r.ClusterCli = nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user