update
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 52s
This commit is contained in:
75
api/Blog.api
75
api/Blog.api
@@ -64,6 +64,49 @@ type (
|
|||||||
DeletePostResp {}
|
DeletePostResp {}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
GetPostReq {
|
||||||
|
post_id string `json:"post_id"`
|
||||||
|
}
|
||||||
|
GetPostResp {
|
||||||
|
post_id string `json:"post_id"`
|
||||||
|
title string `json:"title"`
|
||||||
|
content string `json:"content"`
|
||||||
|
cover_image_url string `json:"cover_image_url"`
|
||||||
|
created_at int64 `json:"created_at"`
|
||||||
|
updated_at int64 `json:"updated_at"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
ListPostsReq {
|
||||||
|
page int `json:"page"`
|
||||||
|
page_size int `json:"page_size"`
|
||||||
|
}
|
||||||
|
ListPostsResp {
|
||||||
|
posts []ListPostsRespPosts `json:"posts"`
|
||||||
|
total_count int `json:"total_count"`
|
||||||
|
}
|
||||||
|
ListPostsRespPosts {
|
||||||
|
post_id string `json:"post_id"`
|
||||||
|
title string `json:"title"`
|
||||||
|
cover_image_url string `json:"cover_image_url"`
|
||||||
|
created_at int64 `json:"created_at"`
|
||||||
|
updated_at int64 `json:"updated_at"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
ListTagsReq {}
|
||||||
|
ListTagsResp {
|
||||||
|
tags []ListTagsRespTags `json:"tags"`
|
||||||
|
}
|
||||||
|
ListTagsRespTags {
|
||||||
|
tag_id string `json:"tag_id"`
|
||||||
|
tag_name string `json:"tag_name"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
prefix: /api/blog
|
prefix: /api/blog
|
||||||
)
|
)
|
||||||
@@ -76,6 +119,32 @@ service Blog {
|
|||||||
get /ping (PingReq) returns (PingResp)
|
get /ping (PingReq) returns (PingResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@server (
|
||||||
|
prefix: /api/blog/view
|
||||||
|
)
|
||||||
|
service Blog {
|
||||||
|
@doc (
|
||||||
|
summary: "Get a blog post by ID"
|
||||||
|
description: "Get a blog post by ID"
|
||||||
|
)
|
||||||
|
@handler GetPostHandler
|
||||||
|
post /post (GetPostReq) returns (GetPostResp)
|
||||||
|
|
||||||
|
@doc (
|
||||||
|
summary: "Get a list of blog posts"
|
||||||
|
description: "Get a list of blog posts with pagination"
|
||||||
|
)
|
||||||
|
@handler ListPostsHandler
|
||||||
|
post /posts (ListPostsReq) returns (ListPostsResp)
|
||||||
|
|
||||||
|
@doc (
|
||||||
|
summary: "Get a list of blog tags"
|
||||||
|
description: "Get a list of blog tags"
|
||||||
|
)
|
||||||
|
@handler ListTagsHandler
|
||||||
|
post /tags (ListTagsReq) returns (ListTagsResp)
|
||||||
|
}
|
||||||
|
|
||||||
@server (
|
@server (
|
||||||
middleware: SuperAdminAuthMiddleware
|
middleware: SuperAdminAuthMiddleware
|
||||||
prefix: /api/blog/post
|
prefix: /api/blog/post
|
||||||
@@ -105,7 +174,7 @@ service Blog {
|
|||||||
|
|
||||||
@server (
|
@server (
|
||||||
middleware: SuperAdminAuthMiddleware
|
middleware: SuperAdminAuthMiddleware
|
||||||
prefix: /api/blog
|
prefix: /api/blog/file
|
||||||
)
|
)
|
||||||
service Blog {
|
service Blog {
|
||||||
@doc (
|
@doc (
|
||||||
@@ -113,13 +182,13 @@ service Blog {
|
|||||||
description: "Get presigned URL for file upload"
|
description: "Get presigned URL for file upload"
|
||||||
)
|
)
|
||||||
@handler UploadPresignedURLHandler
|
@handler UploadPresignedURLHandler
|
||||||
post /file/upload (UploadPresignedURLReq) returns (UploadPresignedURLResp)
|
post /upload (UploadPresignedURLReq) returns (UploadPresignedURLResp)
|
||||||
|
|
||||||
@doc (
|
@doc (
|
||||||
summary: "Get presigned URL for file download"
|
summary: "Get presigned URL for file download"
|
||||||
description: "Get presigned URL for file download"
|
description: "Get presigned URL for file download"
|
||||||
)
|
)
|
||||||
@handler DownloadPresignedURLHandler
|
@handler DownloadPresignedURLHandler
|
||||||
post /file/download (DownloadPresignedURLReq) returns (DownloadPresignedURLResp)
|
post /download (DownloadPresignedURLReq) returns (DownloadPresignedURLResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
app/internal/handler/getposthandler.go
Normal file
29
app/internal/handler/getposthandler.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a blog post by ID
|
||||||
|
func GetPostHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.GetPostReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := logic.NewGetPostLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.GetPost(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/internal/handler/listpostshandler.go
Normal file
29
app/internal/handler/listpostshandler.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a list of blog posts
|
||||||
|
func ListPostsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ListPostsReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := logic.NewListPostsLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListPosts(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/internal/handler/listtagshandler.go
Normal file
29
app/internal/handler/listtagshandler.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/logic"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
"github.com/zeromicro/go-zero/rest/httpx"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Get a list of blog tags
|
||||||
|
func ListTagsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
var req types.ListTagsReq
|
||||||
|
if err := httpx.Parse(r, &req); err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
l := logic.NewListTagsLogic(r.Context(), svcCtx)
|
||||||
|
resp, err := l.ListTags(&req)
|
||||||
|
if err != nil {
|
||||||
|
httpx.ErrorCtx(r.Context(), w, err)
|
||||||
|
} else {
|
||||||
|
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,30 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
rest.WithPrefix("/api/blog"),
|
rest.WithPrefix("/api/blog"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
server.AddRoutes(
|
||||||
|
[]rest.Route{
|
||||||
|
{
|
||||||
|
// Get a blog post by ID
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/post",
|
||||||
|
Handler: GetPostHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Get a list of blog posts
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/posts",
|
||||||
|
Handler: ListPostsHandler(serverCtx),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Get a list of blog tags
|
||||||
|
Method: http.MethodPost,
|
||||||
|
Path: "/tags",
|
||||||
|
Handler: ListTagsHandler(serverCtx),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rest.WithPrefix("/api/blog/view"),
|
||||||
|
)
|
||||||
|
|
||||||
server.AddRoutes(
|
server.AddRoutes(
|
||||||
rest.WithMiddlewares(
|
rest.WithMiddlewares(
|
||||||
[]rest.Middleware{serverCtx.SuperAdminAuthMiddleware},
|
[]rest.Middleware{serverCtx.SuperAdminAuthMiddleware},
|
||||||
@@ -58,17 +82,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
{
|
{
|
||||||
// Get presigned URL for file download
|
// Get presigned URL for file download
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/file/download",
|
Path: "/download",
|
||||||
Handler: DownloadPresignedURLHandler(serverCtx),
|
Handler: DownloadPresignedURLHandler(serverCtx),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Get presigned URL for file upload
|
// Get presigned URL for file upload
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
Path: "/file/upload",
|
Path: "/upload",
|
||||||
Handler: UploadPresignedURLHandler(serverCtx),
|
Handler: UploadPresignedURLHandler(serverCtx),
|
||||||
},
|
},
|
||||||
}...,
|
}...,
|
||||||
),
|
),
|
||||||
rest.WithPrefix("/api/blog"),
|
rest.WithPrefix("/api/blog/file"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
31
app/internal/logic/getpostlogic.go
Normal file
31
app/internal/logic/getpostlogic.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPostLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a blog post by ID
|
||||||
|
func NewGetPostLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostLogic {
|
||||||
|
return &GetPostLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *GetPostLogic) GetPost(req *types.GetPostReq) (resp *types.GetPostResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
31
app/internal/logic/listpostslogic.go
Normal file
31
app/internal/logic/listpostslogic.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListPostsLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a list of blog posts
|
||||||
|
func NewListPostsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPostsLogic {
|
||||||
|
return &ListPostsLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListPostsLogic) ListPosts(req *types.ListPostsReq) (resp *types.ListPostsResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
31
app/internal/logic/listtagslogic.go
Normal file
31
app/internal/logic/listtagslogic.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package logic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/svc"
|
||||||
|
"git.cialloo.com/CiallooWeb/Blog/app/internal/types"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListTagsLogic struct {
|
||||||
|
logx.Logger
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get a list of blog tags
|
||||||
|
func NewListTagsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListTagsLogic {
|
||||||
|
return &ListTagsLogic{
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *ListTagsLogic) ListTags(req *types.ListTagsReq) (resp *types.ListTagsResp, err error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -39,6 +39,49 @@ type EditPostReq struct {
|
|||||||
type EditPostResp struct {
|
type EditPostResp struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GetPostReq struct {
|
||||||
|
Post_id string `json:"post_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetPostResp struct {
|
||||||
|
Post_id string `json:"post_id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Content string `json:"content"`
|
||||||
|
Cover_image_url string `json:"cover_image_url"`
|
||||||
|
Created_at int64 `json:"created_at"`
|
||||||
|
Updated_at int64 `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListPostsReq struct {
|
||||||
|
Page int `json:"page"`
|
||||||
|
Page_size int `json:"page_size"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListPostsResp struct {
|
||||||
|
Posts []ListPostsRespPosts `json:"posts"`
|
||||||
|
Total_count int `json:"total_count"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListPostsRespPosts struct {
|
||||||
|
Post_id string `json:"post_id"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Cover_image_url string `json:"cover_image_url"`
|
||||||
|
Created_at int64 `json:"created_at"`
|
||||||
|
Updated_at int64 `json:"updated_at"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTagsReq struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTagsResp struct {
|
||||||
|
Tags []ListTagsRespTags `json:"tags"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListTagsRespTags struct {
|
||||||
|
Tag_id string `json:"tag_id"`
|
||||||
|
Tag_name string `json:"tag_name"`
|
||||||
|
}
|
||||||
|
|
||||||
type PingReq struct {
|
type PingReq struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user