Skip to content

Commit

Permalink
reflection + boilerplate for CRUDs
Browse files Browse the repository at this point in the history
  • Loading branch information
pieceowater committed Dec 24, 2024
1 parent d437046 commit ce88567
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import (
"app/internal/pkg"
gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)

func main() {
appCfg := cfg.Inst()
appRouter := pkg.NewRouter()

grpcServer := grpc.NewServer()
reflection.Register(grpcServer)

serverManager := gossiper.NewServerManager()
serverManager.AddServer(gossiper.NewGRPCServ(appCfg.GrpcPort, grpc.NewServer(), appRouter.InitGRPC))
serverManager.AddServer(gossiper.NewGRPCServ(appCfg.GrpcPort, grpcServer, appRouter.InitGRPC))

serverManager.StartAll()
defer serverManager.StopAll()
Expand Down
21 changes: 21 additions & 0 deletions internal/pkg/post/ctrl/post.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ctrl
import (
pb "app/internal/core/grpc/generated"
"app/internal/pkg/post/svc"
"context"
)

type PostController struct {
Expand All @@ -13,3 +14,23 @@ type PostController struct {
func NewPostController(service *svc.PostService) *PostController {
return &PostController{postService: service}
}

func (p PostController) GetPosts(ctx context.Context, request *pb.GetPostsRequest) (*pb.GetPostsResponse, error) {
//TODO implement me
panic("implement me")
}

func (p PostController) GetPost(ctx context.Context, request *pb.GetPostRequest) (*pb.Post, error) {
//TODO implement me
panic("implement me")
}

func (p PostController) CreatePost(ctx context.Context, request *pb.CreatePostRequest) (*pb.Post, error) {
//TODO implement me
panic("implement me")
}

func (p PostController) DeletePost(ctx context.Context, request *pb.DeletePostRequest) (*pb.Post, error) {
//TODO implement me
panic("implement me")
}
22 changes: 22 additions & 0 deletions internal/pkg/post/svc/post.svc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package svc

import (
"app/internal/pkg/post/ent"
"context"
gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
)

Expand All @@ -11,3 +13,23 @@ type PostService struct {
func NewPostService(db gossiper.Database) *PostService {
return &PostService{db: db}
}

func (s PostService) GetPosts(ctx context.Context, filter gossiper.Filter[string]) (gossiper.PaginatedResult[*ent.Post], error) {
//TODO implement me
panic("implement me")
}

func (s PostService) GetPost(ctx context.Context, id int) (ent.Post, error) {
//TODO implement me
panic("implement me")
}

func (s PostService) CreatePost(ctx context.Context, post *ent.Post) (ent.Post, error) {
//TODO implement me
panic("implement me")
}

func (s PostService) DeletePost(ctx context.Context, id int) (ent.Post, error) {
//TODO implement me
panic("implement me")
}
11 changes: 11 additions & 0 deletions internal/pkg/record/ctrl/record.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ctrl
import (
pb "app/internal/core/grpc/generated"
"app/internal/pkg/record/svc"
"context"
)

type RecordController struct {
Expand All @@ -13,3 +14,13 @@ type RecordController struct {
func NewRecordController(service *svc.RecordService) *RecordController {
return &RecordController{recordService: service}
}

func (r RecordController) GetRecords(ctx context.Context, request *pb.GetRecordsRequest) (*pb.GetRecordsResponse, error) {
//TODO implement me
panic("implement me")
}

func (r RecordController) CreateRecord(ctx context.Context, request *pb.CreateRecordRequest) (*pb.Record, error) {
//TODO implement me
panic("implement me")
}
16 changes: 15 additions & 1 deletion internal/pkg/record/svc/record.svc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package svc

import gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
import (
"app/internal/pkg/record/ent"
"context"
gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
)

type RecordService struct {
db gossiper.Database
Expand All @@ -9,3 +13,13 @@ type RecordService struct {
func NewRecordService(db gossiper.Database) *RecordService {
return &RecordService{db: db}
}

func (s RecordService) GetRecords(ctx context.Context, filter gossiper.Filter[string]) (gossiper.PaginatedResult[ent.Record], error) {
//TODO implement me
panic("implement me")
}

func (s RecordService) CreateRecord(ctx context.Context, request *ent.Record) (*ent.Record, error) {
//TODO implement me
panic("implement me")
}
21 changes: 21 additions & 0 deletions internal/pkg/route/ctrl/route.ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ctrl
import (
pb "app/internal/core/grpc/generated"
"app/internal/pkg/route/svc"
"context"
)

type RouteController struct {
Expand All @@ -13,3 +14,23 @@ type RouteController struct {
func NewRouteController(service *svc.RouteService) *RouteController {
return &RouteController{routeService: service}
}

func (r RouteController) GetRoutes(ctx context.Context, request *pb.GetRoutesRequest) (*pb.GetRoutesResponse, error) {
//TODO implement me
panic("implement me")
}

func (r RouteController) GetRoute(ctx context.Context, request *pb.GetRouteRequest) (*pb.Route, error) {
//TODO implement me
panic("implement me")
}

func (r RouteController) CreateRoute(ctx context.Context, request *pb.CreateRouteRequest) (*pb.Route, error) {
//TODO implement me
panic("implement me")
}

func (r RouteController) DeleteRoute(ctx context.Context, request *pb.DeleteRouteRequest) (*pb.Route, error) {
//TODO implement me
panic("implement me")
}
26 changes: 25 additions & 1 deletion internal/pkg/route/svc/route.svc.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package svc

import gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
import (
"app/internal/pkg/route/ent"
"context"
gossiper "github.com/pieceowater-dev/lotof.lib.gossiper/v2"
)

type RouteService struct {
db gossiper.Database
Expand All @@ -9,3 +13,23 @@ type RouteService struct {
func NewRouteService(db gossiper.Database) *RouteService {
return &RouteService{db: db}
}

func (s RouteService) GetRoutes(ctx context.Context, filter gossiper.Filter[string]) (gossiper.PaginatedResult[ent.Route], error) {
//TODO implement me
panic("implement me")
}

func (s RouteService) GetRoute(ctx context.Context, id int) (*ent.Route, error) {
//TODO implement me
panic("implement me")
}

func (s RouteService) CreateRoute(ctx context.Context, request *ent.Route) (*ent.Route, error) {
//TODO implement me
panic("implement me")
}

func (s RouteService) DeleteRoute(ctx context.Context, id int) (*ent.Route, error) {
//TODO implement me
panic("implement me")
}

0 comments on commit ce88567

Please sign in to comment.