mirror of
				https://gitee.com/dromara/mayfly-go
				synced 2025-11-04 00:10:25 +08:00 
			
		
		
		
	refactor: 使用泛型重构参数绑定等
This commit is contained in:
		@@ -77,7 +77,7 @@ func (d *Db) ReqConfs() *req.Confs {
 | 
			
		||||
 | 
			
		||||
// @router /api/dbs [get]
 | 
			
		||||
func (d *Db) Dbs(rc *req.Ctx) {
 | 
			
		||||
	queryCond := req.BindQuery[*entity.DbQuery](rc, new(entity.DbQuery))
 | 
			
		||||
	queryCond := req.BindQuery[*entity.DbQuery](rc)
 | 
			
		||||
 | 
			
		||||
	// 不存在可访问标签id,即没有可操作数据
 | 
			
		||||
	tags := d.tagApp.GetAccountTags(rc.GetLoginAccount().Id, &tagentity.TagTreeQuery{
 | 
			
		||||
@@ -115,9 +115,7 @@ func (d *Db) Dbs(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *Db) Save(rc *req.Ctx) {
 | 
			
		||||
	form := &form.DbForm{}
 | 
			
		||||
	db := req.BindJsonAndCopyTo[*entity.Db](rc, form, new(entity.Db))
 | 
			
		||||
 | 
			
		||||
	form, db := req.BindJsonAndCopyTo[*form.DbForm, *entity.Db](rc)
 | 
			
		||||
	rc.ReqParam = form
 | 
			
		||||
 | 
			
		||||
	biz.ErrIsNil(d.dbApp.SaveDb(rc.MetaCtx, db))
 | 
			
		||||
@@ -137,7 +135,7 @@ func (d *Db) DeleteDb(rc *req.Ctx) {
 | 
			
		||||
/**  数据库操作相关、执行sql等   ***/
 | 
			
		||||
 | 
			
		||||
func (d *Db) ExecSql(rc *req.Ctx) {
 | 
			
		||||
	form := req.BindJsonAndValid(rc, new(form.DbSqlExecForm))
 | 
			
		||||
	form := req.BindJsonAndValid[*form.DbSqlExecForm](rc)
 | 
			
		||||
 | 
			
		||||
	ctx, cancel := context.WithTimeout(rc.MetaCtx, time.Duration(config.GetDbms().SqlExecTl)*time.Second)
 | 
			
		||||
	defer cancel()
 | 
			
		||||
@@ -351,8 +349,7 @@ func (d *Db) GetSchemas(rc *req.Ctx) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (d *Db) CopyTable(rc *req.Ctx) {
 | 
			
		||||
	form := &form.DbCopyTableForm{}
 | 
			
		||||
	copy := req.BindJsonAndCopyTo[*dbi.DbCopyTable](rc, form, new(dbi.DbCopyTable))
 | 
			
		||||
	form, copy := req.BindJsonAndCopyTo[*form.DbCopyTableForm, *dbi.DbCopyTable](rc)
 | 
			
		||||
 | 
			
		||||
	conn, err := d.dbApp.GetDbConn(rc.MetaCtx, form.Id, form.Db)
 | 
			
		||||
	biz.ErrIsNilAppendErr(err, "copy table error: %s")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user