|
@ -30,7 +30,7 @@ func CreateApi(a model.SysApi) (err error) { |
|
|
// @return error
|
|
|
// @return error
|
|
|
func DeleteApi(a model.SysApi) (err error) { |
|
|
func DeleteApi(a model.SysApi) (err error) { |
|
|
err = global.GVA_DB.Delete(a).Error |
|
|
err = global.GVA_DB.Delete(a).Error |
|
|
ClearCasbin(1, a.Path,a.Method) |
|
|
|
|
|
|
|
|
ClearCasbin(1, a.Path, a.Method) |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -45,10 +45,6 @@ func GetAPIInfoList(a model.SysApi, info request.PageInfo, Order string, Desc bo |
|
|
limit := info.PageSize |
|
|
limit := info.PageSize |
|
|
offset := info.PageSize * (info.Page - 1) |
|
|
offset := info.PageSize * (info.Page - 1) |
|
|
db := global.GVA_DB |
|
|
db := global.GVA_DB |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return |
|
|
|
|
|
} else { |
|
|
|
|
|
var apiList []model.SysApi |
|
|
var apiList []model.SysApi |
|
|
|
|
|
|
|
|
if a.Path != "" { |
|
|
if a.Path != "" { |
|
@ -82,7 +78,6 @@ func GetAPIInfoList(a model.SysApi, info request.PageInfo, Order string, Desc bo |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return err, apiList, total |
|
|
return err, apiList, total |
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// @title GetAllApis
|
|
|
// @title GetAllApis
|
|
@ -114,7 +109,7 @@ func UpdateApi(a model.SysApi) (err error) { |
|
|
|
|
|
|
|
|
err = global.GVA_DB.Where("id = ?", a.ID).First(&oldA).Error |
|
|
err = global.GVA_DB.Where("id = ?", a.ID).First(&oldA).Error |
|
|
|
|
|
|
|
|
if oldA.Path != a.Path || oldA.Method != a.Method{ |
|
|
|
|
|
|
|
|
if oldA.Path != a.Path || oldA.Method != a.Method { |
|
|
flag := global.GVA_DB.Where("path = ? AND method = ?", a.Path, a.Method).Find(&model.SysApi{}).RecordNotFound() |
|
|
flag := global.GVA_DB.Where("path = ? AND method = ?", a.Path, a.Method).Find(&model.SysApi{}).RecordNotFound() |
|
|
if !flag { |
|
|
if !flag { |
|
|
return errors.New("存在相同api路径") |
|
|
return errors.New("存在相同api路径") |
|
@ -123,7 +118,7 @@ func UpdateApi(a model.SysApi) (err error) { |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} else { |
|
|
} else { |
|
|
err = UpdateCasbinApi(oldA.Path, a.Path,oldA.Method,a.Method) |
|
|
|
|
|
|
|
|
err = UpdateCasbinApi(oldA.Path, a.Path, oldA.Method, a.Method) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return err |
|
|
return err |
|
|
} else { |
|
|
} else { |
|
|