-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
create_or_update_api_authority_handler.go
45 lines (39 loc) · 1.23 KB
/
create_or_update_api_authority_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package authority
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"github.com/suyuan32/simple-admin-core/api/internal/logic/authority"
"github.com/suyuan32/simple-admin-core/api/internal/svc"
"github.com/suyuan32/simple-admin-core/api/internal/types"
)
// swagger:route post /authority/api/create_or_update authority CreateOrUpdateApiAuthority
//
// Create or update API authorization information | 创建或更新API权限
//
// Create or update API authorization information | 创建或更新API权限
//
// Parameters:
// + name: body
// require: true
// in: body
// type: CreateOrUpdateApiAuthorityReq
//
// Responses:
// 200: BaseMsgResp
func CreateOrUpdateApiAuthorityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateOrUpdateApiAuthorityReq
if err := httpx.Parse(r, &req, true); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := authority.NewCreateOrUpdateApiAuthorityLogic(r.Context(), svcCtx)
resp, err := l.CreateOrUpdateApiAuthority(&req)
if err != nil {
err = svcCtx.Trans.TransError(r.Context(), err)
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}