mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-06 01:06:22 +00:00
⚡ implement OIDC configuration management with CRUD operations, add admin routes, and enhance error handling
This commit is contained in:
46
internal/service/post.go
Normal file
46
internal/service/post.go
Normal file
@ -0,0 +1,46 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/snowykami/neo-blog/internal/ctxutils"
|
||||
"github.com/snowykami/neo-blog/internal/dto"
|
||||
"github.com/snowykami/neo-blog/internal/model"
|
||||
"github.com/snowykami/neo-blog/internal/repo"
|
||||
"github.com/snowykami/neo-blog/pkg/errs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type PostService struct{}
|
||||
|
||||
func NewPostService() *PostService {
|
||||
return &PostService{}
|
||||
}
|
||||
|
||||
func (p *PostService) CreatePost(ctx context.Context, req *dto.CreateOrUpdatePostReq) error {
|
||||
currentUser := ctxutils.GetCurrentUser(ctx)
|
||||
if currentUser == nil {
|
||||
return errs.ErrUnauthorized
|
||||
}
|
||||
|
||||
post := &model.Post{
|
||||
Title: req.Title,
|
||||
Content: req.Content,
|
||||
UserID: currentUser.ID,
|
||||
Labels: req.Labels,
|
||||
IsPrivate: req.IsPrivate,
|
||||
}
|
||||
|
||||
if err := repo.Post.CreatePost(post); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *PostService) DeletePost(ctx context.Context, id string) error {
|
||||
}
|
||||
|
||||
func (p *PostService) GetPost(ctx context.Context, id string) (*model.Post, error) {}
|
||||
|
||||
func (p *PostService) UpdatePost(req *dto.CreateOrUpdatePostReq) error {}
|
||||
|
||||
func (p *PostService) ListPosts() {}
|
Reference in New Issue
Block a user