新增获取接口列表
This commit is contained in:
@@ -161,27 +161,6 @@ func (r *ApiService) PutApi(c *gin.Context, requestApiId int64, putApiRequest re
|
||||
return false, errors.New("您当前为普通用户,无法修改接口")
|
||||
}
|
||||
|
||||
if putApiRequest.ApiPath != adminApi.APIPath && putApiRequest.ApiMethod != adminApi.APIMethod {
|
||||
// 检测接口名称+请求方式
|
||||
maps := make(map[string]interface{})
|
||||
maps["api_path"] = putApiRequest.ApiPath
|
||||
maps["api_method"] = putApiRequest.ApiMethod
|
||||
adminApis, err := adminApiDao.GetAdminApiList(maps)
|
||||
if len(adminApis) > 0 || err != nil {
|
||||
return false, errors.New("接口重复")
|
||||
}
|
||||
}
|
||||
|
||||
if putApiRequest.ApiPath != adminApi.APIPath {
|
||||
// 检测接口路径
|
||||
pattern := `^/[\w/]+(\:\w+)?$`
|
||||
r := regexp.MustCompile(pattern)
|
||||
|
||||
if !r.MatchString(putApiRequest.ApiPath) {
|
||||
return false, errors.New("接口路径错误")
|
||||
}
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
tx := global.Db.Begin()
|
||||
defer func() {
|
||||
@@ -193,8 +172,6 @@ func (r *ApiService) PutApi(c *gin.Context, requestApiId int64, putApiRequest re
|
||||
// 修改接口
|
||||
data := make(map[string]interface{})
|
||||
data["api_name"] = putApiRequest.ApiName
|
||||
data["api_path"] = putApiRequest.ApiPath
|
||||
data["api_method"] = putApiRequest.ApiMethod
|
||||
err = adminApiDao.EditAdminApiById(tx, requestApiId, data)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
|
||||
Reference in New Issue
Block a user