补充API Doc

This commit is contained in:
yumaojun03 2025-05-31 18:09:24 +08:00
parent 50d39008de
commit c315c4747c
4 changed files with 34 additions and 2 deletions

View File

@ -1,7 +1,7 @@
[app]
name = "devcloud"
description = "app desc"
address = "localhost"
address = "http://127.0.0.1:8080"
encrypt_key = "defualt app encrypt key"
[datasource]
@ -11,7 +11,7 @@
database = "devcloud_go18"
username = "root"
password = "123456"
auto_migrate = true
auto_migrate = false
debug = true
[http]

View File

@ -1,6 +1,8 @@
package api
import (
_ "embed"
"122.51.31.227/go-course/go18/devcloud/mcenter/apps/token"
"github.com/infraboard/mcube/v2/ioc"
"github.com/infraboard/mcube/v2/ioc/config/gorestful"
@ -23,6 +25,9 @@ func (h *TokenRestulApiHandler) Name() string {
return token.APP_NAME
}
//go:embed docs/login.md
var loginApiDocNotes string
func (h *TokenRestulApiHandler) Init() error {
h.svc = token.GetService()
@ -30,6 +35,7 @@ func (h *TokenRestulApiHandler) Init() error {
ws := gorestful.ObjectRouter(h)
ws.Route(ws.POST("").To(h.Login).
Doc("颁发令牌(登录)").
Notes(loginApiDocNotes).
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(token.IssueTokenRequest{}).
Writes(token.Token{}).

View File

@ -0,0 +1,8 @@
登录接口
```json
{
"username": "admin",
"password": "123456"
}
```

18
devcloud/mcenter/main.go Normal file
View File

@ -0,0 +1,18 @@
package main
import (
"github.com/infraboard/mcube/v2/ioc/server/cmd"
// 加载的业务对象
_ "122.51.31.227/go-course/go18/devcloud/mcenter/apps"
// 非功能性模块
_ "github.com/infraboard/mcube/v2/ioc/apps/apidoc/restful"
_ "github.com/infraboard/mcube/v2/ioc/apps/health/restful"
_ "github.com/infraboard/mcube/v2/ioc/apps/metric/restful"
)
func main() {
// 启动
cmd.Start()
}