refactor(bookmark): 重构书签服务入口文件并整合用户权限功能

将 bookmark.go 重命名为 main.go,并调整包引用路径。将 bookmarks 和 user_np
两个模块的处理逻辑合并到同一个服务中,统一注册路由。同时更新了相关 API
的引用路径,确保生成代码与内部实现正确绑定。

此外,移除了独立的 user_np 服务入口文件,其功能已整合至 bookmark 服务中。

配置文件中调整了 user_np 和 vfs 服务的端口及部分接口定义,完善了用户
相关操作的路径参数和请求体结构。
This commit is contained in:
zzy
2025-09-25 09:50:35 +08:00
parent 1e81e603de
commit 24f238f377
23 changed files with 1173 additions and 601 deletions

View File

@ -3,8 +3,9 @@ package main
import (
"log"
bookmarks "git.zzyxyz.com/zzy/zzyxyz_go_api/gen/bookmarks"
"git.zzyxyz.com/zzy/zzyxyz_go_api/internal/handlers"
bookmarks_api "git.zzyxyz.com/zzy/zzyxyz_go_api/gen/bookmarks"
user_np_api "git.zzyxyz.com/zzy/zzyxyz_go_api/gen/user_np"
"git.zzyxyz.com/zzy/zzyxyz_go_api/internal/bookmarks"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
)
@ -25,12 +26,20 @@ func main() {
{
// create a type that satisfies the `api.ServerInterface`,
// which contains an implementation of every operation from the generated code
if server, err := handlers.NewBookMarks("./data/bookmark.sqlite3"); err != nil {
if server, err := bookmarks.NewBookMarks("./data/bookmark.sqlite3"); err != nil {
log.Fatal("Failed to create bookmarks server:", err)
} else if permission, err := handlers.NewBookMarkPermission(); err != nil || permission == nil {
} else if permission, err := bookmarks.NewBookMarkPermission(); err != nil || permission == nil {
log.Fatal("Failed to create bookmarks permission:", err)
} else {
bookmarks.RegisterHandlersWithOptions(api_router, server, *permission)
bookmarks_api.RegisterHandlersWithOptions(api_router, server, *permission)
}
// create a type that satisfies the `api.ServerInterface`,
// which contains an implementation of every operation from the generated code
if server, err := bookmarks.NewUserNP("./data/user_np.sqlite3"); err != nil {
log.Fatal("Failed to create user_np server:", err)
} else {
user_np_api.RegisterHandlers(api_router, server)
}
}

View File

@ -1,29 +0,0 @@
package main
import (
"log"
user_np "git.zzyxyz.com/zzy/zzyxyz_go_api/gen/user_np"
"git.zzyxyz.com/zzy/zzyxyz_go_api/internal/handlers"
"github.com/gin-gonic/gin"
)
func main() {
// gin.SetMode(gin.ReleaseMode)
router := gin.Default()
api_router := router.Group("/api")
{
// create a type that satisfies the `api.ServerInterface`,
// which contains an implementation of every operation from the generated code
if server, err := handlers.NewUserNP("./data/user_np.sqlite3"); err != nil {
log.Fatal("Failed to create user_np server:", err)
} else {
user_np.RegisterHandlers(api_router, server)
}
}
var listener = "localhost:8082"
log.Printf("Starting server at http://%s", listener)
log.Fatal(router.Run(listener))
}