mirror of
https://gitee.com/dromara/mayfly-go
synced 2026-02-07 05:15:36 +08:00
refactor: 后端路由定义方式&请求参数绑定重构
This commit is contained in:
@@ -35,8 +35,7 @@ const DEFAULT_ROW_SIZE = 5000
|
||||
|
||||
// @router /api/dbs [get]
|
||||
func (d *Db) Dbs(rc *req.Ctx) {
|
||||
condition := new(entity.DbQuery)
|
||||
condition.TagPathLike = rc.GinCtx.Query("tagPath")
|
||||
queryCond, page := ginx.BindQueryAndPage[*entity.DbQuery](rc.GinCtx, new(entity.DbQuery))
|
||||
|
||||
// 不存在可访问标签id,即没有可操作数据
|
||||
tagIds := d.TagApp.ListTagIdByAccountId(rc.LoginAccount.Id)
|
||||
@@ -44,16 +43,14 @@ func (d *Db) Dbs(rc *req.Ctx) {
|
||||
rc.ResData = model.EmptyPageResult[any]()
|
||||
return
|
||||
}
|
||||
condition.TagIds = tagIds
|
||||
rc.ResData = d.DbApp.GetPageList(condition, ginx.GetPageParam(rc.GinCtx), new([]vo.SelectDataDbVO))
|
||||
|
||||
queryCond.TagIds = tagIds
|
||||
rc.ResData = d.DbApp.GetPageList(queryCond, page, new([]vo.SelectDataDbVO))
|
||||
}
|
||||
|
||||
func (d *Db) Save(rc *req.Ctx) {
|
||||
form := &form.DbForm{}
|
||||
ginx.BindJsonAndValid(rc.GinCtx, form)
|
||||
|
||||
db := new(entity.Db)
|
||||
utils.Copy(db, form)
|
||||
db := ginx.BindJsonAndCopyTo[*entity.Db](rc.GinCtx, form, new(entity.Db))
|
||||
|
||||
// 密码解密,并使用解密后的赋值
|
||||
originPwd, err := utils.DefaultRsaDecrypt(form.Password, true)
|
||||
@@ -319,7 +316,6 @@ func (d *Db) DumpSql(rc *req.Ctx) {
|
||||
|
||||
writer.WriteString("COMMIT;\n")
|
||||
}
|
||||
rc.NoRes = true
|
||||
|
||||
rc.ReqParam = fmt.Sprintf("%s, tables: %s, dumpType: %s", dbInstance.Info.GetLogDesc(), tablesStr, dumpType)
|
||||
}
|
||||
|
||||
@@ -12,12 +12,7 @@ type DbSqlExec struct {
|
||||
}
|
||||
|
||||
func (d *DbSqlExec) DbSqlExecs(rc *req.Ctx) {
|
||||
g := rc.GinCtx
|
||||
m := &entity.DbSqlExec{DbId: uint64(ginx.QueryInt(g, "dbId", 0)),
|
||||
Db: g.Query("db"),
|
||||
Table: g.Query("table"),
|
||||
Type: int8(ginx.QueryInt(g, "type", 0)),
|
||||
}
|
||||
m.CreatorId = rc.LoginAccount.Id
|
||||
rc.ResData = d.DbSqlExecApp.GetPageList(m, ginx.GetPageParam(rc.GinCtx), new([]entity.DbSqlExec))
|
||||
queryCond, page := ginx.BindQueryAndPage(rc.GinCtx, new(entity.DbSqlExecQuery))
|
||||
queryCond.CreatorId = rc.LoginAccount.Id
|
||||
rc.ResData = d.DbSqlExecApp.GetPageList(queryCond, page, new([]entity.DbSqlExec))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user