├── .gitignore ├── Microservice Diagram-3.png ├── auth ├── Makefile ├── internal │ ├── initializer │ │ ├── load_env.go │ │ └── connecDatabase.go │ ├── model │ │ └── auth.go │ ├── utils │ │ ├── hash.go │ │ └── jwt.go │ ├── pb │ │ ├── auth.proto │ │ ├── auth_grpc.pb.go │ │ └── auth.pb.go │ ├── service │ │ └── user_service.go │ ├── repository │ │ └── user_repository.go │ └── handler │ │ └── user_handler.go ├── Dockerfile ├── go.mod ├── cmd │ └── main.go └── go.sum ├── product ├── Makefile ├── internal │ ├── initializer │ │ ├── load_env.go │ │ └── connect_database.go │ ├── model │ │ └── product.go │ ├── service │ │ └── product.go │ ├── pb │ │ ├── product.proto │ │ └── product_grpc.pb.go │ ├── handler │ │ └── product.go │ └── repository │ │ └── product.go ├── Dockerfile ├── cmd │ └── main.go ├── go.mod └── go.sum ├── order ├── Makefile ├── internal │ ├── model │ │ └── order.go │ ├── initializers │ │ ├── load_env.go │ │ └── connect_database.go │ ├── repository │ │ └── order.go │ ├── pb │ │ ├── order.proto │ │ ├── product.proto │ │ ├── order_grpc.pb.go │ │ ├── order.pb.go │ │ ├── product_grpc.pb.go │ │ └── product.pb.go │ ├── client │ │ └── product.go │ └── handler │ │ └── order.go ├── Dockerfile ├── go.mod ├── cmd │ └── main.go └── go.sum ├── api-gateaway ├── Makefile ├── internal │ ├── order │ │ ├── routes.go │ │ ├── client.go │ │ ├── pb │ │ │ ├── order.proto │ │ │ ├── order_grpc.pb.go │ │ │ └── order.pb.go │ │ └── handler.go │ ├── auth │ │ ├── client.go │ │ ├── routes.go │ │ ├── middleware.go │ │ ├── pb │ │ │ ├── auth.proto │ │ │ ├── auth_grpc.pb.go │ │ │ └── auth.pb.go │ │ └── handler.go │ └── product │ │ ├── client.go │ │ ├── routes.go │ │ ├── pb │ │ ├── product.proto │ │ └── product_grpc.pb.go │ │ └── handler.go ├── Dockerfile ├── cmd │ └── main.go ├── go.mod └── go.sum ├── readme.md ├── Makefile └── docker-compose.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /Microservice Diagram-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magistraapta/e-comm-microservices/HEAD/Microservice Diagram-3.png -------------------------------------------------------------------------------- /auth/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. ./internal/pb/auth.proto 3 | 4 | server: 5 | go run cmd/main.go -------------------------------------------------------------------------------- /product/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. ./internal/pb/*.proto 3 | 4 | server: 5 | go run cmd/main.go 6 | -------------------------------------------------------------------------------- /order/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. ./internal/pb/order.proto 3 | protoc --go_out=. --go-grpc_out=. ./internal/pb/product.proto 4 | 5 | 6 | server: 7 | go run cmd/main.go 8 | -------------------------------------------------------------------------------- /order/internal/model/order.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type Order struct { 4 | Id int64 `json:"id" gorm:"primaryKey"` 5 | ProductID int64 `json:"product_id"` 6 | Price int64 `json:"price"` 7 | UserID int64 `json:"user_id"` 8 | } 9 | -------------------------------------------------------------------------------- /api-gateaway/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. ./internal/auth/pb/auth.proto 3 | protoc --go_out=. --go-grpc_out=. ./internal/product/pb/product.proto 4 | protoc --go_out=. --go-grpc_out=. ./internal/order/pb/order.proto 5 | 6 | server: 7 | go run cmd/main.go -------------------------------------------------------------------------------- /order/internal/initializers/load_env.go: -------------------------------------------------------------------------------- 1 | package initializers 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/joho/godotenv" 7 | ) 8 | 9 | func LoadEnv() { 10 | err := godotenv.Load("./internal/config/.env") 11 | 12 | if err != nil { 13 | log.Fatal("failed to load .env file") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /auth/internal/initializer/load_env.go: -------------------------------------------------------------------------------- 1 | package initializer 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/joho/godotenv" 7 | ) 8 | 9 | func LoadEnv() { 10 | err := godotenv.Load("./internal/config/.env") 11 | if err != nil { 12 | log.Fatal("Error load .env file" + err.Error()) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /product/internal/initializer/load_env.go: -------------------------------------------------------------------------------- 1 | package initializer 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/joho/godotenv" 7 | ) 8 | 9 | func LoadEnv() { 10 | err := godotenv.Load("./internal/config/.env") 11 | 12 | if err != nil { 13 | log.Fatalln("failed to load .env file") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /api-gateaway/internal/order/routes.go: -------------------------------------------------------------------------------- 1 | package order 2 | 3 | import ( 4 | "api-gateaway/internal/auth" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func SetupOrderRoute(r *gin.Engine, orderHandler *OrderHandler, authSvc *auth.AuthMiddleware) { 10 | order := r.Group("/order") 11 | order.Use(authSvc.ValidateToken) 12 | order.POST("/", orderHandler.CreateOrder) 13 | } 14 | -------------------------------------------------------------------------------- /auth/internal/model/auth.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type User struct { 4 | Id int64 `json:"id" gorm:"primaryKey"` 5 | Username string `json:"username"` 6 | Email string `json:"email" gorm:"unique"` 7 | Password string `json:"password"` 8 | } 9 | 10 | type Admin struct { 11 | Id int64 `gorm:"primaryKey"` 12 | Username string 13 | Password string 14 | } 15 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/client.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "api-gateaway/internal/auth/pb" 5 | 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | type AuthClient struct { 10 | Client pb.AuthServiceClient 11 | } 12 | 13 | func NewAuthServiceClient(conn *grpc.ClientConn) *AuthClient { 14 | return &AuthClient{ 15 | Client: pb.NewAuthServiceClient(conn), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api-gateaway/internal/order/client.go: -------------------------------------------------------------------------------- 1 | package order 2 | 3 | import ( 4 | "api-gateaway/internal/order/pb" 5 | 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | type OrderClient struct { 10 | Client pb.OrderServiceClient 11 | } 12 | 13 | func NewOrderServiceClient(conn *grpc.ClientConn) *OrderClient { 14 | return &OrderClient{ 15 | Client: pb.NewOrderServiceClient(conn), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /api-gateaway/internal/product/client.go: -------------------------------------------------------------------------------- 1 | package product 2 | 3 | import ( 4 | "api-gateaway/internal/product/pb" 5 | 6 | "google.golang.org/grpc" 7 | ) 8 | 9 | type ProductClient struct { 10 | Client pb.ProductServiceClient 11 | } 12 | 13 | func NewProductClient(conn *grpc.ClientConn) *ProductClient { 14 | return &ProductClient{ 15 | Client: pb.NewProductServiceClient(conn), 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /order/internal/repository/order.go: -------------------------------------------------------------------------------- 1 | package repository 2 | 3 | import ( 4 | "context" 5 | "order/internal/model" 6 | 7 | "gorm.io/gorm" 8 | ) 9 | 10 | type OrderRepository struct { 11 | db *gorm.DB 12 | } 13 | 14 | func NewOrderRepository(db *gorm.DB) *OrderRepository { 15 | return &OrderRepository{db: db} 16 | } 17 | 18 | func (r *OrderRepository) CreateOrder(ctx context.Context, order *model.Order) 19 | -------------------------------------------------------------------------------- /product/internal/model/product.go: -------------------------------------------------------------------------------- 1 | package model 2 | 3 | type Product struct { 4 | Id int64 `json:"id" gorm:"primaryKey"` 5 | Name string `json:"name"` 6 | Price int64 `json:"price"` 7 | Stock int64 `json:"stock"` 8 | } 9 | 10 | type StockDecreaseLog struct { 11 | Id int64 `json:"id" gorm:"primaryKey"` 12 | OrderID int64 `json:"order_id"` 13 | ProductRefer int64 `json:"product_refer"` 14 | } 15 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/routes.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | func SetupAuthRoute(r *gin.Engine, authHandler *AuthHandler) { 6 | 7 | auth := r.Group("/auth") 8 | auth.POST("/register", authHandler.Register) 9 | auth.POST("/login", authHandler.Login) 10 | 11 | admin := r.Group("/admin") 12 | admin.POST("/register", authHandler.AdminRegister) 13 | admin.POST("/login", authHandler.AdminLogin) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /order/internal/pb/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package order; 4 | 5 | option go_package="./internal/pb"; 6 | 7 | service OrderService{ 8 | rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse); 9 | } 10 | 11 | message CreateOrderRequest{ 12 | int64 productId = 1; 13 | int64 quantity = 2; 14 | int64 userId = 3; 15 | } 16 | 17 | message CreateOrderResponse{ 18 | int64 status = 1; 19 | string error = 2; 20 | int64 id = 3; 21 | } -------------------------------------------------------------------------------- /api-gateaway/internal/order/pb/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package order; 4 | 5 | option go_package = "./internal/order/pb"; 6 | 7 | service OrderService { 8 | rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse); 9 | } 10 | 11 | message CreateOrderRequest { 12 | int64 productID = 1; 13 | int64 quantity = 2; 14 | int64 userID = 3; 15 | } 16 | 17 | message CreateOrderResponse { 18 | int64 status = 1; 19 | string error = 2; 20 | int64 id = 3; 21 | } -------------------------------------------------------------------------------- /auth/internal/initializer/connecDatabase.go: -------------------------------------------------------------------------------- 1 | package initializer 2 | 3 | import ( 4 | "auth/internal/model" 5 | "log" 6 | "os" 7 | 8 | "gorm.io/driver/postgres" 9 | "gorm.io/gorm" 10 | ) 11 | 12 | func ConnectDatabase() *gorm.DB { 13 | 14 | databaseConfig := os.Getenv("DATABASE_CONFIG") 15 | db, err := gorm.Open(postgres.Open(databaseConfig), &gorm.Config{}) 16 | 17 | if err != nil { 18 | log.Fatalln(err) 19 | } 20 | 21 | db.AutoMigrate(&model.User{}, &model.Admin{}) 22 | 23 | return db 24 | } 25 | -------------------------------------------------------------------------------- /api-gateaway/internal/product/routes.go: -------------------------------------------------------------------------------- 1 | package product 2 | 3 | import ( 4 | "api-gateaway/internal/auth" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func SetupProductRoute(r *gin.Engine, productHandler *ProductHandler, authSvc *auth.AuthMiddleware) { 10 | 11 | product := r.Group("/product") 12 | 13 | product.Use(authSvc.ValidateToken) 14 | product.GET("/:id", productHandler.FindOne) 15 | product.GET("/", productHandler.FindAll) 16 | 17 | product.POST("/", productHandler.CreateProduct) 18 | 19 | } 20 | -------------------------------------------------------------------------------- /product/internal/initializer/connect_database.go: -------------------------------------------------------------------------------- 1 | package initializer 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "product/internal/model" 7 | 8 | "gorm.io/driver/postgres" 9 | "gorm.io/gorm" 10 | ) 11 | 12 | func ConnectDatabase() *gorm.DB { 13 | 14 | databaseConfig := os.Getenv("DATABASE_CONFIG") 15 | db, err := gorm.Open(postgres.Open(databaseConfig), &gorm.Config{}) 16 | 17 | if err != nil { 18 | log.Fatalln(err) 19 | } 20 | 21 | db.AutoMigrate(&model.Product{}, &model.StockDecreaseLog{}) 22 | 23 | return db 24 | } 25 | -------------------------------------------------------------------------------- /order/internal/initializers/connect_database.go: -------------------------------------------------------------------------------- 1 | package initializers 2 | 3 | import ( 4 | "log" 5 | "order/internal/model" 6 | "os" 7 | 8 | "gorm.io/driver/postgres" 9 | "gorm.io/gorm" 10 | ) 11 | 12 | func ConnectDatabase() *gorm.DB { 13 | 14 | datbaaseConfig := os.Getenv("DATABASE_CONFIG") 15 | db, err := gorm.Open(postgres.Open(datbaaseConfig), &gorm.Config{}) 16 | 17 | if err != nil { 18 | log.Fatalf("failed to connect database: %v", err) 19 | } 20 | 21 | db.AutoMigrate(&model.Order{}) 22 | 23 | return db 24 | } 25 | -------------------------------------------------------------------------------- /auth/internal/utils/hash.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "log" 5 | 6 | "golang.org/x/crypto/bcrypt" 7 | ) 8 | 9 | func HashPassword(password string) (string, error) { 10 | hashedPasswrod, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) 11 | if err != nil { 12 | log.Fatalln(err) 13 | } 14 | return string(hashedPasswrod), nil 15 | } 16 | 17 | func CheckHashPassword(password string, hashedPassword string) bool { 18 | 19 | err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password)) 20 | 21 | return err == nil 22 | } 23 | -------------------------------------------------------------------------------- /auth/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.24 AS build 3 | 4 | WORKDIR /app 5 | 6 | # Copy module files and download dependencies 7 | COPY go.mod go.sum ./ 8 | RUN go mod download 9 | 10 | # Copy the entire project 11 | COPY . . 12 | 13 | # Set build environment and build binary 14 | ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 15 | RUN go build -o out/dist ./cmd 16 | 17 | # Final image 18 | FROM alpine:3.14 19 | 20 | WORKDIR /app 21 | 22 | # Copy the binary from the build stage 23 | COPY --from=build /app/out/dist /app/dist 24 | 25 | # Ensure it's executable 26 | RUN chmod +x /app/dist 27 | 28 | # Run the binary 29 | CMD ["/app/dist"] 30 | -------------------------------------------------------------------------------- /order/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.24 AS build 3 | 4 | WORKDIR /app 5 | 6 | # Copy module files and download dependencies 7 | COPY go.mod go.sum ./ 8 | RUN go mod download 9 | 10 | # Copy the entire project 11 | COPY . . 12 | 13 | # Set build environment and build binary 14 | ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 15 | RUN go build -o out/dist ./cmd 16 | 17 | # Final image 18 | FROM alpine:3.14 19 | 20 | WORKDIR /app 21 | 22 | # Copy the binary from the build stage 23 | COPY --from=build /app/out/dist /app/dist 24 | 25 | # Ensure it's executable 26 | RUN chmod +x /app/dist 27 | 28 | # Run the binary 29 | CMD ["/app/dist"] 30 | -------------------------------------------------------------------------------- /product/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.24 AS build 3 | 4 | WORKDIR /app 5 | 6 | # Copy module files and download dependencies 7 | COPY go.mod go.sum ./ 8 | RUN go mod download 9 | 10 | # Copy the entire project 11 | COPY . . 12 | 13 | # Set build environment and build binary 14 | ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 15 | RUN go build -o out/dist ./cmd 16 | 17 | # Final image 18 | FROM alpine:3.14 19 | 20 | WORKDIR /app 21 | 22 | # Copy the binary from the build stage 23 | COPY --from=build /app/out/dist /app/dist 24 | 25 | # Ensure it's executable 26 | RUN chmod +x /app/dist 27 | 28 | # Run the binary 29 | CMD ["/app/dist"] 30 | -------------------------------------------------------------------------------- /api-gateaway/Dockerfile: -------------------------------------------------------------------------------- 1 | # Build stage 2 | FROM golang:1.24 AS build 3 | 4 | WORKDIR /app 5 | 6 | # Copy module files and download dependencies 7 | COPY go.mod go.sum ./ 8 | RUN go mod download 9 | 10 | # Copy the entire project 11 | COPY . . 12 | 13 | # Set build environment and build binary 14 | ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 15 | RUN go build -o out/dist ./cmd 16 | 17 | # Final image 18 | FROM alpine:3.14 19 | 20 | WORKDIR /app 21 | 22 | # Copy the binary from the build stage 23 | COPY --from=build /app/out/dist /app/dist 24 | 25 | # Ensure it's executable 26 | RUN chmod +x /app/dist 27 | 28 | # Run the binary 29 | CMD ["/app/dist"] 30 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Microservices in Go 2 | - API Gateaway: Recieve request from the client in http 3 | - Auth Service: Manage user authentication and authorization 4 | - Product Service: Manage available products 5 | - Order Service: Handler order from users 6 | 7 | ## Diagram 8 | ![Image](https://github.com/user-attachments/assets/30501277-b552-4e09-9b6b-d30bfa200854) 9 | 10 | ## To-do List 11 | - [x] Create admin login and register 12 | - [x] Create order service 13 | - [x] setup Docker on every service 14 | 15 | ## Run Locally 16 | 17 | Clone the project 18 | 19 | ```bash 20 | git clone https://github.com/magistraapta/e-comm-microservices 21 | ``` 22 | 23 | Go to the project directory 24 | 25 | ```bash 26 | cd e-comm-microservices 27 | ``` 28 | 29 | Run services 30 | 31 | ```bash 32 | make run-all 33 | ``` 34 | 35 | Run on Docker 36 | 37 | ```bash 38 | make run 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /order/go.mod: -------------------------------------------------------------------------------- 1 | module order 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/jackc/pgpassfile v1.0.0 // indirect 7 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 8 | github.com/jackc/pgx/v5 v5.5.5 // indirect 9 | github.com/jackc/puddle/v2 v2.2.1 // indirect 10 | github.com/jinzhu/inflection v1.0.0 // indirect 11 | github.com/jinzhu/now v1.1.5 // indirect 12 | github.com/joho/godotenv v1.5.1 // indirect 13 | golang.org/x/crypto v0.32.0 // indirect 14 | golang.org/x/net v0.34.0 // indirect 15 | golang.org/x/sync v0.10.0 // indirect 16 | golang.org/x/sys v0.29.0 // indirect 17 | golang.org/x/text v0.21.0 // indirect 18 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect 19 | google.golang.org/grpc v1.71.1 // indirect 20 | google.golang.org/protobuf v1.36.4 // indirect 21 | gorm.io/driver/postgres v1.5.11 // indirect 22 | gorm.io/gorm v1.25.12 // indirect 23 | ) 24 | -------------------------------------------------------------------------------- /order/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | "order/internal/client" 8 | "order/internal/handler" 9 | "order/internal/initializers" 10 | "order/internal/pb" 11 | 12 | "google.golang.org/grpc" 13 | ) 14 | 15 | func init() { 16 | initializers.LoadEnv() 17 | initializers.ConnectDatabase() 18 | } 19 | 20 | func main() { 21 | db := initializers.ConnectDatabase() 22 | 23 | productClient := client.NewProductServiceClient("localhost:50052") 24 | handler := handler.NewOrderHandler(db, productClient) 25 | 26 | listener, err := net.Listen("tcp", ":50053") 27 | if err != nil { 28 | log.Fatalf("Failed to listen: %v", err) 29 | } 30 | 31 | grpcServer := grpc.NewServer() 32 | pb.RegisterOrderServiceServer(grpcServer, handler) 33 | 34 | fmt.Println("Order service is running on port :50053") 35 | 36 | if err := grpcServer.Serve(listener); err != nil { 37 | log.Fatalf("Failed to serve: %v", err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /auth/go.mod: -------------------------------------------------------------------------------- 1 | module auth 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/golang-jwt/jwt/v4 v4.5.2 // indirect 7 | github.com/jackc/pgpassfile v1.0.0 // indirect 8 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 9 | github.com/jackc/pgx/v5 v5.5.5 // indirect 10 | github.com/jackc/puddle/v2 v2.2.1 // indirect 11 | github.com/jinzhu/inflection v1.0.0 // indirect 12 | github.com/jinzhu/now v1.1.5 // indirect 13 | github.com/joho/godotenv v1.5.1 // indirect 14 | golang.org/x/crypto v0.32.0 // indirect 15 | golang.org/x/net v0.34.0 // indirect 16 | golang.org/x/sync v0.10.0 // indirect 17 | golang.org/x/sys v0.29.0 // indirect 18 | golang.org/x/text v0.21.0 // indirect 19 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect 20 | google.golang.org/grpc v1.71.1 // indirect 21 | google.golang.org/protobuf v1.36.6 // indirect 22 | gorm.io/driver/postgres v1.5.11 // indirect 23 | gorm.io/gorm v1.25.12 // indirect 24 | ) 25 | -------------------------------------------------------------------------------- /auth/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "auth/internal/handler" 5 | "auth/internal/initializer" 6 | "auth/internal/pb" 7 | "auth/internal/repository" 8 | "auth/internal/service" 9 | "log" 10 | "net" 11 | 12 | "google.golang.org/grpc" 13 | ) 14 | 15 | func init() { 16 | initializer.LoadEnv() 17 | initializer.ConnectDatabase() 18 | } 19 | 20 | func main() { 21 | listener, err := net.Listen("tcp", ":50051") 22 | 23 | if err != nil { 24 | log.Fatalf("failed to listen: %v", err) 25 | } 26 | 27 | grpcServer := grpc.NewServer() 28 | 29 | db := initializer.ConnectDatabase() 30 | userRepo := repository.NewUserRepository(db) 31 | userService := service.NewUserService(userRepo) 32 | userHandler := handler.NewUserHanlder(userService) 33 | 34 | pb.RegisterAuthServiceServer(grpcServer, userHandler) 35 | 36 | log.Println("AuthService is running on port 50051...") 37 | if err := grpcServer.Serve(listener); err != nil { 38 | log.Fatalf("failed to serve: %v", err) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /product/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net" 7 | "product/internal/handler" 8 | "product/internal/initializer" 9 | "product/internal/pb" 10 | "product/internal/repository" 11 | "product/internal/service" 12 | 13 | "google.golang.org/grpc" 14 | ) 15 | 16 | func init() { 17 | initializer.LoadEnv() 18 | initializer.ConnectDatabase() 19 | } 20 | func main() { 21 | listener, err := net.Listen("tcp", ":50052") 22 | 23 | if err != nil { 24 | log.Fatalf("Failed to listen: %v", err) 25 | } 26 | 27 | grpcServer := grpc.NewServer() 28 | 29 | db := initializer.ConnectDatabase() 30 | repo := repository.NewProductRepository(db) 31 | service := service.NewProductService(repo) 32 | handler := handler.NewProductHandler(service) 33 | 34 | pb.RegisterProductServiceServer(grpcServer, handler) 35 | 36 | fmt.Print("Product service is running on port :50052...") 37 | 38 | if err := grpcServer.Serve(listener); err != nil { 39 | log.Fatal("failed to serve: &v", err) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /order/internal/client/product.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | "log" 6 | "order/internal/pb" 7 | 8 | "google.golang.org/grpc" 9 | ) 10 | 11 | type ProductServiceClient struct { 12 | Client pb.ProductServiceClient 13 | } 14 | 15 | func NewProductServiceClient(url string) *ProductServiceClient { 16 | conn, err := grpc.Dial(url, grpc.WithInsecure()) 17 | if err != nil { 18 | log.Fatalf("failed to connect to product service: %v", err) 19 | } 20 | 21 | return &ProductServiceClient{ 22 | Client: pb.NewProductServiceClient(conn), 23 | } 24 | } 25 | 26 | func (c *ProductServiceClient) FindOne(productID int64) (*pb.FindOneResponse, error) { 27 | req := &pb.FindOneRequest{ 28 | Id: productID, 29 | } 30 | return c.Client.FindOne(context.Background(), req) 31 | } 32 | 33 | func (c *ProductServiceClient) DecreaseStock(productID int64, orderID int64, quantity int64) (*pb.DecreaseStockResponse, error) { 34 | req := &pb.DecreaseStockRequest{ 35 | Id: productID, 36 | OrderId: orderID, 37 | Quantity: quantity, 38 | } 39 | return c.Client.DecreaseStock(context.Background(), req) 40 | } 41 | -------------------------------------------------------------------------------- /order/internal/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./internal/pb"; 6 | 7 | service ProductService{ 8 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 9 | rpc FindOne(FindOneRequest) returns (FindOneResponse); 10 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse); 11 | } 12 | 13 | message CreateProductRequest{ 14 | string name = 1; 15 | int64 stock = 2; 16 | int64 price = 3; 17 | } 18 | message CreateProductResponse{ 19 | int64 status = 1; 20 | string error = 2; 21 | int64 id = 3; 22 | } 23 | message FindOneData { 24 | int64 id = 1; 25 | string name = 2; 26 | int64 stock = 3; 27 | int64 price = 4; 28 | } 29 | 30 | 31 | message FindOneRequest{ 32 | int64 id = 1; 33 | } 34 | message FindOneResponse{ 35 | int64 status = 1; 36 | string error = 2; 37 | FindOneData data = 3; 38 | } 39 | 40 | message DecreaseStockRequest{ 41 | int64 id = 1; 42 | int64 orderId = 2; 43 | int64 quantity = 3; // <- Add this 44 | } 45 | message DecreaseStockResponse{ 46 | int64 status = 1; 47 | string error = 2; 48 | } 49 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | run-all: 2 | cd api-gateaway && make server & 3 | cd auth && make server & 4 | cd product && make server & 5 | cd order && make server & 6 | 7 | run-services: 8 | cd auth && make server & 9 | cd product && make server & 10 | cd order && make server & 11 | 12 | kill-ports: 13 | @for port in 50051 50052 50053; do \ 14 | pid=$$(lsof -t -i :$$port); \ 15 | if [ -n "$$pid" ]; then \ 16 | echo "Killing process on port $$port (PID: $$pid)"; \ 17 | kill -9 $$pid; \ 18 | else \ 19 | echo "No process found on port $$port"; \ 20 | fi \ 21 | done 22 | 23 | docker-build: 24 | cd api-gateaway && docker build -t magistra/ecom-api-gateaway . 25 | cd auth && docker build -t magistra/ecom-auth-service . 26 | cd product && docker build -t magistra/ecom-product-service . 27 | cd order && docker build -t magistra/ecom-order-service . 28 | 29 | docker-push: 30 | cd api-gateaway && docker push magistra/ecom-api-gateaway 31 | cd auth && docker push magistra/ecom-auth-service 32 | cd product && docker push magistra/ecom-product-service 33 | cd order && docker push magistra/ecom-order-service 34 | 35 | run: 36 | sudo docker compose up -------------------------------------------------------------------------------- /api-gateaway/internal/auth/middleware.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "api-gateaway/internal/auth/pb" 5 | "context" 6 | "net/http" 7 | "strings" 8 | 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | type AuthMiddleware struct { 13 | client *AuthClient 14 | } 15 | 16 | func NewAuthMiddleware(client *AuthClient) AuthMiddleware { 17 | return AuthMiddleware{client: client} 18 | } 19 | 20 | func (s *AuthMiddleware) ValidateToken(ctx *gin.Context) { 21 | authorization, err := ctx.Cookie("Authorization") 22 | if err != nil || authorization == "" { 23 | ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Missing Authorization cookie"}) 24 | return 25 | } 26 | 27 | // No need to split or trim Bearer 28 | token := strings.TrimSpace(authorization) 29 | 30 | if token == "" { 31 | ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Token is empty"}) 32 | return 33 | } 34 | 35 | res, err := s.client.Client.Validate(context.Background(), &pb.ValidateRequest{ 36 | Token: token, 37 | }) 38 | 39 | if err != nil || res.Status != http.StatusOK { 40 | ctx.AbortWithError(http.StatusUnauthorized, err) 41 | return 42 | } 43 | 44 | ctx.Set("userId", res.UserID) 45 | ctx.Next() 46 | } 47 | -------------------------------------------------------------------------------- /api-gateaway/internal/order/handler.go: -------------------------------------------------------------------------------- 1 | package order 2 | 3 | import ( 4 | "api-gateaway/internal/order/pb" 5 | "net/http" 6 | 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | type OrderHandler struct { 11 | Client *OrderClient 12 | } 13 | 14 | func NewOrderHandler(client *OrderClient) *OrderHandler { 15 | return &OrderHandler{Client: client} 16 | } 17 | 18 | func (h *OrderHandler) CreateOrder(ctx *gin.Context) { 19 | var req struct { 20 | ProductID int64 `json:"product_id"` 21 | Quantity int64 `json:"quantity"` 22 | } 23 | 24 | if err := ctx.BindJSON(&req); err != nil { 25 | ctx.AbortWithError(http.StatusBadRequest, err) 26 | return 27 | } 28 | 29 | val, exists := ctx.Get("userId") 30 | if !exists { 31 | ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"}) 32 | return 33 | } 34 | 35 | userId, ok := val.(int64) 36 | if !ok { 37 | ctx.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "invalid user id format"}) 38 | return 39 | } 40 | 41 | res, err := h.Client.Client.CreateOrder(ctx, &pb.CreateOrderRequest{ 42 | ProductID: req.ProductID, 43 | Quantity: req.Quantity, 44 | UserID: userId, 45 | }) 46 | 47 | if err != nil { 48 | ctx.AbortWithError(http.StatusBadGateway, err) 49 | return 50 | } 51 | 52 | ctx.JSON(http.StatusCreated, &res) 53 | } 54 | -------------------------------------------------------------------------------- /auth/internal/pb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package auth; 4 | 5 | option go_package = "./internal/pb"; 6 | 7 | service AuthService { 8 | rpc Register(RegisterRequest) returns (RegisterResponse); 9 | rpc AdminRegister(AdminRegisterRequest) returns (RegisterResponse); 10 | rpc Login(LoginRequest) returns (LoginResponse); 11 | rpc AdminLogin(AdminLoginRequest) returns (LoginResponse); 12 | rpc Validate(ValidateRequest) returns (ValidateResponse); 13 | } 14 | 15 | message RegisterRequest { 16 | string username = 1; 17 | string email = 2; 18 | string password = 3; 19 | } 20 | 21 | message RegisterResponse { 22 | int64 id = 1; 23 | int64 status = 2; 24 | string error = 3; 25 | } 26 | 27 | message AdminRegisterRequest { 28 | string username = 1; 29 | string password = 2; 30 | } 31 | 32 | message AdminRegisterResponse { 33 | string username = 1; 34 | string password = 2; 35 | } 36 | 37 | message LoginRequest { 38 | string email = 1; 39 | string password = 2; 40 | } 41 | 42 | message AdminLoginRequest { 43 | string username = 1; 44 | string password = 2; 45 | } 46 | 47 | message LoginResponse { 48 | string token = 1; 49 | int64 status = 2; 50 | string error = 3; 51 | } 52 | 53 | message ValidateRequest { 54 | string token = 1; 55 | } 56 | 57 | message ValidateResponse { 58 | int64 status = 1; 59 | string error = 2; 60 | int64 userID = 3; 61 | } 62 | -------------------------------------------------------------------------------- /auth/internal/service/user_service.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "auth/internal/model" 5 | "auth/internal/repository" 6 | "auth/internal/utils" 7 | "context" 8 | "errors" 9 | ) 10 | 11 | type UserService struct { 12 | repo *repository.UserRepository 13 | } 14 | 15 | func NewUserService(repo *repository.UserRepository) *UserService { 16 | return &UserService{repo: repo} 17 | } 18 | 19 | func (s *UserService) Register(ctx context.Context, user *model.User) (*model.User, error) { 20 | return s.repo.Register(ctx, user) 21 | } 22 | 23 | func (s *UserService) Login(ctx context.Context, email string, password string) (*model.User, error) { 24 | existingUser, err := s.repo.UserLogin(ctx, email) 25 | if err != nil { 26 | return nil, errors.New("invalid email or password") 27 | } 28 | 29 | if !utils.CheckHashPassword(password, existingUser.Password) { 30 | return nil, errors.New("invalid email or password") 31 | } 32 | 33 | return existingUser, nil 34 | } 35 | 36 | func (s *UserService) AdminLogin(ctx context.Context, username string) (*model.Admin, error) { 37 | existingAdmin, err := s.repo.AdminLogin(ctx, username) 38 | if err != nil { 39 | return nil, errors.New("invalid email or password") 40 | } 41 | 42 | return existingAdmin, nil 43 | } 44 | 45 | func (s *UserService) AdminRegister(ctx context.Context, admin *model.Admin) (*model.Admin, error) { 46 | return s.repo.RegisterAdmin(ctx, admin) 47 | } 48 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/pb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package auth; 4 | 5 | option go_package = "./internal/auth/pb"; 6 | 7 | service AuthService { 8 | rpc Register(RegisterRequest) returns (RegisterResponse); 9 | rpc AdminRegister(AdminRegisterRequest) returns (RegisterResponse); 10 | rpc Login(LoginRequest) returns (LoginResponse); 11 | rpc AdminLogin(AdminLoginRequest) returns (LoginResponse); 12 | rpc Validate(ValidateRequest) returns (ValidateResponse); 13 | } 14 | 15 | message RegisterRequest { 16 | string username = 1; 17 | string email = 2; 18 | string password = 3; 19 | } 20 | 21 | message RegisterResponse { 22 | int64 id = 1; 23 | int64 status = 2; 24 | string error = 3; 25 | } 26 | 27 | message AdminRegisterRequest { 28 | string username = 1; 29 | string password = 2; 30 | } 31 | 32 | message AdminRegisterResponse { 33 | string username = 1; 34 | string password = 2; 35 | } 36 | 37 | message LoginRequest { 38 | string email = 1; 39 | string password = 2; 40 | } 41 | 42 | message AdminLoginRequest { 43 | string username = 1; 44 | string password = 2; 45 | } 46 | 47 | message LoginResponse { 48 | string token = 1; 49 | int64 status = 2; 50 | string error = 3; 51 | } 52 | 53 | message ValidateRequest { 54 | string token = 1; 55 | } 56 | 57 | message ValidateResponse { 58 | int64 status = 1; 59 | string error = 2; 60 | int64 userID = 3; 61 | } 62 | -------------------------------------------------------------------------------- /api-gateaway/internal/product/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./internal/product/pb"; 6 | 7 | service ProductService { 8 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 9 | rpc FindOne(FindOneRequest) returns (FindOneResponse); 10 | rpc FindAll(FindAllRequest) returns (FindAllResponse); 11 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse); 12 | } 13 | 14 | message CreateProductRequest { 15 | string name = 1; 16 | int64 price = 2; 17 | int64 stock = 3; 18 | } 19 | 20 | message CreateProductResponse { 21 | int64 status = 1; 22 | string error = 2; 23 | int64 id = 3; 24 | } 25 | 26 | message FindOneData { 27 | int64 id = 1; 28 | string name = 2; 29 | int64 price = 3; 30 | int64 stock = 4; 31 | } 32 | 33 | message FindOneRequest { 34 | int64 id = 1; 35 | } 36 | 37 | message FindOneResponse { 38 | int64 status = 1; 39 | string error = 2; 40 | FindOneData data = 3; 41 | } 42 | 43 | message FindAllRequest {} 44 | 45 | message FindAllResponse { 46 | int64 status = 1; 47 | string error = 2; 48 | repeated FindOneData products = 3; 49 | } 50 | 51 | message DecreaseStockRequest { 52 | int64 id = 1; 53 | int64 orderID = 2; 54 | } 55 | 56 | message DecreaseStockResponse { 57 | int64 status = 1; 58 | string error = 2; 59 | } 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /product/internal/service/product.go: -------------------------------------------------------------------------------- 1 | package service 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "product/internal/model" 7 | "product/internal/repository" 8 | ) 9 | 10 | type ProductService struct { 11 | repo *repository.ProductRepository 12 | } 13 | 14 | func NewProductService(repo *repository.ProductRepository) *ProductService { 15 | return &ProductService{repo: repo} 16 | } 17 | 18 | func (s *ProductService) CreateProduct(ctx context.Context, product *model.Product) (*model.Product, error) { 19 | if product.Name == "" || product.Price <= 0 || product.Stock <= 0 { 20 | return nil, errors.New("invalid product data") 21 | } 22 | 23 | return s.repo.CreateProduct(ctx, product) 24 | } 25 | 26 | func (s *ProductService) FindOne(ctx context.Context, product *model.Product) (*model.Product, error) { 27 | return s.repo.FindOne(ctx, product) 28 | } 29 | 30 | func (s *ProductService) FindAll(ctx context.Context) ([]model.Product, error) { 31 | return s.repo.FindAll(ctx) 32 | } 33 | 34 | func (s *ProductService) DecreaseStock(ctx context.Context, productID int64, orderID int64, quantity int64) (*model.Product, error) { 35 | 36 | product, err := s.FindOne(ctx, &model.Product{Id: productID}) 37 | 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | if product.Stock <= 0 { 43 | return nil, errors.New("product is out of stock") 44 | } 45 | 46 | return s.repo.DecreaseStock(ctx, productID, orderID, quantity) 47 | } 48 | -------------------------------------------------------------------------------- /product/internal/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./internal/pb"; 6 | 7 | service ProductService { 8 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 9 | rpc FindOne(FindOneRequest) returns (FindOneResponse); 10 | rpc FindAll(FindAllRequest) returns (FindAllResponse); 11 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse); 12 | } 13 | 14 | message CreateProductRequest { 15 | string name = 1; 16 | int64 price = 2; 17 | int64 stock = 3; 18 | } 19 | 20 | message CreateProductResponse { 21 | int64 status = 1; 22 | string error = 2; 23 | int64 id = 3; 24 | } 25 | 26 | message FindOneData { 27 | int64 id = 1; 28 | string name = 2; 29 | int64 price = 3; 30 | int64 stock = 4; 31 | } 32 | 33 | message FindOneRequest { 34 | int64 id = 1; 35 | } 36 | 37 | message FindOneResponse { 38 | int64 status = 1; 39 | string error = 2; 40 | FindOneData data = 3; 41 | } 42 | 43 | message FindAllRequest {} 44 | 45 | message FindAllResponse { 46 | int64 status = 1; 47 | string error = 2; 48 | repeated FindOneData products = 3; 49 | } 50 | 51 | message DecreaseStockRequest { 52 | int64 id = 1; 53 | int64 orderID = 2; 54 | int64 quantity = 3; // <- Add this 55 | } 56 | 57 | message DecreaseStockResponse { 58 | int64 status = 1; 59 | string error = 2; 60 | } 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /api-gateaway/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "api-gateaway/internal/auth" 5 | "api-gateaway/internal/order" 6 | "api-gateaway/internal/product" 7 | "log" 8 | 9 | "github.com/gin-gonic/gin" 10 | "google.golang.org/grpc" 11 | ) 12 | 13 | func main() { 14 | authConn, err := grpc.Dial(":50051", grpc.WithInsecure()) 15 | if err != nil { 16 | log.Fatalf("Failed to connect to auth service: %v", err) 17 | } 18 | defer authConn.Close() 19 | 20 | productConn, err := grpc.Dial(":50052", grpc.WithInsecure()) 21 | if err != nil { 22 | log.Fatalf("Failed to connect to product service: %v", err) 23 | } 24 | defer productConn.Close() 25 | 26 | orderConn, err := grpc.Dial(":50053", grpc.WithInsecure()) 27 | if err != nil { 28 | log.Fatalf("Failed to connect to product service: %v", err) 29 | } 30 | defer orderConn.Close() 31 | 32 | authClient := auth.NewAuthServiceClient(authConn) 33 | authHandler := auth.NewAuthHandler(authClient) 34 | 35 | productClient := product.NewProductClient(productConn) 36 | productHandler := product.NewProductHandler(productClient) 37 | 38 | orderClient := order.NewOrderServiceClient(orderConn) 39 | orderHandler := order.NewOrderHandler(orderClient) 40 | 41 | r := gin.Default() 42 | 43 | middleware := auth.NewAuthMiddleware(authClient) 44 | 45 | auth.SetupAuthRoute(r, authHandler) 46 | product.SetupProductRoute(r, productHandler, &middleware) 47 | order.SetupOrderRoute(r, orderHandler, &middleware) 48 | 49 | r.Run(":8000") 50 | } 51 | -------------------------------------------------------------------------------- /api-gateaway/go.mod: -------------------------------------------------------------------------------- 1 | module api-gateaway 2 | 3 | go 1.24.0 4 | 5 | require ( 6 | github.com/bytedance/sonic v1.11.6 // indirect 7 | github.com/bytedance/sonic/loader v0.1.1 // indirect 8 | github.com/cloudwego/base64x v0.1.4 // indirect 9 | github.com/cloudwego/iasm v0.2.0 // indirect 10 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 11 | github.com/gin-contrib/sse v0.1.0 // indirect 12 | github.com/gin-gonic/gin v1.10.0 // indirect 13 | github.com/go-playground/locales v0.14.1 // indirect 14 | github.com/go-playground/universal-translator v0.18.1 // indirect 15 | github.com/go-playground/validator/v10 v10.20.0 // indirect 16 | github.com/goccy/go-json v0.10.2 // indirect 17 | github.com/json-iterator/go v1.1.12 // indirect 18 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect 19 | github.com/leodido/go-urn v1.4.0 // indirect 20 | github.com/mattn/go-isatty v0.0.20 // indirect 21 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 22 | github.com/modern-go/reflect2 v1.0.2 // indirect 23 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 24 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 25 | github.com/ugorji/go/codec v1.2.12 // indirect 26 | golang.org/x/arch v0.8.0 // indirect 27 | golang.org/x/crypto v0.32.0 // indirect 28 | golang.org/x/net v0.34.0 // indirect 29 | golang.org/x/sys v0.29.0 // indirect 30 | golang.org/x/text v0.21.0 // indirect 31 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect 32 | google.golang.org/grpc v1.71.1 // indirect 33 | google.golang.org/protobuf v1.36.4 // indirect 34 | gopkg.in/yaml.v3 v3.0.1 // indirect 35 | ) 36 | -------------------------------------------------------------------------------- /product/go.mod: -------------------------------------------------------------------------------- 1 | module product 2 | 3 | go 1.24 4 | 5 | require ( 6 | github.com/bytedance/sonic v1.11.6 // indirect 7 | github.com/bytedance/sonic/loader v0.1.1 // indirect 8 | github.com/cloudwego/base64x v0.1.4 // indirect 9 | github.com/cloudwego/iasm v0.2.0 // indirect 10 | github.com/gabriel-vasile/mimetype v1.4.3 // indirect 11 | github.com/gin-contrib/sse v0.1.0 // indirect 12 | github.com/gin-gonic/gin v1.10.0 // indirect 13 | github.com/go-playground/locales v0.14.1 // indirect 14 | github.com/go-playground/universal-translator v0.18.1 // indirect 15 | github.com/go-playground/validator/v10 v10.20.0 // indirect 16 | github.com/goccy/go-json v0.10.2 // indirect 17 | github.com/jackc/pgpassfile v1.0.0 // indirect 18 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 19 | github.com/jackc/pgx/v5 v5.5.5 // indirect 20 | github.com/jackc/puddle/v2 v2.2.1 // indirect 21 | github.com/jinzhu/inflection v1.0.0 // indirect 22 | github.com/jinzhu/now v1.1.5 // indirect 23 | github.com/joho/godotenv v1.5.1 // indirect 24 | github.com/json-iterator/go v1.1.12 // indirect 25 | github.com/klauspost/cpuid/v2 v2.2.7 // indirect 26 | github.com/leodido/go-urn v1.4.0 // indirect 27 | github.com/mattn/go-isatty v0.0.20 // indirect 28 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 29 | github.com/modern-go/reflect2 v1.0.2 // indirect 30 | github.com/pelletier/go-toml/v2 v2.2.2 // indirect 31 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 32 | github.com/ugorji/go/codec v1.2.12 // indirect 33 | golang.org/x/arch v0.8.0 // indirect 34 | golang.org/x/crypto v0.32.0 // indirect 35 | golang.org/x/net v0.34.0 // indirect 36 | golang.org/x/sync v0.10.0 // indirect 37 | golang.org/x/sys v0.29.0 // indirect 38 | golang.org/x/text v0.21.0 // indirect 39 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect 40 | google.golang.org/grpc v1.71.1 // indirect 41 | google.golang.org/protobuf v1.36.4 // indirect 42 | gopkg.in/yaml.v3 v3.0.1 // indirect 43 | gorm.io/driver/postgres v1.5.11 // indirect 44 | gorm.io/gorm v1.25.12 // indirect 45 | ) 46 | -------------------------------------------------------------------------------- /order/internal/handler/order.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "order/internal/client" 7 | "order/internal/model" 8 | "order/internal/pb" 9 | 10 | "gorm.io/gorm" 11 | ) 12 | 13 | type OrderHandler struct { 14 | db *gorm.DB 15 | pb.UnimplementedOrderServiceServer 16 | ProductClient *client.ProductServiceClient 17 | } 18 | 19 | func NewOrderHandler(db *gorm.DB, productClient *client.ProductServiceClient) *OrderHandler { 20 | return &OrderHandler{ 21 | db: db, 22 | ProductClient: productClient, 23 | } 24 | } 25 | 26 | func (h *OrderHandler) CreateOrder(ctx context.Context, req *pb.CreateOrderRequest) (*pb.CreateOrderResponse, error) { 27 | product, err := h.ProductClient.FindOne(req.ProductId) 28 | 29 | if err != nil { 30 | return &pb.CreateOrderResponse{ 31 | Status: http.StatusBadGateway, 32 | Error: err.Error(), 33 | }, nil 34 | } 35 | 36 | if product.Status >= http.StatusNotFound { 37 | return &pb.CreateOrderResponse{ 38 | Status: product.Status, 39 | Error: product.Error, 40 | }, nil 41 | } 42 | 43 | if product.Data.Stock <= 0 { 44 | return &pb.CreateOrderResponse{ 45 | Status: http.StatusBadRequest, 46 | Error: "stock is too low", 47 | }, nil 48 | } 49 | 50 | order := model.Order{ 51 | Price: product.Data.Price, 52 | ProductID: product.Data.Id, 53 | UserID: req.UserId, 54 | } 55 | 56 | if err := h.db.Create(&order).Error; err != nil { 57 | return &pb.CreateOrderResponse{ 58 | Status: http.StatusInternalServerError, 59 | Error: err.Error(), 60 | }, nil 61 | } 62 | 63 | res, err := h.ProductClient.DecreaseStock(order.ProductID, order.Id, req.Quantity) 64 | 65 | if err != nil { 66 | return &pb.CreateOrderResponse{ 67 | Status: http.StatusBadRequest, 68 | Error: err.Error(), 69 | }, nil 70 | } 71 | 72 | if res.Status == http.StatusConflict { 73 | h.db.Delete(&model.Order{}, order.Id) 74 | return &pb.CreateOrderResponse{ 75 | Status: http.StatusConflict, 76 | Error: res.Error, 77 | }, nil 78 | } 79 | 80 | return &pb.CreateOrderResponse{ 81 | Status: http.StatusCreated, 82 | Id: order.Id, 83 | }, nil 84 | } 85 | -------------------------------------------------------------------------------- /api-gateaway/internal/product/handler.go: -------------------------------------------------------------------------------- 1 | package product 2 | 3 | import ( 4 | "api-gateaway/internal/product/pb" 5 | "context" 6 | "net/http" 7 | "strconv" 8 | 9 | "github.com/gin-gonic/gin" 10 | ) 11 | 12 | type ProductHandler struct { 13 | Client *ProductClient 14 | } 15 | 16 | func NewProductHandler(client *ProductClient) *ProductHandler { 17 | return &ProductHandler{Client: client} 18 | } 19 | 20 | func (h *ProductHandler) CreateProduct(ctx *gin.Context) { 21 | var req struct { 22 | Name string `json:"name"` 23 | Price int64 `json:"price"` 24 | Stock int64 `json:"stock"` 25 | } 26 | 27 | if err := ctx.ShouldBindBodyWithJSON(&req); err != nil { 28 | ctx.AbortWithError(http.StatusBadRequest, err) 29 | return 30 | } 31 | 32 | res, err := h.Client.Client.CreateProduct(context.Background(), &pb.CreateProductRequest{ 33 | Name: req.Name, 34 | Price: req.Price, 35 | Stock: req.Stock, 36 | }) 37 | 38 | if err != nil { 39 | ctx.AbortWithError(http.StatusBadGateway, err) 40 | return 41 | } 42 | 43 | if res == nil { 44 | ctx.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": "nil response from product service"}) 45 | return 46 | } 47 | 48 | ctx.JSON(http.StatusOK, &pb.CreateProductResponse{ 49 | Id: res.Id, 50 | Status: http.StatusOK, 51 | }) 52 | } 53 | 54 | func (h *ProductHandler) FindOne(ctx *gin.Context) { 55 | 56 | id, err := strconv.ParseInt(ctx.Param("id"), 10, 32) 57 | 58 | if err != nil { 59 | ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "failed to get id"}) 60 | return 61 | } 62 | 63 | res, err := h.Client.Client.FindOne(ctx, &pb.FindOneRequest{ 64 | Id: int64(id), 65 | }) 66 | 67 | if err != nil { 68 | ctx.AbortWithStatusJSON(http.StatusBadGateway, gin.H{"error": "failed to get product"}) 69 | return 70 | } 71 | 72 | ctx.JSON(http.StatusOK, &pb.FindOneResponse{ 73 | Data: res.Data, 74 | }) 75 | } 76 | 77 | func (h *ProductHandler) FindAll(ctx *gin.Context) { 78 | products, err := h.Client.Client.FindAll(ctx, &pb.FindAllRequest{}) 79 | 80 | if err != nil { 81 | ctx.AbortWithError(http.StatusBadGateway, err) 82 | return 83 | } 84 | 85 | ctx.JSON(http.StatusOK, products) 86 | } 87 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | 3 | services: 4 | api-gateaway: 5 | image: magistra/ecom-api-gateaway 6 | environment: 7 | - PORT=8000 8 | - AUTH_SERVICE=auth-service:50051 9 | - PRODUCT_SERVICE=product-service:50053 10 | - ORDER_SERVICE=order-service:50052 11 | ports: 12 | - "8000:8000" 13 | depends_on: 14 | - auth-service 15 | - product-service 16 | - order-service 17 | restart: always 18 | 19 | auth-service: 20 | image: magistra/ecom-auth-service 21 | ports: 22 | - "50051:50051" 23 | environment: 24 | - PORT=50051 25 | - DATABASE_CONFIG=postgres://postgres:postgres@auth-db:5432/auth-service 26 | - SECRET_KEY=33hejjnubueebf3933iwubufeb 27 | depends_on: 28 | - auth-db 29 | restart: always 30 | 31 | product-service: 32 | image: magistra/ecom-product-service 33 | ports: 34 | - "50053:50053" 35 | environment: 36 | - PORT=50053 37 | - DATABASE_CONFIG=postgres://postgres:postgres@product-db:5432/product-service 38 | depends_on: 39 | - product-db 40 | restart: always 41 | 42 | order-service: 43 | image: magistra/ecom-order-service 44 | ports: 45 | - "50052:50052" 46 | environment: 47 | - PORT=50052 48 | - DATABASE_CONFIG=postgres://postgres:postgres@order-db:5432/order-service 49 | depends_on: 50 | - order-db 51 | restart: always 52 | 53 | auth-db: 54 | image: postgres:latest 55 | ports: 56 | - "5433:5432" 57 | environment: 58 | - POSTGRES_DB=auth-service 59 | - POSTGRES_USER=postgres 60 | - POSTGRES_PASSWORD=postgres 61 | restart: always 62 | 63 | product-db: 64 | image: postgres:latest 65 | ports: 66 | - "5434:5432" 67 | environment: 68 | - POSTGRES_DB=product-service 69 | - POSTGRES_USER=postgres 70 | - POSTGRES_PASSWORD=postgres 71 | restart: always 72 | 73 | order-db: 74 | image: postgres:latest 75 | ports: 76 | - "5435:5432" 77 | environment: 78 | - POSTGRES_DB=order-service 79 | - POSTGRES_USER=postgres 80 | - POSTGRES_PASSWORD=postgres 81 | restart: always 82 | -------------------------------------------------------------------------------- /auth/internal/utils/jwt.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "auth/internal/model" 5 | "errors" 6 | "fmt" 7 | "os" 8 | "time" 9 | 10 | "github.com/golang-jwt/jwt/v4" 11 | ) 12 | 13 | type JwtClaims struct { 14 | Id int64 15 | Username string 16 | Email string 17 | Password string 18 | jwt.StandardClaims 19 | } 20 | 21 | func GenerateToken(user *model.User) (string, error) { 22 | expirationTime := time.Now().Add(24 * time.Hour) 23 | 24 | claims := JwtClaims{ 25 | StandardClaims: jwt.StandardClaims{ 26 | Issuer: "self-pickup", 27 | ExpiresAt: expirationTime.Unix(), 28 | }, 29 | Id: user.Id, 30 | Username: user.Username, 31 | Email: user.Email, 32 | Password: user.Password, 33 | } 34 | 35 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) 36 | 37 | secret := os.Getenv("SECRET_KEY") 38 | if secret == "" { 39 | return "", fmt.Errorf("SECRET_KEY environment variable not set") 40 | } 41 | 42 | tokenString, err := token.SignedString([]byte(secret)) 43 | if err != nil { 44 | return "", err 45 | } 46 | 47 | return tokenString, nil 48 | } 49 | 50 | func GenerateAdminToken(admin *model.Admin) (string, error) { 51 | expirationTime := time.Now().Add(24 * time.Hour) 52 | 53 | claims := JwtClaims{ 54 | StandardClaims: jwt.StandardClaims{ 55 | Issuer: "self-pickup", 56 | ExpiresAt: expirationTime.Unix(), 57 | }, 58 | Id: admin.Id, 59 | Username: admin.Username, 60 | Password: admin.Password, 61 | } 62 | 63 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) 64 | 65 | secret := os.Getenv("SECRET_KEY") 66 | if secret == "" { 67 | return "", fmt.Errorf("SECRET_KEY environment variable not set") 68 | } 69 | 70 | tokenString, err := token.SignedString([]byte(secret)) 71 | if err != nil { 72 | return "", err 73 | } 74 | 75 | return tokenString, nil 76 | } 77 | 78 | func ValidateToken(signedToken string) (*JwtClaims, error) { 79 | secret := os.Getenv("SECRET_KEY") 80 | 81 | token, err := jwt.ParseWithClaims(signedToken, &JwtClaims{}, func(token *jwt.Token) (interface{}, error) { 82 | return []byte(secret), nil 83 | }) 84 | 85 | if err != nil { 86 | return nil, err 87 | } 88 | 89 | claims, ok := token.Claims.(*JwtClaims) 90 | 91 | if !ok { 92 | return nil, errors.New("couldn't parse claims") 93 | } 94 | 95 | if claims.ExpiresAt < time.Now().Local().Unix() { 96 | return nil, errors.New("JWT is expired") 97 | } 98 | 99 | return claims, err 100 | } 101 | -------------------------------------------------------------------------------- /auth/internal/repository/user_repository.go: -------------------------------------------------------------------------------- 1 | package repository 2 | 3 | import ( 4 | "auth/internal/model" 5 | "auth/internal/utils" 6 | "context" 7 | "errors" 8 | 9 | "gorm.io/gorm" 10 | ) 11 | 12 | type UserRepository struct { 13 | DB *gorm.DB 14 | } 15 | 16 | func NewUserRepository(db *gorm.DB) *UserRepository { 17 | return &UserRepository{DB: db} 18 | } 19 | 20 | func (r *UserRepository) Register(ctx context.Context, user *model.User) (*model.User, error) { 21 | 22 | // check email 23 | var existingUser model.User 24 | 25 | result := r.DB.WithContext(ctx).Where("email = ?", user.Email).First(&existingUser) 26 | 27 | if result.Error == nil { 28 | return nil, errors.New("User already exist") 29 | } 30 | 31 | if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { 32 | return nil, result.Error 33 | } 34 | 35 | hashedPassword, err := utils.HashPassword(user.Password) 36 | 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | newUser := model.User{ 42 | Username: user.Username, 43 | Email: user.Email, 44 | Password: hashedPassword, 45 | } 46 | 47 | result = r.DB.WithContext(ctx).Create(&newUser) 48 | 49 | if result.Error != nil { 50 | return nil, result.Error 51 | } 52 | 53 | return &newUser, nil 54 | } 55 | 56 | func (r *UserRepository) UserLogin(ctx context.Context, email string) (*model.User, error) { 57 | var user model.User 58 | err := r.DB.WithContext(ctx).Where("email = ?", email).First(&user).Error 59 | 60 | if err != nil { 61 | if errors.Is(err, gorm.ErrRecordNotFound) { 62 | return nil, errors.New("user not found") 63 | } 64 | return nil, err 65 | } 66 | 67 | return &user, nil 68 | } 69 | 70 | func (r *UserRepository) AdminLogin(ctx context.Context, username string) (*model.Admin, error) { 71 | var admin model.Admin 72 | err := r.DB.WithContext(ctx).Where("username = ?", username).First(&admin).Error 73 | 74 | if err != nil { 75 | if errors.Is(err, gorm.ErrRecordNotFound) { 76 | return nil, errors.New("user not found") 77 | } 78 | return nil, err 79 | } 80 | 81 | return &admin, nil 82 | } 83 | 84 | func (r *UserRepository) RegisterAdmin(ctx context.Context, admin *model.Admin) (*model.Admin, error) { 85 | hashedPassword, err := utils.HashPassword(admin.Password) 86 | 87 | if err != nil { 88 | return nil, err 89 | } 90 | 91 | newAdmin := model.Admin{ 92 | Username: admin.Username, 93 | Password: hashedPassword, 94 | } 95 | 96 | result := r.DB.WithContext(ctx).Create(&newAdmin) 97 | 98 | if result.Error != nil { 99 | return nil, result.Error 100 | } 101 | 102 | return &newAdmin, nil 103 | } 104 | -------------------------------------------------------------------------------- /product/internal/handler/product.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "product/internal/model" 7 | "product/internal/pb" 8 | "product/internal/service" 9 | ) 10 | 11 | type ProductHandler struct { 12 | pb.UnimplementedProductServiceServer 13 | service *service.ProductService 14 | } 15 | 16 | func NewProductHandler(service *service.ProductService) *ProductHandler { 17 | return &ProductHandler{service: service} 18 | } 19 | 20 | func (h *ProductHandler) CreateProduct(ctx context.Context, req *pb.CreateProductRequest) (*pb.CreateProductResponse, error) { 21 | var product model.Product 22 | 23 | product.Name = req.Name 24 | product.Price = req.Price 25 | product.Stock = req.Stock 26 | 27 | res, err := h.service.CreateProduct(ctx, &product) 28 | 29 | if err != nil { 30 | return &pb.CreateProductResponse{ 31 | Status: http.StatusBadRequest, 32 | Error: err.Error(), 33 | }, nil 34 | } 35 | 36 | return &pb.CreateProductResponse{ 37 | Status: http.StatusOK, 38 | Id: res.Id, 39 | }, nil 40 | 41 | } 42 | 43 | func (h *ProductHandler) FindOne(ctx context.Context, req *pb.FindOneRequest) (*pb.FindOneResponse, error) { 44 | var product model.Product 45 | 46 | product.Id = req.Id 47 | res, err := h.service.FindOne(ctx, &product) 48 | 49 | if err != nil { 50 | return &pb.FindOneResponse{ 51 | Status: http.StatusBadRequest, 52 | Error: "failed to get product", 53 | }, nil 54 | } 55 | 56 | data := &pb.FindOneData{ 57 | Id: res.Id, 58 | Name: res.Name, 59 | Price: res.Price, 60 | Stock: res.Stock, 61 | } 62 | 63 | return &pb.FindOneResponse{ 64 | Data: data, 65 | }, nil 66 | } 67 | 68 | func (h *ProductHandler) FindAll(ctx context.Context, req *pb.FindAllRequest) (*pb.FindAllResponse, error) { 69 | 70 | products, err := h.service.FindAll(ctx) 71 | 72 | if err != nil { 73 | return &pb.FindAllResponse{ 74 | Status: http.StatusBadGateway, 75 | Error: err.Error(), 76 | }, nil 77 | } 78 | 79 | var pbProducts []*pb.FindOneData 80 | 81 | for _, p := range products { 82 | pbProducts = append(pbProducts, &pb.FindOneData{ 83 | Id: p.Id, 84 | Name: p.Name, 85 | Price: p.Price, 86 | Stock: p.Stock, 87 | }) 88 | } 89 | 90 | return &pb.FindAllResponse{ 91 | Products: pbProducts, 92 | }, nil 93 | } 94 | 95 | func (h *ProductHandler) DecreaseStock(ctx context.Context, req *pb.DecreaseStockRequest) (*pb.DecreaseStockResponse, error) { 96 | _, err := h.service.DecreaseStock(ctx, req.Id, req.OrderID, req.Quantity) 97 | 98 | if err != nil { 99 | return &pb.DecreaseStockResponse{ 100 | Status: http.StatusBadGateway, 101 | Error: err.Error(), 102 | }, nil 103 | } 104 | 105 | return &pb.DecreaseStockResponse{ 106 | Status: http.StatusOK, 107 | }, nil 108 | } 109 | -------------------------------------------------------------------------------- /product/internal/repository/product.go: -------------------------------------------------------------------------------- 1 | package repository 2 | 3 | import ( 4 | "context" 5 | "errors" 6 | "product/internal/model" 7 | 8 | "gorm.io/gorm" 9 | ) 10 | 11 | type ProductRepository struct { 12 | db *gorm.DB 13 | } 14 | 15 | func NewProductRepository(db *gorm.DB) *ProductRepository { 16 | return &ProductRepository{db: db} 17 | } 18 | 19 | func (r *ProductRepository) CreateProduct(ctx context.Context, product *model.Product) (*model.Product, error) { 20 | 21 | newProduct := model.Product{ 22 | Name: product.Name, 23 | Price: product.Price, 24 | Stock: product.Stock, 25 | } 26 | 27 | err := r.db.WithContext(ctx).Create(&newProduct).Error 28 | 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &newProduct, nil 34 | } 35 | 36 | func (r *ProductRepository) FindOne(ctx context.Context, product *model.Product) (*model.Product, error) { 37 | var existingProduct model.Product 38 | err := r.db.WithContext(ctx).First(&existingProduct, product.Id).Error 39 | 40 | if err != nil { 41 | if errors.Is(err, gorm.ErrRecordNotFound) { 42 | return nil, errors.New("product not found") 43 | } 44 | 45 | return nil, err 46 | } 47 | 48 | return &existingProduct, nil 49 | } 50 | 51 | func (r *ProductRepository) FindAll(ctx context.Context) ([]model.Product, error) { 52 | var products []model.Product 53 | 54 | // Use context-aware DB operation 55 | if err := r.db.WithContext(ctx).Find(&products).Error; err != nil { 56 | return nil, err 57 | } 58 | 59 | return products, nil 60 | } 61 | 62 | func (r *ProductRepository) DecreaseStock(ctx context.Context, productID int64, orderID int64, quantity int64) (*model.Product, error) { 63 | var product model.Product 64 | 65 | // 1. Find product by ID 66 | if err := r.db.WithContext(ctx).First(&product, productID).Error; err != nil { 67 | return nil, err 68 | } 69 | 70 | // 2. Check if stock decrease log already exists 71 | var existingLog model.StockDecreaseLog 72 | err := r.db.WithContext(ctx).Where("order_id = ?", orderID).First(&existingLog).Error 73 | if err == nil { 74 | // Log already exists, don't decrease stock again 75 | return nil, errors.New("stock has already been decreased for this order") 76 | } 77 | if !errors.Is(err, gorm.ErrRecordNotFound) { 78 | // Actual DB error 79 | return nil, err 80 | } 81 | 82 | // 3. Make sure stock is not zero or negative 83 | if product.Stock <= 0 { 84 | return nil, errors.New("not enough stock") 85 | } 86 | 87 | // 4. Decrease stock 88 | product.Stock -= quantity 89 | if err := r.db.WithContext(ctx).Save(&product).Error; err != nil { 90 | return nil, err 91 | } 92 | 93 | // 5. Create stock decrease log 94 | log := model.StockDecreaseLog{ 95 | OrderID: orderID, 96 | ProductRefer: productID, 97 | } 98 | if err := r.db.WithContext(ctx).Create(&log).Error; err != nil { 99 | return nil, err 100 | } 101 | 102 | return &product, nil 103 | } 104 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/handler.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "api-gateaway/internal/auth/pb" 5 | "context" 6 | "net/http" 7 | 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | type AuthHandler struct { 12 | Client *AuthClient 13 | } 14 | 15 | func NewAuthHandler(client *AuthClient) *AuthHandler { 16 | return &AuthHandler{Client: client} 17 | } 18 | 19 | func (h *AuthHandler) Register(ctx *gin.Context) { 20 | var req struct { 21 | Username string `json:"username"` 22 | Email string `json:"email"` 23 | Password string `json:"password"` 24 | } 25 | 26 | if err := ctx.ShouldBindJSON(&req); err != nil { 27 | ctx.AbortWithError(http.StatusBadRequest, err) 28 | return 29 | } 30 | 31 | res, err := h.Client.Client.Register(context.Background(), &pb.RegisterRequest{ 32 | Username: req.Username, 33 | Email: req.Email, 34 | Password: req.Password, 35 | }) 36 | 37 | if err != nil { 38 | ctx.AbortWithError(http.StatusBadGateway, err) 39 | } 40 | 41 | ctx.JSON(int(res.Status), res) 42 | } 43 | 44 | func (h *AuthHandler) Login(ctx *gin.Context) { 45 | var req struct { 46 | Email string `json:"email"` 47 | Password string `json:"password"` 48 | } 49 | 50 | if err := ctx.ShouldBindJSON(&req); err != nil { 51 | ctx.AbortWithError(http.StatusBadRequest, err) 52 | return 53 | } 54 | 55 | res, err := h.Client.Client.Login(context.Background(), &pb.LoginRequest{ 56 | Email: req.Email, 57 | Password: req.Password, 58 | }) 59 | 60 | if err != nil { 61 | ctx.AbortWithError(http.StatusBadGateway, err) 62 | return 63 | } 64 | 65 | ctx.SetCookie("Authorization", res.Token, 3600*24*30, "", "", false, true) 66 | 67 | ctx.JSON(http.StatusOK, &res) 68 | } 69 | 70 | func (h *AuthHandler) AdminRegister(ctx *gin.Context) { 71 | var req struct { 72 | Username string `json:"username"` 73 | Password string `json:"password"` 74 | } 75 | 76 | if err := ctx.BindJSON(&req); err != nil { 77 | ctx.AbortWithError(http.StatusBadRequest, err) 78 | return 79 | } 80 | 81 | res, err := h.Client.Client.AdminRegister(ctx, &pb.AdminRegisterRequest{ 82 | Username: req.Username, 83 | Password: req.Password, 84 | }) 85 | 86 | if err != nil { 87 | ctx.AbortWithError(http.StatusBadRequest, err) 88 | return 89 | } 90 | 91 | ctx.JSON(int(res.Status), res) 92 | } 93 | 94 | func (h *AuthHandler) AdminLogin(ctx *gin.Context) { 95 | var req struct { 96 | Username string `json:"username"` 97 | Password string `json:"password"` 98 | } 99 | 100 | if err := ctx.BindJSON(&req); err != nil { 101 | ctx.AbortWithError(http.StatusBadRequest, err) 102 | return 103 | } 104 | 105 | res, err := h.Client.Client.AdminLogin(ctx, &pb.AdminLoginRequest{ 106 | Username: req.Username, 107 | Password: req.Password, 108 | }) 109 | 110 | if err != nil { 111 | ctx.AbortWithError(http.StatusBadGateway, err) 112 | return 113 | } 114 | 115 | ctx.JSON(int(res.Status), res) 116 | 117 | } 118 | -------------------------------------------------------------------------------- /auth/internal/handler/user_handler.go: -------------------------------------------------------------------------------- 1 | package handler 2 | 3 | import ( 4 | "auth/internal/model" 5 | "auth/internal/pb" 6 | "auth/internal/service" 7 | "auth/internal/utils" 8 | "context" 9 | "net/http" 10 | ) 11 | 12 | type AuthHandler struct { 13 | pb.UnimplementedAuthServiceServer 14 | service *service.UserService 15 | } 16 | 17 | func NewUserHanlder(service *service.UserService) *AuthHandler { 18 | return &AuthHandler{service: service} 19 | } 20 | 21 | func (h *AuthHandler) Register(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error) { 22 | var user model.User 23 | 24 | user.Username = req.Username 25 | user.Email = req.Email 26 | user.Password = req.Password 27 | 28 | res, err := h.service.Register(ctx, &user) 29 | 30 | if err != nil { 31 | return &pb.RegisterResponse{ 32 | Error: err.Error(), 33 | }, nil 34 | } 35 | 36 | return &pb.RegisterResponse{ 37 | Status: http.StatusCreated, 38 | Id: res.Id, 39 | }, nil 40 | } 41 | 42 | func (h *AuthHandler) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { 43 | 44 | res, err := h.service.Login(ctx, req.Email, req.Password) 45 | 46 | if err != nil { 47 | return &pb.LoginResponse{ 48 | Status: http.StatusNotFound, 49 | Error: "user not found", 50 | }, nil 51 | } 52 | 53 | matchPassword := utils.CheckHashPassword(req.Password, res.Password) 54 | 55 | if !matchPassword { 56 | return &pb.LoginResponse{ 57 | Status: http.StatusBadGateway, 58 | Error: "Invalid email or password", 59 | }, nil 60 | } 61 | 62 | token, _ := utils.GenerateToken(res) 63 | 64 | return &pb.LoginResponse{ 65 | Status: http.StatusOK, 66 | Token: token, 67 | }, nil 68 | } 69 | 70 | func (h *AuthHandler) AdminRegister(ctx context.Context, req *pb.AdminRegisterRequest) (*pb.RegisterResponse, error) { 71 | admin := &model.Admin{ 72 | Username: req.Username, 73 | Password: req.Password, 74 | } 75 | 76 | res, err := h.service.AdminRegister(ctx, admin) 77 | 78 | if err != nil { 79 | return &pb.RegisterResponse{ 80 | Error: err.Error(), 81 | }, nil 82 | } 83 | 84 | return &pb.RegisterResponse{ 85 | Status: http.StatusCreated, 86 | Id: res.Id, 87 | }, nil 88 | } 89 | 90 | func (h *AuthHandler) AdminLogin(ctx context.Context, req *pb.AdminLoginRequest) (*pb.LoginResponse, error) { 91 | res, err := h.service.AdminLogin(ctx, req.Username) 92 | 93 | if err != nil { 94 | return &pb.LoginResponse{ 95 | Status: http.StatusBadRequest, 96 | Error: err.Error(), 97 | }, nil 98 | } 99 | 100 | isPasswordMatch := utils.CheckHashPassword(req.Password, res.Password) 101 | 102 | if !isPasswordMatch { 103 | return &pb.LoginResponse{ 104 | Status: http.StatusBadGateway, 105 | Error: "Invalid email or password", 106 | }, nil 107 | } 108 | 109 | token, err := utils.GenerateAdminToken(res) 110 | 111 | if err != nil { 112 | return &pb.LoginResponse{ 113 | Status: http.StatusBadGateway, 114 | Error: err.Error(), 115 | }, nil 116 | } 117 | 118 | return &pb.LoginResponse{ 119 | Status: http.StatusOK, 120 | Token: token, 121 | }, nil 122 | } 123 | 124 | func (h *AuthHandler) Validate(ctx context.Context, req *pb.ValidateRequest) (*pb.ValidateResponse, error) { 125 | claims, err := utils.ValidateToken(req.Token) 126 | 127 | if err != nil { 128 | return &pb.ValidateResponse{ 129 | Status: http.StatusBadRequest, 130 | Error: err.Error(), 131 | }, nil 132 | } 133 | 134 | return &pb.ValidateResponse{ 135 | Status: http.StatusOK, 136 | UserID: claims.Id, 137 | }, nil 138 | } 139 | -------------------------------------------------------------------------------- /auth/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= 3 | github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= 4 | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 5 | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= 6 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= 7 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= 8 | github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= 9 | github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= 10 | github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= 11 | github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= 12 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 13 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 14 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 15 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 16 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 17 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 18 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 19 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 20 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 21 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 22 | golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= 23 | golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= 24 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 25 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 26 | golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= 27 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 28 | golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= 29 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 30 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 31 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 32 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= 33 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= 34 | google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= 35 | google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= 36 | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= 37 | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 38 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 39 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 40 | gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= 41 | gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= 42 | gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= 43 | gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= 44 | -------------------------------------------------------------------------------- /order/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 3 | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= 4 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= 5 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= 6 | github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= 7 | github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= 8 | github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= 9 | github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= 10 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 11 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 12 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 13 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 14 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 15 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 16 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 17 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 18 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 19 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 20 | golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= 21 | golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= 22 | golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= 23 | golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= 24 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 25 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 26 | golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= 27 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 28 | golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= 29 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 30 | golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= 31 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 32 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= 33 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 34 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 35 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 36 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= 37 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= 38 | google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= 39 | google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= 40 | google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= 41 | google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 42 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 43 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 44 | gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= 45 | gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= 46 | gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= 47 | gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= 48 | -------------------------------------------------------------------------------- /order/internal/pb/order_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | OrderService_CreateOrder_FullMethodName = "/order.OrderService/CreateOrder" 23 | ) 24 | 25 | // OrderServiceClient is the client API for OrderService service. 26 | // 27 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 28 | type OrderServiceClient interface { 29 | CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) 30 | } 31 | 32 | type orderServiceClient struct { 33 | cc grpc.ClientConnInterface 34 | } 35 | 36 | func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient { 37 | return &orderServiceClient{cc} 38 | } 39 | 40 | func (c *orderServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) { 41 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 42 | out := new(CreateOrderResponse) 43 | err := c.cc.Invoke(ctx, OrderService_CreateOrder_FullMethodName, in, out, cOpts...) 44 | if err != nil { 45 | return nil, err 46 | } 47 | return out, nil 48 | } 49 | 50 | // OrderServiceServer is the server API for OrderService service. 51 | // All implementations must embed UnimplementedOrderServiceServer 52 | // for forward compatibility. 53 | type OrderServiceServer interface { 54 | CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) 55 | mustEmbedUnimplementedOrderServiceServer() 56 | } 57 | 58 | // UnimplementedOrderServiceServer must be embedded to have 59 | // forward compatible implementations. 60 | // 61 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 62 | // pointer dereference when methods are called. 63 | type UnimplementedOrderServiceServer struct{} 64 | 65 | func (UnimplementedOrderServiceServer) CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) { 66 | return nil, status.Errorf(codes.Unimplemented, "method CreateOrder not implemented") 67 | } 68 | func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {} 69 | func (UnimplementedOrderServiceServer) testEmbeddedByValue() {} 70 | 71 | // UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service. 72 | // Use of this interface is not recommended, as added methods to OrderServiceServer will 73 | // result in compilation errors. 74 | type UnsafeOrderServiceServer interface { 75 | mustEmbedUnimplementedOrderServiceServer() 76 | } 77 | 78 | func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) { 79 | // If the following call pancis, it indicates UnimplementedOrderServiceServer was 80 | // embedded by pointer and is nil. This will cause panics if an 81 | // unimplemented method is ever invoked, so we test this at initialization 82 | // time to prevent it from happening at runtime later due to I/O. 83 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 84 | t.testEmbeddedByValue() 85 | } 86 | s.RegisterService(&OrderService_ServiceDesc, srv) 87 | } 88 | 89 | func _OrderService_CreateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 90 | in := new(CreateOrderRequest) 91 | if err := dec(in); err != nil { 92 | return nil, err 93 | } 94 | if interceptor == nil { 95 | return srv.(OrderServiceServer).CreateOrder(ctx, in) 96 | } 97 | info := &grpc.UnaryServerInfo{ 98 | Server: srv, 99 | FullMethod: OrderService_CreateOrder_FullMethodName, 100 | } 101 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 102 | return srv.(OrderServiceServer).CreateOrder(ctx, req.(*CreateOrderRequest)) 103 | } 104 | return interceptor(ctx, in, info, handler) 105 | } 106 | 107 | // OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service. 108 | // It's only intended for direct use with grpc.RegisterService, 109 | // and not to be introspected or modified (even as a copy) 110 | var OrderService_ServiceDesc = grpc.ServiceDesc{ 111 | ServiceName: "order.OrderService", 112 | HandlerType: (*OrderServiceServer)(nil), 113 | Methods: []grpc.MethodDesc{ 114 | { 115 | MethodName: "CreateOrder", 116 | Handler: _OrderService_CreateOrder_Handler, 117 | }, 118 | }, 119 | Streams: []grpc.StreamDesc{}, 120 | Metadata: "internal/pb/order.proto", 121 | } 122 | -------------------------------------------------------------------------------- /api-gateaway/internal/order/pb/order_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/order/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | OrderService_CreateOrder_FullMethodName = "/order.OrderService/CreateOrder" 23 | ) 24 | 25 | // OrderServiceClient is the client API for OrderService service. 26 | // 27 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 28 | type OrderServiceClient interface { 29 | CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) 30 | } 31 | 32 | type orderServiceClient struct { 33 | cc grpc.ClientConnInterface 34 | } 35 | 36 | func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient { 37 | return &orderServiceClient{cc} 38 | } 39 | 40 | func (c *orderServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) { 41 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 42 | out := new(CreateOrderResponse) 43 | err := c.cc.Invoke(ctx, OrderService_CreateOrder_FullMethodName, in, out, cOpts...) 44 | if err != nil { 45 | return nil, err 46 | } 47 | return out, nil 48 | } 49 | 50 | // OrderServiceServer is the server API for OrderService service. 51 | // All implementations must embed UnimplementedOrderServiceServer 52 | // for forward compatibility. 53 | type OrderServiceServer interface { 54 | CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) 55 | mustEmbedUnimplementedOrderServiceServer() 56 | } 57 | 58 | // UnimplementedOrderServiceServer must be embedded to have 59 | // forward compatible implementations. 60 | // 61 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 62 | // pointer dereference when methods are called. 63 | type UnimplementedOrderServiceServer struct{} 64 | 65 | func (UnimplementedOrderServiceServer) CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) { 66 | return nil, status.Errorf(codes.Unimplemented, "method CreateOrder not implemented") 67 | } 68 | func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {} 69 | func (UnimplementedOrderServiceServer) testEmbeddedByValue() {} 70 | 71 | // UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service. 72 | // Use of this interface is not recommended, as added methods to OrderServiceServer will 73 | // result in compilation errors. 74 | type UnsafeOrderServiceServer interface { 75 | mustEmbedUnimplementedOrderServiceServer() 76 | } 77 | 78 | func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) { 79 | // If the following call pancis, it indicates UnimplementedOrderServiceServer was 80 | // embedded by pointer and is nil. This will cause panics if an 81 | // unimplemented method is ever invoked, so we test this at initialization 82 | // time to prevent it from happening at runtime later due to I/O. 83 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 84 | t.testEmbeddedByValue() 85 | } 86 | s.RegisterService(&OrderService_ServiceDesc, srv) 87 | } 88 | 89 | func _OrderService_CreateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 90 | in := new(CreateOrderRequest) 91 | if err := dec(in); err != nil { 92 | return nil, err 93 | } 94 | if interceptor == nil { 95 | return srv.(OrderServiceServer).CreateOrder(ctx, in) 96 | } 97 | info := &grpc.UnaryServerInfo{ 98 | Server: srv, 99 | FullMethod: OrderService_CreateOrder_FullMethodName, 100 | } 101 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 102 | return srv.(OrderServiceServer).CreateOrder(ctx, req.(*CreateOrderRequest)) 103 | } 104 | return interceptor(ctx, in, info, handler) 105 | } 106 | 107 | // OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service. 108 | // It's only intended for direct use with grpc.RegisterService, 109 | // and not to be introspected or modified (even as a copy) 110 | var OrderService_ServiceDesc = grpc.ServiceDesc{ 111 | ServiceName: "order.OrderService", 112 | HandlerType: (*OrderServiceServer)(nil), 113 | Methods: []grpc.MethodDesc{ 114 | { 115 | MethodName: "CreateOrder", 116 | Handler: _OrderService_CreateOrder_Handler, 117 | }, 118 | }, 119 | Streams: []grpc.StreamDesc{}, 120 | Metadata: "internal/order/pb/order.proto", 121 | } 122 | -------------------------------------------------------------------------------- /order/internal/pb/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.36.6 4 | // protoc v5.29.3 5 | // source: internal/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | unsafe "unsafe" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type CreateOrderRequest struct { 25 | state protoimpl.MessageState `protogen:"open.v1"` 26 | ProductId int64 `protobuf:"varint,1,opt,name=productId,proto3" json:"productId,omitempty"` 27 | Quantity int64 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"` 28 | UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` 29 | unknownFields protoimpl.UnknownFields 30 | sizeCache protoimpl.SizeCache 31 | } 32 | 33 | func (x *CreateOrderRequest) Reset() { 34 | *x = CreateOrderRequest{} 35 | mi := &file_internal_pb_order_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *CreateOrderRequest) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*CreateOrderRequest) ProtoMessage() {} 45 | 46 | func (x *CreateOrderRequest) ProtoReflect() protoreflect.Message { 47 | mi := &file_internal_pb_order_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use CreateOrderRequest.ProtoReflect.Descriptor instead. 59 | func (*CreateOrderRequest) Descriptor() ([]byte, []int) { 60 | return file_internal_pb_order_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *CreateOrderRequest) GetProductId() int64 { 64 | if x != nil { 65 | return x.ProductId 66 | } 67 | return 0 68 | } 69 | 70 | func (x *CreateOrderRequest) GetQuantity() int64 { 71 | if x != nil { 72 | return x.Quantity 73 | } 74 | return 0 75 | } 76 | 77 | func (x *CreateOrderRequest) GetUserId() int64 { 78 | if x != nil { 79 | return x.UserId 80 | } 81 | return 0 82 | } 83 | 84 | type CreateOrderResponse struct { 85 | state protoimpl.MessageState `protogen:"open.v1"` 86 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 87 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 88 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 89 | unknownFields protoimpl.UnknownFields 90 | sizeCache protoimpl.SizeCache 91 | } 92 | 93 | func (x *CreateOrderResponse) Reset() { 94 | *x = CreateOrderResponse{} 95 | mi := &file_internal_pb_order_proto_msgTypes[1] 96 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 97 | ms.StoreMessageInfo(mi) 98 | } 99 | 100 | func (x *CreateOrderResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*CreateOrderResponse) ProtoMessage() {} 105 | 106 | func (x *CreateOrderResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_internal_pb_order_proto_msgTypes[1] 108 | if x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use CreateOrderResponse.ProtoReflect.Descriptor instead. 119 | func (*CreateOrderResponse) Descriptor() ([]byte, []int) { 120 | return file_internal_pb_order_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *CreateOrderResponse) GetStatus() int64 { 124 | if x != nil { 125 | return x.Status 126 | } 127 | return 0 128 | } 129 | 130 | func (x *CreateOrderResponse) GetError() string { 131 | if x != nil { 132 | return x.Error 133 | } 134 | return "" 135 | } 136 | 137 | func (x *CreateOrderResponse) GetId() int64 { 138 | if x != nil { 139 | return x.Id 140 | } 141 | return 0 142 | } 143 | 144 | var File_internal_pb_order_proto protoreflect.FileDescriptor 145 | 146 | const file_internal_pb_order_proto_rawDesc = "" + 147 | "\n" + 148 | "\x17internal/pb/order.proto\x12\x05order\"f\n" + 149 | "\x12CreateOrderRequest\x12\x1c\n" + 150 | "\tproductId\x18\x01 \x01(\x03R\tproductId\x12\x1a\n" + 151 | "\bquantity\x18\x02 \x01(\x03R\bquantity\x12\x16\n" + 152 | "\x06userId\x18\x03 \x01(\x03R\x06userId\"S\n" + 153 | "\x13CreateOrderResponse\x12\x16\n" + 154 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 155 | "\x05error\x18\x02 \x01(\tR\x05error\x12\x0e\n" + 156 | "\x02id\x18\x03 \x01(\x03R\x02id2T\n" + 157 | "\fOrderService\x12D\n" + 158 | "\vCreateOrder\x12\x19.order.CreateOrderRequest\x1a\x1a.order.CreateOrderResponseB\x0fZ\r./internal/pbb\x06proto3" 159 | 160 | var ( 161 | file_internal_pb_order_proto_rawDescOnce sync.Once 162 | file_internal_pb_order_proto_rawDescData []byte 163 | ) 164 | 165 | func file_internal_pb_order_proto_rawDescGZIP() []byte { 166 | file_internal_pb_order_proto_rawDescOnce.Do(func() { 167 | file_internal_pb_order_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_pb_order_proto_rawDesc), len(file_internal_pb_order_proto_rawDesc))) 168 | }) 169 | return file_internal_pb_order_proto_rawDescData 170 | } 171 | 172 | var file_internal_pb_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 173 | var file_internal_pb_order_proto_goTypes = []any{ 174 | (*CreateOrderRequest)(nil), // 0: order.CreateOrderRequest 175 | (*CreateOrderResponse)(nil), // 1: order.CreateOrderResponse 176 | } 177 | var file_internal_pb_order_proto_depIdxs = []int32{ 178 | 0, // 0: order.OrderService.CreateOrder:input_type -> order.CreateOrderRequest 179 | 1, // 1: order.OrderService.CreateOrder:output_type -> order.CreateOrderResponse 180 | 1, // [1:2] is the sub-list for method output_type 181 | 0, // [0:1] is the sub-list for method input_type 182 | 0, // [0:0] is the sub-list for extension type_name 183 | 0, // [0:0] is the sub-list for extension extendee 184 | 0, // [0:0] is the sub-list for field type_name 185 | } 186 | 187 | func init() { file_internal_pb_order_proto_init() } 188 | func file_internal_pb_order_proto_init() { 189 | if File_internal_pb_order_proto != nil { 190 | return 191 | } 192 | type x struct{} 193 | out := protoimpl.TypeBuilder{ 194 | File: protoimpl.DescBuilder{ 195 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 196 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_pb_order_proto_rawDesc), len(file_internal_pb_order_proto_rawDesc)), 197 | NumEnums: 0, 198 | NumMessages: 2, 199 | NumExtensions: 0, 200 | NumServices: 1, 201 | }, 202 | GoTypes: file_internal_pb_order_proto_goTypes, 203 | DependencyIndexes: file_internal_pb_order_proto_depIdxs, 204 | MessageInfos: file_internal_pb_order_proto_msgTypes, 205 | }.Build() 206 | File_internal_pb_order_proto = out.File 207 | file_internal_pb_order_proto_goTypes = nil 208 | file_internal_pb_order_proto_depIdxs = nil 209 | } 210 | -------------------------------------------------------------------------------- /api-gateaway/go.sum: -------------------------------------------------------------------------------- 1 | github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= 2 | github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= 3 | github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= 4 | github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= 5 | github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= 6 | github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= 7 | github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= 8 | github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= 9 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 10 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 11 | github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= 12 | github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= 13 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 14 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 15 | github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= 16 | github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= 17 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= 18 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= 19 | github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= 20 | github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= 21 | github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= 22 | github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= 23 | github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= 24 | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= 25 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 26 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 27 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 28 | github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= 29 | github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= 30 | github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= 31 | github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= 32 | github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= 33 | github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= 34 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 35 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 36 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 37 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 38 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 39 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 40 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 41 | github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= 42 | github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= 43 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 44 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 45 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 46 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 47 | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= 48 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 49 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 50 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 51 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 52 | github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 53 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 54 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 55 | github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= 56 | github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= 57 | github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= 58 | github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= 59 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= 60 | golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= 61 | golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= 62 | golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= 63 | golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= 64 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 65 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 66 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 67 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 68 | golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= 69 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 70 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 71 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 72 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= 73 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= 74 | google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= 75 | google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= 76 | google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= 77 | google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 78 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 79 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 80 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 81 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 82 | nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= 83 | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= 84 | -------------------------------------------------------------------------------- /api-gateaway/internal/order/pb/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.36.6 4 | // protoc v5.29.3 5 | // source: internal/order/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | unsafe "unsafe" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type CreateOrderRequest struct { 25 | state protoimpl.MessageState `protogen:"open.v1"` 26 | ProductID int64 `protobuf:"varint,1,opt,name=productID,proto3" json:"productID,omitempty"` 27 | Quantity int64 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"` 28 | UserID int64 `protobuf:"varint,3,opt,name=userID,proto3" json:"userID,omitempty"` 29 | unknownFields protoimpl.UnknownFields 30 | sizeCache protoimpl.SizeCache 31 | } 32 | 33 | func (x *CreateOrderRequest) Reset() { 34 | *x = CreateOrderRequest{} 35 | mi := &file_internal_order_pb_order_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *CreateOrderRequest) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*CreateOrderRequest) ProtoMessage() {} 45 | 46 | func (x *CreateOrderRequest) ProtoReflect() protoreflect.Message { 47 | mi := &file_internal_order_pb_order_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use CreateOrderRequest.ProtoReflect.Descriptor instead. 59 | func (*CreateOrderRequest) Descriptor() ([]byte, []int) { 60 | return file_internal_order_pb_order_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *CreateOrderRequest) GetProductID() int64 { 64 | if x != nil { 65 | return x.ProductID 66 | } 67 | return 0 68 | } 69 | 70 | func (x *CreateOrderRequest) GetQuantity() int64 { 71 | if x != nil { 72 | return x.Quantity 73 | } 74 | return 0 75 | } 76 | 77 | func (x *CreateOrderRequest) GetUserID() int64 { 78 | if x != nil { 79 | return x.UserID 80 | } 81 | return 0 82 | } 83 | 84 | type CreateOrderResponse struct { 85 | state protoimpl.MessageState `protogen:"open.v1"` 86 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 87 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 88 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 89 | unknownFields protoimpl.UnknownFields 90 | sizeCache protoimpl.SizeCache 91 | } 92 | 93 | func (x *CreateOrderResponse) Reset() { 94 | *x = CreateOrderResponse{} 95 | mi := &file_internal_order_pb_order_proto_msgTypes[1] 96 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 97 | ms.StoreMessageInfo(mi) 98 | } 99 | 100 | func (x *CreateOrderResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*CreateOrderResponse) ProtoMessage() {} 105 | 106 | func (x *CreateOrderResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_internal_order_pb_order_proto_msgTypes[1] 108 | if x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use CreateOrderResponse.ProtoReflect.Descriptor instead. 119 | func (*CreateOrderResponse) Descriptor() ([]byte, []int) { 120 | return file_internal_order_pb_order_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *CreateOrderResponse) GetStatus() int64 { 124 | if x != nil { 125 | return x.Status 126 | } 127 | return 0 128 | } 129 | 130 | func (x *CreateOrderResponse) GetError() string { 131 | if x != nil { 132 | return x.Error 133 | } 134 | return "" 135 | } 136 | 137 | func (x *CreateOrderResponse) GetId() int64 { 138 | if x != nil { 139 | return x.Id 140 | } 141 | return 0 142 | } 143 | 144 | var File_internal_order_pb_order_proto protoreflect.FileDescriptor 145 | 146 | const file_internal_order_pb_order_proto_rawDesc = "" + 147 | "\n" + 148 | "\x1dinternal/order/pb/order.proto\x12\x05order\"f\n" + 149 | "\x12CreateOrderRequest\x12\x1c\n" + 150 | "\tproductID\x18\x01 \x01(\x03R\tproductID\x12\x1a\n" + 151 | "\bquantity\x18\x02 \x01(\x03R\bquantity\x12\x16\n" + 152 | "\x06userID\x18\x03 \x01(\x03R\x06userID\"S\n" + 153 | "\x13CreateOrderResponse\x12\x16\n" + 154 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 155 | "\x05error\x18\x02 \x01(\tR\x05error\x12\x0e\n" + 156 | "\x02id\x18\x03 \x01(\x03R\x02id2T\n" + 157 | "\fOrderService\x12D\n" + 158 | "\vCreateOrder\x12\x19.order.CreateOrderRequest\x1a\x1a.order.CreateOrderResponseB\x15Z\x13./internal/order/pbb\x06proto3" 159 | 160 | var ( 161 | file_internal_order_pb_order_proto_rawDescOnce sync.Once 162 | file_internal_order_pb_order_proto_rawDescData []byte 163 | ) 164 | 165 | func file_internal_order_pb_order_proto_rawDescGZIP() []byte { 166 | file_internal_order_pb_order_proto_rawDescOnce.Do(func() { 167 | file_internal_order_pb_order_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_order_pb_order_proto_rawDesc), len(file_internal_order_pb_order_proto_rawDesc))) 168 | }) 169 | return file_internal_order_pb_order_proto_rawDescData 170 | } 171 | 172 | var file_internal_order_pb_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 173 | var file_internal_order_pb_order_proto_goTypes = []any{ 174 | (*CreateOrderRequest)(nil), // 0: order.CreateOrderRequest 175 | (*CreateOrderResponse)(nil), // 1: order.CreateOrderResponse 176 | } 177 | var file_internal_order_pb_order_proto_depIdxs = []int32{ 178 | 0, // 0: order.OrderService.CreateOrder:input_type -> order.CreateOrderRequest 179 | 1, // 1: order.OrderService.CreateOrder:output_type -> order.CreateOrderResponse 180 | 1, // [1:2] is the sub-list for method output_type 181 | 0, // [0:1] is the sub-list for method input_type 182 | 0, // [0:0] is the sub-list for extension type_name 183 | 0, // [0:0] is the sub-list for extension extendee 184 | 0, // [0:0] is the sub-list for field type_name 185 | } 186 | 187 | func init() { file_internal_order_pb_order_proto_init() } 188 | func file_internal_order_pb_order_proto_init() { 189 | if File_internal_order_pb_order_proto != nil { 190 | return 191 | } 192 | type x struct{} 193 | out := protoimpl.TypeBuilder{ 194 | File: protoimpl.DescBuilder{ 195 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 196 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_order_pb_order_proto_rawDesc), len(file_internal_order_pb_order_proto_rawDesc)), 197 | NumEnums: 0, 198 | NumMessages: 2, 199 | NumExtensions: 0, 200 | NumServices: 1, 201 | }, 202 | GoTypes: file_internal_order_pb_order_proto_goTypes, 203 | DependencyIndexes: file_internal_order_pb_order_proto_depIdxs, 204 | MessageInfos: file_internal_order_pb_order_proto_msgTypes, 205 | }.Build() 206 | File_internal_order_pb_order_proto = out.File 207 | file_internal_order_pb_order_proto_goTypes = nil 208 | file_internal_order_pb_order_proto_depIdxs = nil 209 | } 210 | -------------------------------------------------------------------------------- /order/internal/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | ProductService_CreateProduct_FullMethodName = "/product.ProductService/CreateProduct" 23 | ProductService_FindOne_FullMethodName = "/product.ProductService/FindOne" 24 | ProductService_DecreaseStock_FullMethodName = "/product.ProductService/DecreaseStock" 25 | ) 26 | 27 | // ProductServiceClient is the client API for ProductService service. 28 | // 29 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 30 | type ProductServiceClient interface { 31 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 32 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 33 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 34 | } 35 | 36 | type productServiceClient struct { 37 | cc grpc.ClientConnInterface 38 | } 39 | 40 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 41 | return &productServiceClient{cc} 42 | } 43 | 44 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 45 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 46 | out := new(CreateProductResponse) 47 | err := c.cc.Invoke(ctx, ProductService_CreateProduct_FullMethodName, in, out, cOpts...) 48 | if err != nil { 49 | return nil, err 50 | } 51 | return out, nil 52 | } 53 | 54 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 55 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 56 | out := new(FindOneResponse) 57 | err := c.cc.Invoke(ctx, ProductService_FindOne_FullMethodName, in, out, cOpts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return out, nil 62 | } 63 | 64 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 65 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 66 | out := new(DecreaseStockResponse) 67 | err := c.cc.Invoke(ctx, ProductService_DecreaseStock_FullMethodName, in, out, cOpts...) 68 | if err != nil { 69 | return nil, err 70 | } 71 | return out, nil 72 | } 73 | 74 | // ProductServiceServer is the server API for ProductService service. 75 | // All implementations must embed UnimplementedProductServiceServer 76 | // for forward compatibility. 77 | type ProductServiceServer interface { 78 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 79 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 80 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 81 | mustEmbedUnimplementedProductServiceServer() 82 | } 83 | 84 | // UnimplementedProductServiceServer must be embedded to have 85 | // forward compatible implementations. 86 | // 87 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 88 | // pointer dereference when methods are called. 89 | type UnimplementedProductServiceServer struct{} 90 | 91 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 92 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 93 | } 94 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 95 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 96 | } 97 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 98 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 99 | } 100 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 101 | func (UnimplementedProductServiceServer) testEmbeddedByValue() {} 102 | 103 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 104 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 105 | // result in compilation errors. 106 | type UnsafeProductServiceServer interface { 107 | mustEmbedUnimplementedProductServiceServer() 108 | } 109 | 110 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 111 | // If the following call pancis, it indicates UnimplementedProductServiceServer was 112 | // embedded by pointer and is nil. This will cause panics if an 113 | // unimplemented method is ever invoked, so we test this at initialization 114 | // time to prevent it from happening at runtime later due to I/O. 115 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 116 | t.testEmbeddedByValue() 117 | } 118 | s.RegisterService(&ProductService_ServiceDesc, srv) 119 | } 120 | 121 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 122 | in := new(CreateProductRequest) 123 | if err := dec(in); err != nil { 124 | return nil, err 125 | } 126 | if interceptor == nil { 127 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 128 | } 129 | info := &grpc.UnaryServerInfo{ 130 | Server: srv, 131 | FullMethod: ProductService_CreateProduct_FullMethodName, 132 | } 133 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 134 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 135 | } 136 | return interceptor(ctx, in, info, handler) 137 | } 138 | 139 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 140 | in := new(FindOneRequest) 141 | if err := dec(in); err != nil { 142 | return nil, err 143 | } 144 | if interceptor == nil { 145 | return srv.(ProductServiceServer).FindOne(ctx, in) 146 | } 147 | info := &grpc.UnaryServerInfo{ 148 | Server: srv, 149 | FullMethod: ProductService_FindOne_FullMethodName, 150 | } 151 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 152 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 153 | } 154 | return interceptor(ctx, in, info, handler) 155 | } 156 | 157 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 158 | in := new(DecreaseStockRequest) 159 | if err := dec(in); err != nil { 160 | return nil, err 161 | } 162 | if interceptor == nil { 163 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 164 | } 165 | info := &grpc.UnaryServerInfo{ 166 | Server: srv, 167 | FullMethod: ProductService_DecreaseStock_FullMethodName, 168 | } 169 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 170 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 171 | } 172 | return interceptor(ctx, in, info, handler) 173 | } 174 | 175 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 176 | // It's only intended for direct use with grpc.RegisterService, 177 | // and not to be introspected or modified (even as a copy) 178 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 179 | ServiceName: "product.ProductService", 180 | HandlerType: (*ProductServiceServer)(nil), 181 | Methods: []grpc.MethodDesc{ 182 | { 183 | MethodName: "CreateProduct", 184 | Handler: _ProductService_CreateProduct_Handler, 185 | }, 186 | { 187 | MethodName: "FindOne", 188 | Handler: _ProductService_FindOne_Handler, 189 | }, 190 | { 191 | MethodName: "DecreaseStock", 192 | Handler: _ProductService_DecreaseStock_Handler, 193 | }, 194 | }, 195 | Streams: []grpc.StreamDesc{}, 196 | Metadata: "internal/pb/product.proto", 197 | } 198 | -------------------------------------------------------------------------------- /product/go.sum: -------------------------------------------------------------------------------- 1 | github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= 2 | github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= 3 | github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= 4 | github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= 5 | github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= 6 | github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= 7 | github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= 8 | github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= 9 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 10 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 11 | github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= 12 | github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= 13 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 14 | github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 15 | github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= 16 | github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= 17 | github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= 18 | github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= 19 | github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= 20 | github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= 21 | github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= 22 | github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= 23 | github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= 24 | github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= 25 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 26 | github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= 27 | github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= 28 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= 29 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= 30 | github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= 31 | github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= 32 | github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= 33 | github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= 34 | github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 35 | github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 36 | github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= 37 | github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= 38 | github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= 39 | github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= 40 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 41 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 42 | github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= 43 | github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= 44 | github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= 45 | github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= 46 | github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= 47 | github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= 48 | github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= 49 | github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 50 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 51 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 52 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 53 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 54 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 55 | github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= 56 | github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= 57 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 58 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 59 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 60 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 61 | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= 62 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 63 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 64 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 65 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 66 | github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 67 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 68 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 69 | github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= 70 | github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= 71 | github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= 72 | github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= 73 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= 74 | golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= 75 | golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= 76 | golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= 77 | golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= 78 | golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= 79 | golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= 80 | golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= 81 | golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= 82 | golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= 83 | golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 84 | golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= 85 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 86 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 87 | golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 88 | golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= 89 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 90 | golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= 91 | golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 92 | golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 93 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 94 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= 95 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= 96 | google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= 97 | google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= 98 | google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= 99 | google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= 100 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 101 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 102 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 103 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 104 | gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= 105 | gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSkweRGI= 106 | gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8= 107 | gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= 108 | nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= 109 | rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= 110 | -------------------------------------------------------------------------------- /product/internal/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | ProductService_CreateProduct_FullMethodName = "/product.ProductService/CreateProduct" 23 | ProductService_FindOne_FullMethodName = "/product.ProductService/FindOne" 24 | ProductService_FindAll_FullMethodName = "/product.ProductService/FindAll" 25 | ProductService_DecreaseStock_FullMethodName = "/product.ProductService/DecreaseStock" 26 | ) 27 | 28 | // ProductServiceClient is the client API for ProductService service. 29 | // 30 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 31 | type ProductServiceClient interface { 32 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 33 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 34 | FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) 35 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 36 | } 37 | 38 | type productServiceClient struct { 39 | cc grpc.ClientConnInterface 40 | } 41 | 42 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 43 | return &productServiceClient{cc} 44 | } 45 | 46 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 47 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 48 | out := new(CreateProductResponse) 49 | err := c.cc.Invoke(ctx, ProductService_CreateProduct_FullMethodName, in, out, cOpts...) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return out, nil 54 | } 55 | 56 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 57 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 58 | out := new(FindOneResponse) 59 | err := c.cc.Invoke(ctx, ProductService_FindOne_FullMethodName, in, out, cOpts...) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return out, nil 64 | } 65 | 66 | func (c *productServiceClient) FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) { 67 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 68 | out := new(FindAllResponse) 69 | err := c.cc.Invoke(ctx, ProductService_FindAll_FullMethodName, in, out, cOpts...) 70 | if err != nil { 71 | return nil, err 72 | } 73 | return out, nil 74 | } 75 | 76 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 77 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 78 | out := new(DecreaseStockResponse) 79 | err := c.cc.Invoke(ctx, ProductService_DecreaseStock_FullMethodName, in, out, cOpts...) 80 | if err != nil { 81 | return nil, err 82 | } 83 | return out, nil 84 | } 85 | 86 | // ProductServiceServer is the server API for ProductService service. 87 | // All implementations must embed UnimplementedProductServiceServer 88 | // for forward compatibility. 89 | type ProductServiceServer interface { 90 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 91 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 92 | FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) 93 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 94 | mustEmbedUnimplementedProductServiceServer() 95 | } 96 | 97 | // UnimplementedProductServiceServer must be embedded to have 98 | // forward compatible implementations. 99 | // 100 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 101 | // pointer dereference when methods are called. 102 | type UnimplementedProductServiceServer struct{} 103 | 104 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 105 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 106 | } 107 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 108 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 109 | } 110 | func (UnimplementedProductServiceServer) FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) { 111 | return nil, status.Errorf(codes.Unimplemented, "method FindAll not implemented") 112 | } 113 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 114 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 115 | } 116 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 117 | func (UnimplementedProductServiceServer) testEmbeddedByValue() {} 118 | 119 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 120 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 121 | // result in compilation errors. 122 | type UnsafeProductServiceServer interface { 123 | mustEmbedUnimplementedProductServiceServer() 124 | } 125 | 126 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 127 | // If the following call pancis, it indicates UnimplementedProductServiceServer was 128 | // embedded by pointer and is nil. This will cause panics if an 129 | // unimplemented method is ever invoked, so we test this at initialization 130 | // time to prevent it from happening at runtime later due to I/O. 131 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 132 | t.testEmbeddedByValue() 133 | } 134 | s.RegisterService(&ProductService_ServiceDesc, srv) 135 | } 136 | 137 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 138 | in := new(CreateProductRequest) 139 | if err := dec(in); err != nil { 140 | return nil, err 141 | } 142 | if interceptor == nil { 143 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 144 | } 145 | info := &grpc.UnaryServerInfo{ 146 | Server: srv, 147 | FullMethod: ProductService_CreateProduct_FullMethodName, 148 | } 149 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 150 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 151 | } 152 | return interceptor(ctx, in, info, handler) 153 | } 154 | 155 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 156 | in := new(FindOneRequest) 157 | if err := dec(in); err != nil { 158 | return nil, err 159 | } 160 | if interceptor == nil { 161 | return srv.(ProductServiceServer).FindOne(ctx, in) 162 | } 163 | info := &grpc.UnaryServerInfo{ 164 | Server: srv, 165 | FullMethod: ProductService_FindOne_FullMethodName, 166 | } 167 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 168 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 169 | } 170 | return interceptor(ctx, in, info, handler) 171 | } 172 | 173 | func _ProductService_FindAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 174 | in := new(FindAllRequest) 175 | if err := dec(in); err != nil { 176 | return nil, err 177 | } 178 | if interceptor == nil { 179 | return srv.(ProductServiceServer).FindAll(ctx, in) 180 | } 181 | info := &grpc.UnaryServerInfo{ 182 | Server: srv, 183 | FullMethod: ProductService_FindAll_FullMethodName, 184 | } 185 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 186 | return srv.(ProductServiceServer).FindAll(ctx, req.(*FindAllRequest)) 187 | } 188 | return interceptor(ctx, in, info, handler) 189 | } 190 | 191 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 192 | in := new(DecreaseStockRequest) 193 | if err := dec(in); err != nil { 194 | return nil, err 195 | } 196 | if interceptor == nil { 197 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 198 | } 199 | info := &grpc.UnaryServerInfo{ 200 | Server: srv, 201 | FullMethod: ProductService_DecreaseStock_FullMethodName, 202 | } 203 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 204 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 205 | } 206 | return interceptor(ctx, in, info, handler) 207 | } 208 | 209 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 210 | // It's only intended for direct use with grpc.RegisterService, 211 | // and not to be introspected or modified (even as a copy) 212 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 213 | ServiceName: "product.ProductService", 214 | HandlerType: (*ProductServiceServer)(nil), 215 | Methods: []grpc.MethodDesc{ 216 | { 217 | MethodName: "CreateProduct", 218 | Handler: _ProductService_CreateProduct_Handler, 219 | }, 220 | { 221 | MethodName: "FindOne", 222 | Handler: _ProductService_FindOne_Handler, 223 | }, 224 | { 225 | MethodName: "FindAll", 226 | Handler: _ProductService_FindAll_Handler, 227 | }, 228 | { 229 | MethodName: "DecreaseStock", 230 | Handler: _ProductService_DecreaseStock_Handler, 231 | }, 232 | }, 233 | Streams: []grpc.StreamDesc{}, 234 | Metadata: "internal/pb/product.proto", 235 | } 236 | -------------------------------------------------------------------------------- /api-gateaway/internal/product/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/product/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | ProductService_CreateProduct_FullMethodName = "/product.ProductService/CreateProduct" 23 | ProductService_FindOne_FullMethodName = "/product.ProductService/FindOne" 24 | ProductService_FindAll_FullMethodName = "/product.ProductService/FindAll" 25 | ProductService_DecreaseStock_FullMethodName = "/product.ProductService/DecreaseStock" 26 | ) 27 | 28 | // ProductServiceClient is the client API for ProductService service. 29 | // 30 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 31 | type ProductServiceClient interface { 32 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 33 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 34 | FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) 35 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 36 | } 37 | 38 | type productServiceClient struct { 39 | cc grpc.ClientConnInterface 40 | } 41 | 42 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 43 | return &productServiceClient{cc} 44 | } 45 | 46 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 47 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 48 | out := new(CreateProductResponse) 49 | err := c.cc.Invoke(ctx, ProductService_CreateProduct_FullMethodName, in, out, cOpts...) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return out, nil 54 | } 55 | 56 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 57 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 58 | out := new(FindOneResponse) 59 | err := c.cc.Invoke(ctx, ProductService_FindOne_FullMethodName, in, out, cOpts...) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return out, nil 64 | } 65 | 66 | func (c *productServiceClient) FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) { 67 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 68 | out := new(FindAllResponse) 69 | err := c.cc.Invoke(ctx, ProductService_FindAll_FullMethodName, in, out, cOpts...) 70 | if err != nil { 71 | return nil, err 72 | } 73 | return out, nil 74 | } 75 | 76 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 77 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 78 | out := new(DecreaseStockResponse) 79 | err := c.cc.Invoke(ctx, ProductService_DecreaseStock_FullMethodName, in, out, cOpts...) 80 | if err != nil { 81 | return nil, err 82 | } 83 | return out, nil 84 | } 85 | 86 | // ProductServiceServer is the server API for ProductService service. 87 | // All implementations must embed UnimplementedProductServiceServer 88 | // for forward compatibility. 89 | type ProductServiceServer interface { 90 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 91 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 92 | FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) 93 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 94 | mustEmbedUnimplementedProductServiceServer() 95 | } 96 | 97 | // UnimplementedProductServiceServer must be embedded to have 98 | // forward compatible implementations. 99 | // 100 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 101 | // pointer dereference when methods are called. 102 | type UnimplementedProductServiceServer struct{} 103 | 104 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 105 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 106 | } 107 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 108 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 109 | } 110 | func (UnimplementedProductServiceServer) FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) { 111 | return nil, status.Errorf(codes.Unimplemented, "method FindAll not implemented") 112 | } 113 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 114 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 115 | } 116 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 117 | func (UnimplementedProductServiceServer) testEmbeddedByValue() {} 118 | 119 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 120 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 121 | // result in compilation errors. 122 | type UnsafeProductServiceServer interface { 123 | mustEmbedUnimplementedProductServiceServer() 124 | } 125 | 126 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 127 | // If the following call pancis, it indicates UnimplementedProductServiceServer was 128 | // embedded by pointer and is nil. This will cause panics if an 129 | // unimplemented method is ever invoked, so we test this at initialization 130 | // time to prevent it from happening at runtime later due to I/O. 131 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 132 | t.testEmbeddedByValue() 133 | } 134 | s.RegisterService(&ProductService_ServiceDesc, srv) 135 | } 136 | 137 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 138 | in := new(CreateProductRequest) 139 | if err := dec(in); err != nil { 140 | return nil, err 141 | } 142 | if interceptor == nil { 143 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 144 | } 145 | info := &grpc.UnaryServerInfo{ 146 | Server: srv, 147 | FullMethod: ProductService_CreateProduct_FullMethodName, 148 | } 149 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 150 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 151 | } 152 | return interceptor(ctx, in, info, handler) 153 | } 154 | 155 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 156 | in := new(FindOneRequest) 157 | if err := dec(in); err != nil { 158 | return nil, err 159 | } 160 | if interceptor == nil { 161 | return srv.(ProductServiceServer).FindOne(ctx, in) 162 | } 163 | info := &grpc.UnaryServerInfo{ 164 | Server: srv, 165 | FullMethod: ProductService_FindOne_FullMethodName, 166 | } 167 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 168 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 169 | } 170 | return interceptor(ctx, in, info, handler) 171 | } 172 | 173 | func _ProductService_FindAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 174 | in := new(FindAllRequest) 175 | if err := dec(in); err != nil { 176 | return nil, err 177 | } 178 | if interceptor == nil { 179 | return srv.(ProductServiceServer).FindAll(ctx, in) 180 | } 181 | info := &grpc.UnaryServerInfo{ 182 | Server: srv, 183 | FullMethod: ProductService_FindAll_FullMethodName, 184 | } 185 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 186 | return srv.(ProductServiceServer).FindAll(ctx, req.(*FindAllRequest)) 187 | } 188 | return interceptor(ctx, in, info, handler) 189 | } 190 | 191 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 192 | in := new(DecreaseStockRequest) 193 | if err := dec(in); err != nil { 194 | return nil, err 195 | } 196 | if interceptor == nil { 197 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 198 | } 199 | info := &grpc.UnaryServerInfo{ 200 | Server: srv, 201 | FullMethod: ProductService_DecreaseStock_FullMethodName, 202 | } 203 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 204 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 205 | } 206 | return interceptor(ctx, in, info, handler) 207 | } 208 | 209 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 210 | // It's only intended for direct use with grpc.RegisterService, 211 | // and not to be introspected or modified (even as a copy) 212 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 213 | ServiceName: "product.ProductService", 214 | HandlerType: (*ProductServiceServer)(nil), 215 | Methods: []grpc.MethodDesc{ 216 | { 217 | MethodName: "CreateProduct", 218 | Handler: _ProductService_CreateProduct_Handler, 219 | }, 220 | { 221 | MethodName: "FindOne", 222 | Handler: _ProductService_FindOne_Handler, 223 | }, 224 | { 225 | MethodName: "FindAll", 226 | Handler: _ProductService_FindAll_Handler, 227 | }, 228 | { 229 | MethodName: "DecreaseStock", 230 | Handler: _ProductService_DecreaseStock_Handler, 231 | }, 232 | }, 233 | Streams: []grpc.StreamDesc{}, 234 | Metadata: "internal/product/pb/product.proto", 235 | } 236 | -------------------------------------------------------------------------------- /auth/internal/pb/auth_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | AuthService_Register_FullMethodName = "/auth.AuthService/Register" 23 | AuthService_AdminRegister_FullMethodName = "/auth.AuthService/AdminRegister" 24 | AuthService_Login_FullMethodName = "/auth.AuthService/Login" 25 | AuthService_AdminLogin_FullMethodName = "/auth.AuthService/AdminLogin" 26 | AuthService_Validate_FullMethodName = "/auth.AuthService/Validate" 27 | ) 28 | 29 | // AuthServiceClient is the client API for AuthService service. 30 | // 31 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 32 | type AuthServiceClient interface { 33 | Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 34 | AdminRegister(ctx context.Context, in *AdminRegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 35 | Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 36 | AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 37 | Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) 38 | } 39 | 40 | type authServiceClient struct { 41 | cc grpc.ClientConnInterface 42 | } 43 | 44 | func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { 45 | return &authServiceClient{cc} 46 | } 47 | 48 | func (c *authServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 49 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 50 | out := new(RegisterResponse) 51 | err := c.cc.Invoke(ctx, AuthService_Register_FullMethodName, in, out, cOpts...) 52 | if err != nil { 53 | return nil, err 54 | } 55 | return out, nil 56 | } 57 | 58 | func (c *authServiceClient) AdminRegister(ctx context.Context, in *AdminRegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 59 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 60 | out := new(RegisterResponse) 61 | err := c.cc.Invoke(ctx, AuthService_AdminRegister_FullMethodName, in, out, cOpts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 69 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 70 | out := new(LoginResponse) 71 | err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return out, nil 76 | } 77 | 78 | func (c *authServiceClient) AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 79 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 80 | out := new(LoginResponse) 81 | err := c.cc.Invoke(ctx, AuthService_AdminLogin_FullMethodName, in, out, cOpts...) 82 | if err != nil { 83 | return nil, err 84 | } 85 | return out, nil 86 | } 87 | 88 | func (c *authServiceClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) { 89 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 90 | out := new(ValidateResponse) 91 | err := c.cc.Invoke(ctx, AuthService_Validate_FullMethodName, in, out, cOpts...) 92 | if err != nil { 93 | return nil, err 94 | } 95 | return out, nil 96 | } 97 | 98 | // AuthServiceServer is the server API for AuthService service. 99 | // All implementations must embed UnimplementedAuthServiceServer 100 | // for forward compatibility. 101 | type AuthServiceServer interface { 102 | Register(context.Context, *RegisterRequest) (*RegisterResponse, error) 103 | AdminRegister(context.Context, *AdminRegisterRequest) (*RegisterResponse, error) 104 | Login(context.Context, *LoginRequest) (*LoginResponse, error) 105 | AdminLogin(context.Context, *AdminLoginRequest) (*LoginResponse, error) 106 | Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) 107 | mustEmbedUnimplementedAuthServiceServer() 108 | } 109 | 110 | // UnimplementedAuthServiceServer must be embedded to have 111 | // forward compatible implementations. 112 | // 113 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 114 | // pointer dereference when methods are called. 115 | type UnimplementedAuthServiceServer struct{} 116 | 117 | func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { 118 | return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") 119 | } 120 | func (UnimplementedAuthServiceServer) AdminRegister(context.Context, *AdminRegisterRequest) (*RegisterResponse, error) { 121 | return nil, status.Errorf(codes.Unimplemented, "method AdminRegister not implemented") 122 | } 123 | func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { 124 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 125 | } 126 | func (UnimplementedAuthServiceServer) AdminLogin(context.Context, *AdminLoginRequest) (*LoginResponse, error) { 127 | return nil, status.Errorf(codes.Unimplemented, "method AdminLogin not implemented") 128 | } 129 | func (UnimplementedAuthServiceServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) { 130 | return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") 131 | } 132 | func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} 133 | func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} 134 | 135 | // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. 136 | // Use of this interface is not recommended, as added methods to AuthServiceServer will 137 | // result in compilation errors. 138 | type UnsafeAuthServiceServer interface { 139 | mustEmbedUnimplementedAuthServiceServer() 140 | } 141 | 142 | func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { 143 | // If the following call pancis, it indicates UnimplementedAuthServiceServer was 144 | // embedded by pointer and is nil. This will cause panics if an 145 | // unimplemented method is ever invoked, so we test this at initialization 146 | // time to prevent it from happening at runtime later due to I/O. 147 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 148 | t.testEmbeddedByValue() 149 | } 150 | s.RegisterService(&AuthService_ServiceDesc, srv) 151 | } 152 | 153 | func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 154 | in := new(RegisterRequest) 155 | if err := dec(in); err != nil { 156 | return nil, err 157 | } 158 | if interceptor == nil { 159 | return srv.(AuthServiceServer).Register(ctx, in) 160 | } 161 | info := &grpc.UnaryServerInfo{ 162 | Server: srv, 163 | FullMethod: AuthService_Register_FullMethodName, 164 | } 165 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 166 | return srv.(AuthServiceServer).Register(ctx, req.(*RegisterRequest)) 167 | } 168 | return interceptor(ctx, in, info, handler) 169 | } 170 | 171 | func _AuthService_AdminRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 172 | in := new(AdminRegisterRequest) 173 | if err := dec(in); err != nil { 174 | return nil, err 175 | } 176 | if interceptor == nil { 177 | return srv.(AuthServiceServer).AdminRegister(ctx, in) 178 | } 179 | info := &grpc.UnaryServerInfo{ 180 | Server: srv, 181 | FullMethod: AuthService_AdminRegister_FullMethodName, 182 | } 183 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 184 | return srv.(AuthServiceServer).AdminRegister(ctx, req.(*AdminRegisterRequest)) 185 | } 186 | return interceptor(ctx, in, info, handler) 187 | } 188 | 189 | func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 190 | in := new(LoginRequest) 191 | if err := dec(in); err != nil { 192 | return nil, err 193 | } 194 | if interceptor == nil { 195 | return srv.(AuthServiceServer).Login(ctx, in) 196 | } 197 | info := &grpc.UnaryServerInfo{ 198 | Server: srv, 199 | FullMethod: AuthService_Login_FullMethodName, 200 | } 201 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 202 | return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) 203 | } 204 | return interceptor(ctx, in, info, handler) 205 | } 206 | 207 | func _AuthService_AdminLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 208 | in := new(AdminLoginRequest) 209 | if err := dec(in); err != nil { 210 | return nil, err 211 | } 212 | if interceptor == nil { 213 | return srv.(AuthServiceServer).AdminLogin(ctx, in) 214 | } 215 | info := &grpc.UnaryServerInfo{ 216 | Server: srv, 217 | FullMethod: AuthService_AdminLogin_FullMethodName, 218 | } 219 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 220 | return srv.(AuthServiceServer).AdminLogin(ctx, req.(*AdminLoginRequest)) 221 | } 222 | return interceptor(ctx, in, info, handler) 223 | } 224 | 225 | func _AuthService_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 226 | in := new(ValidateRequest) 227 | if err := dec(in); err != nil { 228 | return nil, err 229 | } 230 | if interceptor == nil { 231 | return srv.(AuthServiceServer).Validate(ctx, in) 232 | } 233 | info := &grpc.UnaryServerInfo{ 234 | Server: srv, 235 | FullMethod: AuthService_Validate_FullMethodName, 236 | } 237 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 238 | return srv.(AuthServiceServer).Validate(ctx, req.(*ValidateRequest)) 239 | } 240 | return interceptor(ctx, in, info, handler) 241 | } 242 | 243 | // AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. 244 | // It's only intended for direct use with grpc.RegisterService, 245 | // and not to be introspected or modified (even as a copy) 246 | var AuthService_ServiceDesc = grpc.ServiceDesc{ 247 | ServiceName: "auth.AuthService", 248 | HandlerType: (*AuthServiceServer)(nil), 249 | Methods: []grpc.MethodDesc{ 250 | { 251 | MethodName: "Register", 252 | Handler: _AuthService_Register_Handler, 253 | }, 254 | { 255 | MethodName: "AdminRegister", 256 | Handler: _AuthService_AdminRegister_Handler, 257 | }, 258 | { 259 | MethodName: "Login", 260 | Handler: _AuthService_Login_Handler, 261 | }, 262 | { 263 | MethodName: "AdminLogin", 264 | Handler: _AuthService_AdminLogin_Handler, 265 | }, 266 | { 267 | MethodName: "Validate", 268 | Handler: _AuthService_Validate_Handler, 269 | }, 270 | }, 271 | Streams: []grpc.StreamDesc{}, 272 | Metadata: "internal/pb/auth.proto", 273 | } 274 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/pb/auth_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.5.1 4 | // - protoc v5.29.3 5 | // source: internal/auth/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.64.0 or later. 19 | const _ = grpc.SupportPackageIsVersion9 20 | 21 | const ( 22 | AuthService_Register_FullMethodName = "/auth.AuthService/Register" 23 | AuthService_AdminRegister_FullMethodName = "/auth.AuthService/AdminRegister" 24 | AuthService_Login_FullMethodName = "/auth.AuthService/Login" 25 | AuthService_AdminLogin_FullMethodName = "/auth.AuthService/AdminLogin" 26 | AuthService_Validate_FullMethodName = "/auth.AuthService/Validate" 27 | ) 28 | 29 | // AuthServiceClient is the client API for AuthService service. 30 | // 31 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. 32 | type AuthServiceClient interface { 33 | Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 34 | AdminRegister(ctx context.Context, in *AdminRegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 35 | Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 36 | AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 37 | Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) 38 | } 39 | 40 | type authServiceClient struct { 41 | cc grpc.ClientConnInterface 42 | } 43 | 44 | func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { 45 | return &authServiceClient{cc} 46 | } 47 | 48 | func (c *authServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 49 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 50 | out := new(RegisterResponse) 51 | err := c.cc.Invoke(ctx, AuthService_Register_FullMethodName, in, out, cOpts...) 52 | if err != nil { 53 | return nil, err 54 | } 55 | return out, nil 56 | } 57 | 58 | func (c *authServiceClient) AdminRegister(ctx context.Context, in *AdminRegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 59 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 60 | out := new(RegisterResponse) 61 | err := c.cc.Invoke(ctx, AuthService_AdminRegister_FullMethodName, in, out, cOpts...) 62 | if err != nil { 63 | return nil, err 64 | } 65 | return out, nil 66 | } 67 | 68 | func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 69 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 70 | out := new(LoginResponse) 71 | err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...) 72 | if err != nil { 73 | return nil, err 74 | } 75 | return out, nil 76 | } 77 | 78 | func (c *authServiceClient) AdminLogin(ctx context.Context, in *AdminLoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 79 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 80 | out := new(LoginResponse) 81 | err := c.cc.Invoke(ctx, AuthService_AdminLogin_FullMethodName, in, out, cOpts...) 82 | if err != nil { 83 | return nil, err 84 | } 85 | return out, nil 86 | } 87 | 88 | func (c *authServiceClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) { 89 | cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) 90 | out := new(ValidateResponse) 91 | err := c.cc.Invoke(ctx, AuthService_Validate_FullMethodName, in, out, cOpts...) 92 | if err != nil { 93 | return nil, err 94 | } 95 | return out, nil 96 | } 97 | 98 | // AuthServiceServer is the server API for AuthService service. 99 | // All implementations must embed UnimplementedAuthServiceServer 100 | // for forward compatibility. 101 | type AuthServiceServer interface { 102 | Register(context.Context, *RegisterRequest) (*RegisterResponse, error) 103 | AdminRegister(context.Context, *AdminRegisterRequest) (*RegisterResponse, error) 104 | Login(context.Context, *LoginRequest) (*LoginResponse, error) 105 | AdminLogin(context.Context, *AdminLoginRequest) (*LoginResponse, error) 106 | Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) 107 | mustEmbedUnimplementedAuthServiceServer() 108 | } 109 | 110 | // UnimplementedAuthServiceServer must be embedded to have 111 | // forward compatible implementations. 112 | // 113 | // NOTE: this should be embedded by value instead of pointer to avoid a nil 114 | // pointer dereference when methods are called. 115 | type UnimplementedAuthServiceServer struct{} 116 | 117 | func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { 118 | return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") 119 | } 120 | func (UnimplementedAuthServiceServer) AdminRegister(context.Context, *AdminRegisterRequest) (*RegisterResponse, error) { 121 | return nil, status.Errorf(codes.Unimplemented, "method AdminRegister not implemented") 122 | } 123 | func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { 124 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 125 | } 126 | func (UnimplementedAuthServiceServer) AdminLogin(context.Context, *AdminLoginRequest) (*LoginResponse, error) { 127 | return nil, status.Errorf(codes.Unimplemented, "method AdminLogin not implemented") 128 | } 129 | func (UnimplementedAuthServiceServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) { 130 | return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") 131 | } 132 | func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} 133 | func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} 134 | 135 | // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. 136 | // Use of this interface is not recommended, as added methods to AuthServiceServer will 137 | // result in compilation errors. 138 | type UnsafeAuthServiceServer interface { 139 | mustEmbedUnimplementedAuthServiceServer() 140 | } 141 | 142 | func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { 143 | // If the following call pancis, it indicates UnimplementedAuthServiceServer was 144 | // embedded by pointer and is nil. This will cause panics if an 145 | // unimplemented method is ever invoked, so we test this at initialization 146 | // time to prevent it from happening at runtime later due to I/O. 147 | if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { 148 | t.testEmbeddedByValue() 149 | } 150 | s.RegisterService(&AuthService_ServiceDesc, srv) 151 | } 152 | 153 | func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 154 | in := new(RegisterRequest) 155 | if err := dec(in); err != nil { 156 | return nil, err 157 | } 158 | if interceptor == nil { 159 | return srv.(AuthServiceServer).Register(ctx, in) 160 | } 161 | info := &grpc.UnaryServerInfo{ 162 | Server: srv, 163 | FullMethod: AuthService_Register_FullMethodName, 164 | } 165 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 166 | return srv.(AuthServiceServer).Register(ctx, req.(*RegisterRequest)) 167 | } 168 | return interceptor(ctx, in, info, handler) 169 | } 170 | 171 | func _AuthService_AdminRegister_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 172 | in := new(AdminRegisterRequest) 173 | if err := dec(in); err != nil { 174 | return nil, err 175 | } 176 | if interceptor == nil { 177 | return srv.(AuthServiceServer).AdminRegister(ctx, in) 178 | } 179 | info := &grpc.UnaryServerInfo{ 180 | Server: srv, 181 | FullMethod: AuthService_AdminRegister_FullMethodName, 182 | } 183 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 184 | return srv.(AuthServiceServer).AdminRegister(ctx, req.(*AdminRegisterRequest)) 185 | } 186 | return interceptor(ctx, in, info, handler) 187 | } 188 | 189 | func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 190 | in := new(LoginRequest) 191 | if err := dec(in); err != nil { 192 | return nil, err 193 | } 194 | if interceptor == nil { 195 | return srv.(AuthServiceServer).Login(ctx, in) 196 | } 197 | info := &grpc.UnaryServerInfo{ 198 | Server: srv, 199 | FullMethod: AuthService_Login_FullMethodName, 200 | } 201 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 202 | return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) 203 | } 204 | return interceptor(ctx, in, info, handler) 205 | } 206 | 207 | func _AuthService_AdminLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 208 | in := new(AdminLoginRequest) 209 | if err := dec(in); err != nil { 210 | return nil, err 211 | } 212 | if interceptor == nil { 213 | return srv.(AuthServiceServer).AdminLogin(ctx, in) 214 | } 215 | info := &grpc.UnaryServerInfo{ 216 | Server: srv, 217 | FullMethod: AuthService_AdminLogin_FullMethodName, 218 | } 219 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 220 | return srv.(AuthServiceServer).AdminLogin(ctx, req.(*AdminLoginRequest)) 221 | } 222 | return interceptor(ctx, in, info, handler) 223 | } 224 | 225 | func _AuthService_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 226 | in := new(ValidateRequest) 227 | if err := dec(in); err != nil { 228 | return nil, err 229 | } 230 | if interceptor == nil { 231 | return srv.(AuthServiceServer).Validate(ctx, in) 232 | } 233 | info := &grpc.UnaryServerInfo{ 234 | Server: srv, 235 | FullMethod: AuthService_Validate_FullMethodName, 236 | } 237 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 238 | return srv.(AuthServiceServer).Validate(ctx, req.(*ValidateRequest)) 239 | } 240 | return interceptor(ctx, in, info, handler) 241 | } 242 | 243 | // AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. 244 | // It's only intended for direct use with grpc.RegisterService, 245 | // and not to be introspected or modified (even as a copy) 246 | var AuthService_ServiceDesc = grpc.ServiceDesc{ 247 | ServiceName: "auth.AuthService", 248 | HandlerType: (*AuthServiceServer)(nil), 249 | Methods: []grpc.MethodDesc{ 250 | { 251 | MethodName: "Register", 252 | Handler: _AuthService_Register_Handler, 253 | }, 254 | { 255 | MethodName: "AdminRegister", 256 | Handler: _AuthService_AdminRegister_Handler, 257 | }, 258 | { 259 | MethodName: "Login", 260 | Handler: _AuthService_Login_Handler, 261 | }, 262 | { 263 | MethodName: "AdminLogin", 264 | Handler: _AuthService_AdminLogin_Handler, 265 | }, 266 | { 267 | MethodName: "Validate", 268 | Handler: _AuthService_Validate_Handler, 269 | }, 270 | }, 271 | Streams: []grpc.StreamDesc{}, 272 | Metadata: "internal/auth/pb/auth.proto", 273 | } 274 | -------------------------------------------------------------------------------- /order/internal/pb/product.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.36.6 4 | // protoc v5.29.3 5 | // source: internal/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | unsafe "unsafe" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type CreateProductRequest struct { 25 | state protoimpl.MessageState `protogen:"open.v1"` 26 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 27 | Stock int64 `protobuf:"varint,2,opt,name=stock,proto3" json:"stock,omitempty"` 28 | Price int64 `protobuf:"varint,3,opt,name=price,proto3" json:"price,omitempty"` 29 | unknownFields protoimpl.UnknownFields 30 | sizeCache protoimpl.SizeCache 31 | } 32 | 33 | func (x *CreateProductRequest) Reset() { 34 | *x = CreateProductRequest{} 35 | mi := &file_internal_pb_product_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *CreateProductRequest) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*CreateProductRequest) ProtoMessage() {} 45 | 46 | func (x *CreateProductRequest) ProtoReflect() protoreflect.Message { 47 | mi := &file_internal_pb_product_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use CreateProductRequest.ProtoReflect.Descriptor instead. 59 | func (*CreateProductRequest) Descriptor() ([]byte, []int) { 60 | return file_internal_pb_product_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *CreateProductRequest) GetName() string { 64 | if x != nil { 65 | return x.Name 66 | } 67 | return "" 68 | } 69 | 70 | func (x *CreateProductRequest) GetStock() int64 { 71 | if x != nil { 72 | return x.Stock 73 | } 74 | return 0 75 | } 76 | 77 | func (x *CreateProductRequest) GetPrice() int64 { 78 | if x != nil { 79 | return x.Price 80 | } 81 | return 0 82 | } 83 | 84 | type CreateProductResponse struct { 85 | state protoimpl.MessageState `protogen:"open.v1"` 86 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 87 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 88 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 89 | unknownFields protoimpl.UnknownFields 90 | sizeCache protoimpl.SizeCache 91 | } 92 | 93 | func (x *CreateProductResponse) Reset() { 94 | *x = CreateProductResponse{} 95 | mi := &file_internal_pb_product_proto_msgTypes[1] 96 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 97 | ms.StoreMessageInfo(mi) 98 | } 99 | 100 | func (x *CreateProductResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*CreateProductResponse) ProtoMessage() {} 105 | 106 | func (x *CreateProductResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_internal_pb_product_proto_msgTypes[1] 108 | if x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use CreateProductResponse.ProtoReflect.Descriptor instead. 119 | func (*CreateProductResponse) Descriptor() ([]byte, []int) { 120 | return file_internal_pb_product_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *CreateProductResponse) GetStatus() int64 { 124 | if x != nil { 125 | return x.Status 126 | } 127 | return 0 128 | } 129 | 130 | func (x *CreateProductResponse) GetError() string { 131 | if x != nil { 132 | return x.Error 133 | } 134 | return "" 135 | } 136 | 137 | func (x *CreateProductResponse) GetId() int64 { 138 | if x != nil { 139 | return x.Id 140 | } 141 | return 0 142 | } 143 | 144 | type FindOneData struct { 145 | state protoimpl.MessageState `protogen:"open.v1"` 146 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 147 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 148 | Stock int64 `protobuf:"varint,3,opt,name=stock,proto3" json:"stock,omitempty"` 149 | Price int64 `protobuf:"varint,4,opt,name=price,proto3" json:"price,omitempty"` 150 | unknownFields protoimpl.UnknownFields 151 | sizeCache protoimpl.SizeCache 152 | } 153 | 154 | func (x *FindOneData) Reset() { 155 | *x = FindOneData{} 156 | mi := &file_internal_pb_product_proto_msgTypes[2] 157 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 158 | ms.StoreMessageInfo(mi) 159 | } 160 | 161 | func (x *FindOneData) String() string { 162 | return protoimpl.X.MessageStringOf(x) 163 | } 164 | 165 | func (*FindOneData) ProtoMessage() {} 166 | 167 | func (x *FindOneData) ProtoReflect() protoreflect.Message { 168 | mi := &file_internal_pb_product_proto_msgTypes[2] 169 | if x != nil { 170 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 171 | if ms.LoadMessageInfo() == nil { 172 | ms.StoreMessageInfo(mi) 173 | } 174 | return ms 175 | } 176 | return mi.MessageOf(x) 177 | } 178 | 179 | // Deprecated: Use FindOneData.ProtoReflect.Descriptor instead. 180 | func (*FindOneData) Descriptor() ([]byte, []int) { 181 | return file_internal_pb_product_proto_rawDescGZIP(), []int{2} 182 | } 183 | 184 | func (x *FindOneData) GetId() int64 { 185 | if x != nil { 186 | return x.Id 187 | } 188 | return 0 189 | } 190 | 191 | func (x *FindOneData) GetName() string { 192 | if x != nil { 193 | return x.Name 194 | } 195 | return "" 196 | } 197 | 198 | func (x *FindOneData) GetStock() int64 { 199 | if x != nil { 200 | return x.Stock 201 | } 202 | return 0 203 | } 204 | 205 | func (x *FindOneData) GetPrice() int64 { 206 | if x != nil { 207 | return x.Price 208 | } 209 | return 0 210 | } 211 | 212 | type FindOneRequest struct { 213 | state protoimpl.MessageState `protogen:"open.v1"` 214 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 215 | unknownFields protoimpl.UnknownFields 216 | sizeCache protoimpl.SizeCache 217 | } 218 | 219 | func (x *FindOneRequest) Reset() { 220 | *x = FindOneRequest{} 221 | mi := &file_internal_pb_product_proto_msgTypes[3] 222 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 223 | ms.StoreMessageInfo(mi) 224 | } 225 | 226 | func (x *FindOneRequest) String() string { 227 | return protoimpl.X.MessageStringOf(x) 228 | } 229 | 230 | func (*FindOneRequest) ProtoMessage() {} 231 | 232 | func (x *FindOneRequest) ProtoReflect() protoreflect.Message { 233 | mi := &file_internal_pb_product_proto_msgTypes[3] 234 | if x != nil { 235 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 236 | if ms.LoadMessageInfo() == nil { 237 | ms.StoreMessageInfo(mi) 238 | } 239 | return ms 240 | } 241 | return mi.MessageOf(x) 242 | } 243 | 244 | // Deprecated: Use FindOneRequest.ProtoReflect.Descriptor instead. 245 | func (*FindOneRequest) Descriptor() ([]byte, []int) { 246 | return file_internal_pb_product_proto_rawDescGZIP(), []int{3} 247 | } 248 | 249 | func (x *FindOneRequest) GetId() int64 { 250 | if x != nil { 251 | return x.Id 252 | } 253 | return 0 254 | } 255 | 256 | type FindOneResponse struct { 257 | state protoimpl.MessageState `protogen:"open.v1"` 258 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 259 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 260 | Data *FindOneData `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` 261 | unknownFields protoimpl.UnknownFields 262 | sizeCache protoimpl.SizeCache 263 | } 264 | 265 | func (x *FindOneResponse) Reset() { 266 | *x = FindOneResponse{} 267 | mi := &file_internal_pb_product_proto_msgTypes[4] 268 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 269 | ms.StoreMessageInfo(mi) 270 | } 271 | 272 | func (x *FindOneResponse) String() string { 273 | return protoimpl.X.MessageStringOf(x) 274 | } 275 | 276 | func (*FindOneResponse) ProtoMessage() {} 277 | 278 | func (x *FindOneResponse) ProtoReflect() protoreflect.Message { 279 | mi := &file_internal_pb_product_proto_msgTypes[4] 280 | if x != nil { 281 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 282 | if ms.LoadMessageInfo() == nil { 283 | ms.StoreMessageInfo(mi) 284 | } 285 | return ms 286 | } 287 | return mi.MessageOf(x) 288 | } 289 | 290 | // Deprecated: Use FindOneResponse.ProtoReflect.Descriptor instead. 291 | func (*FindOneResponse) Descriptor() ([]byte, []int) { 292 | return file_internal_pb_product_proto_rawDescGZIP(), []int{4} 293 | } 294 | 295 | func (x *FindOneResponse) GetStatus() int64 { 296 | if x != nil { 297 | return x.Status 298 | } 299 | return 0 300 | } 301 | 302 | func (x *FindOneResponse) GetError() string { 303 | if x != nil { 304 | return x.Error 305 | } 306 | return "" 307 | } 308 | 309 | func (x *FindOneResponse) GetData() *FindOneData { 310 | if x != nil { 311 | return x.Data 312 | } 313 | return nil 314 | } 315 | 316 | type DecreaseStockRequest struct { 317 | state protoimpl.MessageState `protogen:"open.v1"` 318 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 319 | OrderId int64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` 320 | Quantity int64 `protobuf:"varint,3,opt,name=quantity,proto3" json:"quantity,omitempty"` // <- Add this 321 | unknownFields protoimpl.UnknownFields 322 | sizeCache protoimpl.SizeCache 323 | } 324 | 325 | func (x *DecreaseStockRequest) Reset() { 326 | *x = DecreaseStockRequest{} 327 | mi := &file_internal_pb_product_proto_msgTypes[5] 328 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 329 | ms.StoreMessageInfo(mi) 330 | } 331 | 332 | func (x *DecreaseStockRequest) String() string { 333 | return protoimpl.X.MessageStringOf(x) 334 | } 335 | 336 | func (*DecreaseStockRequest) ProtoMessage() {} 337 | 338 | func (x *DecreaseStockRequest) ProtoReflect() protoreflect.Message { 339 | mi := &file_internal_pb_product_proto_msgTypes[5] 340 | if x != nil { 341 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 342 | if ms.LoadMessageInfo() == nil { 343 | ms.StoreMessageInfo(mi) 344 | } 345 | return ms 346 | } 347 | return mi.MessageOf(x) 348 | } 349 | 350 | // Deprecated: Use DecreaseStockRequest.ProtoReflect.Descriptor instead. 351 | func (*DecreaseStockRequest) Descriptor() ([]byte, []int) { 352 | return file_internal_pb_product_proto_rawDescGZIP(), []int{5} 353 | } 354 | 355 | func (x *DecreaseStockRequest) GetId() int64 { 356 | if x != nil { 357 | return x.Id 358 | } 359 | return 0 360 | } 361 | 362 | func (x *DecreaseStockRequest) GetOrderId() int64 { 363 | if x != nil { 364 | return x.OrderId 365 | } 366 | return 0 367 | } 368 | 369 | func (x *DecreaseStockRequest) GetQuantity() int64 { 370 | if x != nil { 371 | return x.Quantity 372 | } 373 | return 0 374 | } 375 | 376 | type DecreaseStockResponse struct { 377 | state protoimpl.MessageState `protogen:"open.v1"` 378 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 379 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 380 | unknownFields protoimpl.UnknownFields 381 | sizeCache protoimpl.SizeCache 382 | } 383 | 384 | func (x *DecreaseStockResponse) Reset() { 385 | *x = DecreaseStockResponse{} 386 | mi := &file_internal_pb_product_proto_msgTypes[6] 387 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 388 | ms.StoreMessageInfo(mi) 389 | } 390 | 391 | func (x *DecreaseStockResponse) String() string { 392 | return protoimpl.X.MessageStringOf(x) 393 | } 394 | 395 | func (*DecreaseStockResponse) ProtoMessage() {} 396 | 397 | func (x *DecreaseStockResponse) ProtoReflect() protoreflect.Message { 398 | mi := &file_internal_pb_product_proto_msgTypes[6] 399 | if x != nil { 400 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 401 | if ms.LoadMessageInfo() == nil { 402 | ms.StoreMessageInfo(mi) 403 | } 404 | return ms 405 | } 406 | return mi.MessageOf(x) 407 | } 408 | 409 | // Deprecated: Use DecreaseStockResponse.ProtoReflect.Descriptor instead. 410 | func (*DecreaseStockResponse) Descriptor() ([]byte, []int) { 411 | return file_internal_pb_product_proto_rawDescGZIP(), []int{6} 412 | } 413 | 414 | func (x *DecreaseStockResponse) GetStatus() int64 { 415 | if x != nil { 416 | return x.Status 417 | } 418 | return 0 419 | } 420 | 421 | func (x *DecreaseStockResponse) GetError() string { 422 | if x != nil { 423 | return x.Error 424 | } 425 | return "" 426 | } 427 | 428 | var File_internal_pb_product_proto protoreflect.FileDescriptor 429 | 430 | const file_internal_pb_product_proto_rawDesc = "" + 431 | "\n" + 432 | "\x19internal/pb/product.proto\x12\aproduct\"V\n" + 433 | "\x14CreateProductRequest\x12\x12\n" + 434 | "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + 435 | "\x05stock\x18\x02 \x01(\x03R\x05stock\x12\x14\n" + 436 | "\x05price\x18\x03 \x01(\x03R\x05price\"U\n" + 437 | "\x15CreateProductResponse\x12\x16\n" + 438 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 439 | "\x05error\x18\x02 \x01(\tR\x05error\x12\x0e\n" + 440 | "\x02id\x18\x03 \x01(\x03R\x02id\"]\n" + 441 | "\vFindOneData\x12\x0e\n" + 442 | "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + 443 | "\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" + 444 | "\x05stock\x18\x03 \x01(\x03R\x05stock\x12\x14\n" + 445 | "\x05price\x18\x04 \x01(\x03R\x05price\" \n" + 446 | "\x0eFindOneRequest\x12\x0e\n" + 447 | "\x02id\x18\x01 \x01(\x03R\x02id\"i\n" + 448 | "\x0fFindOneResponse\x12\x16\n" + 449 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 450 | "\x05error\x18\x02 \x01(\tR\x05error\x12(\n" + 451 | "\x04data\x18\x03 \x01(\v2\x14.product.FindOneDataR\x04data\"\\\n" + 452 | "\x14DecreaseStockRequest\x12\x0e\n" + 453 | "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + 454 | "\aorderId\x18\x02 \x01(\x03R\aorderId\x12\x1a\n" + 455 | "\bquantity\x18\x03 \x01(\x03R\bquantity\"E\n" + 456 | "\x15DecreaseStockResponse\x12\x16\n" + 457 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 458 | "\x05error\x18\x02 \x01(\tR\x05error2\xee\x01\n" + 459 | "\x0eProductService\x12N\n" + 460 | "\rCreateProduct\x12\x1d.product.CreateProductRequest\x1a\x1e.product.CreateProductResponse\x12<\n" + 461 | "\aFindOne\x12\x17.product.FindOneRequest\x1a\x18.product.FindOneResponse\x12N\n" + 462 | "\rDecreaseStock\x12\x1d.product.DecreaseStockRequest\x1a\x1e.product.DecreaseStockResponseB\x0fZ\r./internal/pbb\x06proto3" 463 | 464 | var ( 465 | file_internal_pb_product_proto_rawDescOnce sync.Once 466 | file_internal_pb_product_proto_rawDescData []byte 467 | ) 468 | 469 | func file_internal_pb_product_proto_rawDescGZIP() []byte { 470 | file_internal_pb_product_proto_rawDescOnce.Do(func() { 471 | file_internal_pb_product_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_pb_product_proto_rawDesc), len(file_internal_pb_product_proto_rawDesc))) 472 | }) 473 | return file_internal_pb_product_proto_rawDescData 474 | } 475 | 476 | var file_internal_pb_product_proto_msgTypes = make([]protoimpl.MessageInfo, 7) 477 | var file_internal_pb_product_proto_goTypes = []any{ 478 | (*CreateProductRequest)(nil), // 0: product.CreateProductRequest 479 | (*CreateProductResponse)(nil), // 1: product.CreateProductResponse 480 | (*FindOneData)(nil), // 2: product.FindOneData 481 | (*FindOneRequest)(nil), // 3: product.FindOneRequest 482 | (*FindOneResponse)(nil), // 4: product.FindOneResponse 483 | (*DecreaseStockRequest)(nil), // 5: product.DecreaseStockRequest 484 | (*DecreaseStockResponse)(nil), // 6: product.DecreaseStockResponse 485 | } 486 | var file_internal_pb_product_proto_depIdxs = []int32{ 487 | 2, // 0: product.FindOneResponse.data:type_name -> product.FindOneData 488 | 0, // 1: product.ProductService.CreateProduct:input_type -> product.CreateProductRequest 489 | 3, // 2: product.ProductService.FindOne:input_type -> product.FindOneRequest 490 | 5, // 3: product.ProductService.DecreaseStock:input_type -> product.DecreaseStockRequest 491 | 1, // 4: product.ProductService.CreateProduct:output_type -> product.CreateProductResponse 492 | 4, // 5: product.ProductService.FindOne:output_type -> product.FindOneResponse 493 | 6, // 6: product.ProductService.DecreaseStock:output_type -> product.DecreaseStockResponse 494 | 4, // [4:7] is the sub-list for method output_type 495 | 1, // [1:4] is the sub-list for method input_type 496 | 1, // [1:1] is the sub-list for extension type_name 497 | 1, // [1:1] is the sub-list for extension extendee 498 | 0, // [0:1] is the sub-list for field type_name 499 | } 500 | 501 | func init() { file_internal_pb_product_proto_init() } 502 | func file_internal_pb_product_proto_init() { 503 | if File_internal_pb_product_proto != nil { 504 | return 505 | } 506 | type x struct{} 507 | out := protoimpl.TypeBuilder{ 508 | File: protoimpl.DescBuilder{ 509 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 510 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_pb_product_proto_rawDesc), len(file_internal_pb_product_proto_rawDesc)), 511 | NumEnums: 0, 512 | NumMessages: 7, 513 | NumExtensions: 0, 514 | NumServices: 1, 515 | }, 516 | GoTypes: file_internal_pb_product_proto_goTypes, 517 | DependencyIndexes: file_internal_pb_product_proto_depIdxs, 518 | MessageInfos: file_internal_pb_product_proto_msgTypes, 519 | }.Build() 520 | File_internal_pb_product_proto = out.File 521 | file_internal_pb_product_proto_goTypes = nil 522 | file_internal_pb_product_proto_depIdxs = nil 523 | } 524 | -------------------------------------------------------------------------------- /auth/internal/pb/auth.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.36.6 4 | // protoc v5.29.3 5 | // source: internal/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | unsafe "unsafe" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type RegisterRequest struct { 25 | state protoimpl.MessageState `protogen:"open.v1"` 26 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 27 | Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` 28 | Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` 29 | unknownFields protoimpl.UnknownFields 30 | sizeCache protoimpl.SizeCache 31 | } 32 | 33 | func (x *RegisterRequest) Reset() { 34 | *x = RegisterRequest{} 35 | mi := &file_internal_pb_auth_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *RegisterRequest) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*RegisterRequest) ProtoMessage() {} 45 | 46 | func (x *RegisterRequest) ProtoReflect() protoreflect.Message { 47 | mi := &file_internal_pb_auth_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. 59 | func (*RegisterRequest) Descriptor() ([]byte, []int) { 60 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *RegisterRequest) GetUsername() string { 64 | if x != nil { 65 | return x.Username 66 | } 67 | return "" 68 | } 69 | 70 | func (x *RegisterRequest) GetEmail() string { 71 | if x != nil { 72 | return x.Email 73 | } 74 | return "" 75 | } 76 | 77 | func (x *RegisterRequest) GetPassword() string { 78 | if x != nil { 79 | return x.Password 80 | } 81 | return "" 82 | } 83 | 84 | type RegisterResponse struct { 85 | state protoimpl.MessageState `protogen:"open.v1"` 86 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 87 | Status int64 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` 88 | Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` 89 | unknownFields protoimpl.UnknownFields 90 | sizeCache protoimpl.SizeCache 91 | } 92 | 93 | func (x *RegisterResponse) Reset() { 94 | *x = RegisterResponse{} 95 | mi := &file_internal_pb_auth_proto_msgTypes[1] 96 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 97 | ms.StoreMessageInfo(mi) 98 | } 99 | 100 | func (x *RegisterResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*RegisterResponse) ProtoMessage() {} 105 | 106 | func (x *RegisterResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_internal_pb_auth_proto_msgTypes[1] 108 | if x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. 119 | func (*RegisterResponse) Descriptor() ([]byte, []int) { 120 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *RegisterResponse) GetId() int64 { 124 | if x != nil { 125 | return x.Id 126 | } 127 | return 0 128 | } 129 | 130 | func (x *RegisterResponse) GetStatus() int64 { 131 | if x != nil { 132 | return x.Status 133 | } 134 | return 0 135 | } 136 | 137 | func (x *RegisterResponse) GetError() string { 138 | if x != nil { 139 | return x.Error 140 | } 141 | return "" 142 | } 143 | 144 | type AdminRegisterRequest struct { 145 | state protoimpl.MessageState `protogen:"open.v1"` 146 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 147 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 148 | unknownFields protoimpl.UnknownFields 149 | sizeCache protoimpl.SizeCache 150 | } 151 | 152 | func (x *AdminRegisterRequest) Reset() { 153 | *x = AdminRegisterRequest{} 154 | mi := &file_internal_pb_auth_proto_msgTypes[2] 155 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 156 | ms.StoreMessageInfo(mi) 157 | } 158 | 159 | func (x *AdminRegisterRequest) String() string { 160 | return protoimpl.X.MessageStringOf(x) 161 | } 162 | 163 | func (*AdminRegisterRequest) ProtoMessage() {} 164 | 165 | func (x *AdminRegisterRequest) ProtoReflect() protoreflect.Message { 166 | mi := &file_internal_pb_auth_proto_msgTypes[2] 167 | if x != nil { 168 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 169 | if ms.LoadMessageInfo() == nil { 170 | ms.StoreMessageInfo(mi) 171 | } 172 | return ms 173 | } 174 | return mi.MessageOf(x) 175 | } 176 | 177 | // Deprecated: Use AdminRegisterRequest.ProtoReflect.Descriptor instead. 178 | func (*AdminRegisterRequest) Descriptor() ([]byte, []int) { 179 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{2} 180 | } 181 | 182 | func (x *AdminRegisterRequest) GetUsername() string { 183 | if x != nil { 184 | return x.Username 185 | } 186 | return "" 187 | } 188 | 189 | func (x *AdminRegisterRequest) GetPassword() string { 190 | if x != nil { 191 | return x.Password 192 | } 193 | return "" 194 | } 195 | 196 | type AdminRegisterResponse struct { 197 | state protoimpl.MessageState `protogen:"open.v1"` 198 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 199 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 200 | unknownFields protoimpl.UnknownFields 201 | sizeCache protoimpl.SizeCache 202 | } 203 | 204 | func (x *AdminRegisterResponse) Reset() { 205 | *x = AdminRegisterResponse{} 206 | mi := &file_internal_pb_auth_proto_msgTypes[3] 207 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 208 | ms.StoreMessageInfo(mi) 209 | } 210 | 211 | func (x *AdminRegisterResponse) String() string { 212 | return protoimpl.X.MessageStringOf(x) 213 | } 214 | 215 | func (*AdminRegisterResponse) ProtoMessage() {} 216 | 217 | func (x *AdminRegisterResponse) ProtoReflect() protoreflect.Message { 218 | mi := &file_internal_pb_auth_proto_msgTypes[3] 219 | if x != nil { 220 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 221 | if ms.LoadMessageInfo() == nil { 222 | ms.StoreMessageInfo(mi) 223 | } 224 | return ms 225 | } 226 | return mi.MessageOf(x) 227 | } 228 | 229 | // Deprecated: Use AdminRegisterResponse.ProtoReflect.Descriptor instead. 230 | func (*AdminRegisterResponse) Descriptor() ([]byte, []int) { 231 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{3} 232 | } 233 | 234 | func (x *AdminRegisterResponse) GetUsername() string { 235 | if x != nil { 236 | return x.Username 237 | } 238 | return "" 239 | } 240 | 241 | func (x *AdminRegisterResponse) GetPassword() string { 242 | if x != nil { 243 | return x.Password 244 | } 245 | return "" 246 | } 247 | 248 | type LoginRequest struct { 249 | state protoimpl.MessageState `protogen:"open.v1"` 250 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 251 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 252 | unknownFields protoimpl.UnknownFields 253 | sizeCache protoimpl.SizeCache 254 | } 255 | 256 | func (x *LoginRequest) Reset() { 257 | *x = LoginRequest{} 258 | mi := &file_internal_pb_auth_proto_msgTypes[4] 259 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 260 | ms.StoreMessageInfo(mi) 261 | } 262 | 263 | func (x *LoginRequest) String() string { 264 | return protoimpl.X.MessageStringOf(x) 265 | } 266 | 267 | func (*LoginRequest) ProtoMessage() {} 268 | 269 | func (x *LoginRequest) ProtoReflect() protoreflect.Message { 270 | mi := &file_internal_pb_auth_proto_msgTypes[4] 271 | if x != nil { 272 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 273 | if ms.LoadMessageInfo() == nil { 274 | ms.StoreMessageInfo(mi) 275 | } 276 | return ms 277 | } 278 | return mi.MessageOf(x) 279 | } 280 | 281 | // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. 282 | func (*LoginRequest) Descriptor() ([]byte, []int) { 283 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{4} 284 | } 285 | 286 | func (x *LoginRequest) GetEmail() string { 287 | if x != nil { 288 | return x.Email 289 | } 290 | return "" 291 | } 292 | 293 | func (x *LoginRequest) GetPassword() string { 294 | if x != nil { 295 | return x.Password 296 | } 297 | return "" 298 | } 299 | 300 | type AdminLoginRequest struct { 301 | state protoimpl.MessageState `protogen:"open.v1"` 302 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 303 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 304 | unknownFields protoimpl.UnknownFields 305 | sizeCache protoimpl.SizeCache 306 | } 307 | 308 | func (x *AdminLoginRequest) Reset() { 309 | *x = AdminLoginRequest{} 310 | mi := &file_internal_pb_auth_proto_msgTypes[5] 311 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 312 | ms.StoreMessageInfo(mi) 313 | } 314 | 315 | func (x *AdminLoginRequest) String() string { 316 | return protoimpl.X.MessageStringOf(x) 317 | } 318 | 319 | func (*AdminLoginRequest) ProtoMessage() {} 320 | 321 | func (x *AdminLoginRequest) ProtoReflect() protoreflect.Message { 322 | mi := &file_internal_pb_auth_proto_msgTypes[5] 323 | if x != nil { 324 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 325 | if ms.LoadMessageInfo() == nil { 326 | ms.StoreMessageInfo(mi) 327 | } 328 | return ms 329 | } 330 | return mi.MessageOf(x) 331 | } 332 | 333 | // Deprecated: Use AdminLoginRequest.ProtoReflect.Descriptor instead. 334 | func (*AdminLoginRequest) Descriptor() ([]byte, []int) { 335 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{5} 336 | } 337 | 338 | func (x *AdminLoginRequest) GetUsername() string { 339 | if x != nil { 340 | return x.Username 341 | } 342 | return "" 343 | } 344 | 345 | func (x *AdminLoginRequest) GetPassword() string { 346 | if x != nil { 347 | return x.Password 348 | } 349 | return "" 350 | } 351 | 352 | type LoginResponse struct { 353 | state protoimpl.MessageState `protogen:"open.v1"` 354 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 355 | Status int64 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` 356 | Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` 357 | unknownFields protoimpl.UnknownFields 358 | sizeCache protoimpl.SizeCache 359 | } 360 | 361 | func (x *LoginResponse) Reset() { 362 | *x = LoginResponse{} 363 | mi := &file_internal_pb_auth_proto_msgTypes[6] 364 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 365 | ms.StoreMessageInfo(mi) 366 | } 367 | 368 | func (x *LoginResponse) String() string { 369 | return protoimpl.X.MessageStringOf(x) 370 | } 371 | 372 | func (*LoginResponse) ProtoMessage() {} 373 | 374 | func (x *LoginResponse) ProtoReflect() protoreflect.Message { 375 | mi := &file_internal_pb_auth_proto_msgTypes[6] 376 | if x != nil { 377 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 378 | if ms.LoadMessageInfo() == nil { 379 | ms.StoreMessageInfo(mi) 380 | } 381 | return ms 382 | } 383 | return mi.MessageOf(x) 384 | } 385 | 386 | // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. 387 | func (*LoginResponse) Descriptor() ([]byte, []int) { 388 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{6} 389 | } 390 | 391 | func (x *LoginResponse) GetToken() string { 392 | if x != nil { 393 | return x.Token 394 | } 395 | return "" 396 | } 397 | 398 | func (x *LoginResponse) GetStatus() int64 { 399 | if x != nil { 400 | return x.Status 401 | } 402 | return 0 403 | } 404 | 405 | func (x *LoginResponse) GetError() string { 406 | if x != nil { 407 | return x.Error 408 | } 409 | return "" 410 | } 411 | 412 | type ValidateRequest struct { 413 | state protoimpl.MessageState `protogen:"open.v1"` 414 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 415 | unknownFields protoimpl.UnknownFields 416 | sizeCache protoimpl.SizeCache 417 | } 418 | 419 | func (x *ValidateRequest) Reset() { 420 | *x = ValidateRequest{} 421 | mi := &file_internal_pb_auth_proto_msgTypes[7] 422 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 423 | ms.StoreMessageInfo(mi) 424 | } 425 | 426 | func (x *ValidateRequest) String() string { 427 | return protoimpl.X.MessageStringOf(x) 428 | } 429 | 430 | func (*ValidateRequest) ProtoMessage() {} 431 | 432 | func (x *ValidateRequest) ProtoReflect() protoreflect.Message { 433 | mi := &file_internal_pb_auth_proto_msgTypes[7] 434 | if x != nil { 435 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 436 | if ms.LoadMessageInfo() == nil { 437 | ms.StoreMessageInfo(mi) 438 | } 439 | return ms 440 | } 441 | return mi.MessageOf(x) 442 | } 443 | 444 | // Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead. 445 | func (*ValidateRequest) Descriptor() ([]byte, []int) { 446 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{7} 447 | } 448 | 449 | func (x *ValidateRequest) GetToken() string { 450 | if x != nil { 451 | return x.Token 452 | } 453 | return "" 454 | } 455 | 456 | type ValidateResponse struct { 457 | state protoimpl.MessageState `protogen:"open.v1"` 458 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 459 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 460 | UserID int64 `protobuf:"varint,3,opt,name=userID,proto3" json:"userID,omitempty"` 461 | unknownFields protoimpl.UnknownFields 462 | sizeCache protoimpl.SizeCache 463 | } 464 | 465 | func (x *ValidateResponse) Reset() { 466 | *x = ValidateResponse{} 467 | mi := &file_internal_pb_auth_proto_msgTypes[8] 468 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 469 | ms.StoreMessageInfo(mi) 470 | } 471 | 472 | func (x *ValidateResponse) String() string { 473 | return protoimpl.X.MessageStringOf(x) 474 | } 475 | 476 | func (*ValidateResponse) ProtoMessage() {} 477 | 478 | func (x *ValidateResponse) ProtoReflect() protoreflect.Message { 479 | mi := &file_internal_pb_auth_proto_msgTypes[8] 480 | if x != nil { 481 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 482 | if ms.LoadMessageInfo() == nil { 483 | ms.StoreMessageInfo(mi) 484 | } 485 | return ms 486 | } 487 | return mi.MessageOf(x) 488 | } 489 | 490 | // Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead. 491 | func (*ValidateResponse) Descriptor() ([]byte, []int) { 492 | return file_internal_pb_auth_proto_rawDescGZIP(), []int{8} 493 | } 494 | 495 | func (x *ValidateResponse) GetStatus() int64 { 496 | if x != nil { 497 | return x.Status 498 | } 499 | return 0 500 | } 501 | 502 | func (x *ValidateResponse) GetError() string { 503 | if x != nil { 504 | return x.Error 505 | } 506 | return "" 507 | } 508 | 509 | func (x *ValidateResponse) GetUserID() int64 { 510 | if x != nil { 511 | return x.UserID 512 | } 513 | return 0 514 | } 515 | 516 | var File_internal_pb_auth_proto protoreflect.FileDescriptor 517 | 518 | const file_internal_pb_auth_proto_rawDesc = "" + 519 | "\n" + 520 | "\x16internal/pb/auth.proto\x12\x04auth\"_\n" + 521 | "\x0fRegisterRequest\x12\x1a\n" + 522 | "\busername\x18\x01 \x01(\tR\busername\x12\x14\n" + 523 | "\x05email\x18\x02 \x01(\tR\x05email\x12\x1a\n" + 524 | "\bpassword\x18\x03 \x01(\tR\bpassword\"P\n" + 525 | "\x10RegisterResponse\x12\x0e\n" + 526 | "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + 527 | "\x06status\x18\x02 \x01(\x03R\x06status\x12\x14\n" + 528 | "\x05error\x18\x03 \x01(\tR\x05error\"N\n" + 529 | "\x14AdminRegisterRequest\x12\x1a\n" + 530 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 531 | "\bpassword\x18\x02 \x01(\tR\bpassword\"O\n" + 532 | "\x15AdminRegisterResponse\x12\x1a\n" + 533 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 534 | "\bpassword\x18\x02 \x01(\tR\bpassword\"@\n" + 535 | "\fLoginRequest\x12\x14\n" + 536 | "\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" + 537 | "\bpassword\x18\x02 \x01(\tR\bpassword\"K\n" + 538 | "\x11AdminLoginRequest\x12\x1a\n" + 539 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 540 | "\bpassword\x18\x02 \x01(\tR\bpassword\"S\n" + 541 | "\rLoginResponse\x12\x14\n" + 542 | "\x05token\x18\x01 \x01(\tR\x05token\x12\x16\n" + 543 | "\x06status\x18\x02 \x01(\x03R\x06status\x12\x14\n" + 544 | "\x05error\x18\x03 \x01(\tR\x05error\"'\n" + 545 | "\x0fValidateRequest\x12\x14\n" + 546 | "\x05token\x18\x01 \x01(\tR\x05token\"X\n" + 547 | "\x10ValidateResponse\x12\x16\n" + 548 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 549 | "\x05error\x18\x02 \x01(\tR\x05error\x12\x16\n" + 550 | "\x06userID\x18\x03 \x01(\x03R\x06userID2\xb6\x02\n" + 551 | "\vAuthService\x129\n" + 552 | "\bRegister\x12\x15.auth.RegisterRequest\x1a\x16.auth.RegisterResponse\x12C\n" + 553 | "\rAdminRegister\x12\x1a.auth.AdminRegisterRequest\x1a\x16.auth.RegisterResponse\x120\n" + 554 | "\x05Login\x12\x12.auth.LoginRequest\x1a\x13.auth.LoginResponse\x12:\n" + 555 | "\n" + 556 | "AdminLogin\x12\x17.auth.AdminLoginRequest\x1a\x13.auth.LoginResponse\x129\n" + 557 | "\bValidate\x12\x15.auth.ValidateRequest\x1a\x16.auth.ValidateResponseB\x0fZ\r./internal/pbb\x06proto3" 558 | 559 | var ( 560 | file_internal_pb_auth_proto_rawDescOnce sync.Once 561 | file_internal_pb_auth_proto_rawDescData []byte 562 | ) 563 | 564 | func file_internal_pb_auth_proto_rawDescGZIP() []byte { 565 | file_internal_pb_auth_proto_rawDescOnce.Do(func() { 566 | file_internal_pb_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_pb_auth_proto_rawDesc), len(file_internal_pb_auth_proto_rawDesc))) 567 | }) 568 | return file_internal_pb_auth_proto_rawDescData 569 | } 570 | 571 | var file_internal_pb_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 9) 572 | var file_internal_pb_auth_proto_goTypes = []any{ 573 | (*RegisterRequest)(nil), // 0: auth.RegisterRequest 574 | (*RegisterResponse)(nil), // 1: auth.RegisterResponse 575 | (*AdminRegisterRequest)(nil), // 2: auth.AdminRegisterRequest 576 | (*AdminRegisterResponse)(nil), // 3: auth.AdminRegisterResponse 577 | (*LoginRequest)(nil), // 4: auth.LoginRequest 578 | (*AdminLoginRequest)(nil), // 5: auth.AdminLoginRequest 579 | (*LoginResponse)(nil), // 6: auth.LoginResponse 580 | (*ValidateRequest)(nil), // 7: auth.ValidateRequest 581 | (*ValidateResponse)(nil), // 8: auth.ValidateResponse 582 | } 583 | var file_internal_pb_auth_proto_depIdxs = []int32{ 584 | 0, // 0: auth.AuthService.Register:input_type -> auth.RegisterRequest 585 | 2, // 1: auth.AuthService.AdminRegister:input_type -> auth.AdminRegisterRequest 586 | 4, // 2: auth.AuthService.Login:input_type -> auth.LoginRequest 587 | 5, // 3: auth.AuthService.AdminLogin:input_type -> auth.AdminLoginRequest 588 | 7, // 4: auth.AuthService.Validate:input_type -> auth.ValidateRequest 589 | 1, // 5: auth.AuthService.Register:output_type -> auth.RegisterResponse 590 | 1, // 6: auth.AuthService.AdminRegister:output_type -> auth.RegisterResponse 591 | 6, // 7: auth.AuthService.Login:output_type -> auth.LoginResponse 592 | 6, // 8: auth.AuthService.AdminLogin:output_type -> auth.LoginResponse 593 | 8, // 9: auth.AuthService.Validate:output_type -> auth.ValidateResponse 594 | 5, // [5:10] is the sub-list for method output_type 595 | 0, // [0:5] is the sub-list for method input_type 596 | 0, // [0:0] is the sub-list for extension type_name 597 | 0, // [0:0] is the sub-list for extension extendee 598 | 0, // [0:0] is the sub-list for field type_name 599 | } 600 | 601 | func init() { file_internal_pb_auth_proto_init() } 602 | func file_internal_pb_auth_proto_init() { 603 | if File_internal_pb_auth_proto != nil { 604 | return 605 | } 606 | type x struct{} 607 | out := protoimpl.TypeBuilder{ 608 | File: protoimpl.DescBuilder{ 609 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 610 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_pb_auth_proto_rawDesc), len(file_internal_pb_auth_proto_rawDesc)), 611 | NumEnums: 0, 612 | NumMessages: 9, 613 | NumExtensions: 0, 614 | NumServices: 1, 615 | }, 616 | GoTypes: file_internal_pb_auth_proto_goTypes, 617 | DependencyIndexes: file_internal_pb_auth_proto_depIdxs, 618 | MessageInfos: file_internal_pb_auth_proto_msgTypes, 619 | }.Build() 620 | File_internal_pb_auth_proto = out.File 621 | file_internal_pb_auth_proto_goTypes = nil 622 | file_internal_pb_auth_proto_depIdxs = nil 623 | } 624 | -------------------------------------------------------------------------------- /api-gateaway/internal/auth/pb/auth.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.36.6 4 | // protoc v5.29.3 5 | // source: internal/auth/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | unsafe "unsafe" 15 | ) 16 | 17 | const ( 18 | // Verify that this generated code is sufficiently up-to-date. 19 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 20 | // Verify that runtime/protoimpl is sufficiently up-to-date. 21 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 22 | ) 23 | 24 | type RegisterRequest struct { 25 | state protoimpl.MessageState `protogen:"open.v1"` 26 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 27 | Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` 28 | Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` 29 | unknownFields protoimpl.UnknownFields 30 | sizeCache protoimpl.SizeCache 31 | } 32 | 33 | func (x *RegisterRequest) Reset() { 34 | *x = RegisterRequest{} 35 | mi := &file_internal_auth_pb_auth_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | 40 | func (x *RegisterRequest) String() string { 41 | return protoimpl.X.MessageStringOf(x) 42 | } 43 | 44 | func (*RegisterRequest) ProtoMessage() {} 45 | 46 | func (x *RegisterRequest) ProtoReflect() protoreflect.Message { 47 | mi := &file_internal_auth_pb_auth_proto_msgTypes[0] 48 | if x != nil { 49 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 50 | if ms.LoadMessageInfo() == nil { 51 | ms.StoreMessageInfo(mi) 52 | } 53 | return ms 54 | } 55 | return mi.MessageOf(x) 56 | } 57 | 58 | // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. 59 | func (*RegisterRequest) Descriptor() ([]byte, []int) { 60 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{0} 61 | } 62 | 63 | func (x *RegisterRequest) GetUsername() string { 64 | if x != nil { 65 | return x.Username 66 | } 67 | return "" 68 | } 69 | 70 | func (x *RegisterRequest) GetEmail() string { 71 | if x != nil { 72 | return x.Email 73 | } 74 | return "" 75 | } 76 | 77 | func (x *RegisterRequest) GetPassword() string { 78 | if x != nil { 79 | return x.Password 80 | } 81 | return "" 82 | } 83 | 84 | type RegisterResponse struct { 85 | state protoimpl.MessageState `protogen:"open.v1"` 86 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 87 | Status int64 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` 88 | Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` 89 | unknownFields protoimpl.UnknownFields 90 | sizeCache protoimpl.SizeCache 91 | } 92 | 93 | func (x *RegisterResponse) Reset() { 94 | *x = RegisterResponse{} 95 | mi := &file_internal_auth_pb_auth_proto_msgTypes[1] 96 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 97 | ms.StoreMessageInfo(mi) 98 | } 99 | 100 | func (x *RegisterResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*RegisterResponse) ProtoMessage() {} 105 | 106 | func (x *RegisterResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_internal_auth_pb_auth_proto_msgTypes[1] 108 | if x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. 119 | func (*RegisterResponse) Descriptor() ([]byte, []int) { 120 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *RegisterResponse) GetId() int64 { 124 | if x != nil { 125 | return x.Id 126 | } 127 | return 0 128 | } 129 | 130 | func (x *RegisterResponse) GetStatus() int64 { 131 | if x != nil { 132 | return x.Status 133 | } 134 | return 0 135 | } 136 | 137 | func (x *RegisterResponse) GetError() string { 138 | if x != nil { 139 | return x.Error 140 | } 141 | return "" 142 | } 143 | 144 | type AdminRegisterRequest struct { 145 | state protoimpl.MessageState `protogen:"open.v1"` 146 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 147 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 148 | unknownFields protoimpl.UnknownFields 149 | sizeCache protoimpl.SizeCache 150 | } 151 | 152 | func (x *AdminRegisterRequest) Reset() { 153 | *x = AdminRegisterRequest{} 154 | mi := &file_internal_auth_pb_auth_proto_msgTypes[2] 155 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 156 | ms.StoreMessageInfo(mi) 157 | } 158 | 159 | func (x *AdminRegisterRequest) String() string { 160 | return protoimpl.X.MessageStringOf(x) 161 | } 162 | 163 | func (*AdminRegisterRequest) ProtoMessage() {} 164 | 165 | func (x *AdminRegisterRequest) ProtoReflect() protoreflect.Message { 166 | mi := &file_internal_auth_pb_auth_proto_msgTypes[2] 167 | if x != nil { 168 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 169 | if ms.LoadMessageInfo() == nil { 170 | ms.StoreMessageInfo(mi) 171 | } 172 | return ms 173 | } 174 | return mi.MessageOf(x) 175 | } 176 | 177 | // Deprecated: Use AdminRegisterRequest.ProtoReflect.Descriptor instead. 178 | func (*AdminRegisterRequest) Descriptor() ([]byte, []int) { 179 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{2} 180 | } 181 | 182 | func (x *AdminRegisterRequest) GetUsername() string { 183 | if x != nil { 184 | return x.Username 185 | } 186 | return "" 187 | } 188 | 189 | func (x *AdminRegisterRequest) GetPassword() string { 190 | if x != nil { 191 | return x.Password 192 | } 193 | return "" 194 | } 195 | 196 | type AdminRegisterResponse struct { 197 | state protoimpl.MessageState `protogen:"open.v1"` 198 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 199 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 200 | unknownFields protoimpl.UnknownFields 201 | sizeCache protoimpl.SizeCache 202 | } 203 | 204 | func (x *AdminRegisterResponse) Reset() { 205 | *x = AdminRegisterResponse{} 206 | mi := &file_internal_auth_pb_auth_proto_msgTypes[3] 207 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 208 | ms.StoreMessageInfo(mi) 209 | } 210 | 211 | func (x *AdminRegisterResponse) String() string { 212 | return protoimpl.X.MessageStringOf(x) 213 | } 214 | 215 | func (*AdminRegisterResponse) ProtoMessage() {} 216 | 217 | func (x *AdminRegisterResponse) ProtoReflect() protoreflect.Message { 218 | mi := &file_internal_auth_pb_auth_proto_msgTypes[3] 219 | if x != nil { 220 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 221 | if ms.LoadMessageInfo() == nil { 222 | ms.StoreMessageInfo(mi) 223 | } 224 | return ms 225 | } 226 | return mi.MessageOf(x) 227 | } 228 | 229 | // Deprecated: Use AdminRegisterResponse.ProtoReflect.Descriptor instead. 230 | func (*AdminRegisterResponse) Descriptor() ([]byte, []int) { 231 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{3} 232 | } 233 | 234 | func (x *AdminRegisterResponse) GetUsername() string { 235 | if x != nil { 236 | return x.Username 237 | } 238 | return "" 239 | } 240 | 241 | func (x *AdminRegisterResponse) GetPassword() string { 242 | if x != nil { 243 | return x.Password 244 | } 245 | return "" 246 | } 247 | 248 | type LoginRequest struct { 249 | state protoimpl.MessageState `protogen:"open.v1"` 250 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 251 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 252 | unknownFields protoimpl.UnknownFields 253 | sizeCache protoimpl.SizeCache 254 | } 255 | 256 | func (x *LoginRequest) Reset() { 257 | *x = LoginRequest{} 258 | mi := &file_internal_auth_pb_auth_proto_msgTypes[4] 259 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 260 | ms.StoreMessageInfo(mi) 261 | } 262 | 263 | func (x *LoginRequest) String() string { 264 | return protoimpl.X.MessageStringOf(x) 265 | } 266 | 267 | func (*LoginRequest) ProtoMessage() {} 268 | 269 | func (x *LoginRequest) ProtoReflect() protoreflect.Message { 270 | mi := &file_internal_auth_pb_auth_proto_msgTypes[4] 271 | if x != nil { 272 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 273 | if ms.LoadMessageInfo() == nil { 274 | ms.StoreMessageInfo(mi) 275 | } 276 | return ms 277 | } 278 | return mi.MessageOf(x) 279 | } 280 | 281 | // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. 282 | func (*LoginRequest) Descriptor() ([]byte, []int) { 283 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{4} 284 | } 285 | 286 | func (x *LoginRequest) GetEmail() string { 287 | if x != nil { 288 | return x.Email 289 | } 290 | return "" 291 | } 292 | 293 | func (x *LoginRequest) GetPassword() string { 294 | if x != nil { 295 | return x.Password 296 | } 297 | return "" 298 | } 299 | 300 | type AdminLoginRequest struct { 301 | state protoimpl.MessageState `protogen:"open.v1"` 302 | Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` 303 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 304 | unknownFields protoimpl.UnknownFields 305 | sizeCache protoimpl.SizeCache 306 | } 307 | 308 | func (x *AdminLoginRequest) Reset() { 309 | *x = AdminLoginRequest{} 310 | mi := &file_internal_auth_pb_auth_proto_msgTypes[5] 311 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 312 | ms.StoreMessageInfo(mi) 313 | } 314 | 315 | func (x *AdminLoginRequest) String() string { 316 | return protoimpl.X.MessageStringOf(x) 317 | } 318 | 319 | func (*AdminLoginRequest) ProtoMessage() {} 320 | 321 | func (x *AdminLoginRequest) ProtoReflect() protoreflect.Message { 322 | mi := &file_internal_auth_pb_auth_proto_msgTypes[5] 323 | if x != nil { 324 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 325 | if ms.LoadMessageInfo() == nil { 326 | ms.StoreMessageInfo(mi) 327 | } 328 | return ms 329 | } 330 | return mi.MessageOf(x) 331 | } 332 | 333 | // Deprecated: Use AdminLoginRequest.ProtoReflect.Descriptor instead. 334 | func (*AdminLoginRequest) Descriptor() ([]byte, []int) { 335 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{5} 336 | } 337 | 338 | func (x *AdminLoginRequest) GetUsername() string { 339 | if x != nil { 340 | return x.Username 341 | } 342 | return "" 343 | } 344 | 345 | func (x *AdminLoginRequest) GetPassword() string { 346 | if x != nil { 347 | return x.Password 348 | } 349 | return "" 350 | } 351 | 352 | type LoginResponse struct { 353 | state protoimpl.MessageState `protogen:"open.v1"` 354 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 355 | Status int64 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` 356 | Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"` 357 | unknownFields protoimpl.UnknownFields 358 | sizeCache protoimpl.SizeCache 359 | } 360 | 361 | func (x *LoginResponse) Reset() { 362 | *x = LoginResponse{} 363 | mi := &file_internal_auth_pb_auth_proto_msgTypes[6] 364 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 365 | ms.StoreMessageInfo(mi) 366 | } 367 | 368 | func (x *LoginResponse) String() string { 369 | return protoimpl.X.MessageStringOf(x) 370 | } 371 | 372 | func (*LoginResponse) ProtoMessage() {} 373 | 374 | func (x *LoginResponse) ProtoReflect() protoreflect.Message { 375 | mi := &file_internal_auth_pb_auth_proto_msgTypes[6] 376 | if x != nil { 377 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 378 | if ms.LoadMessageInfo() == nil { 379 | ms.StoreMessageInfo(mi) 380 | } 381 | return ms 382 | } 383 | return mi.MessageOf(x) 384 | } 385 | 386 | // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. 387 | func (*LoginResponse) Descriptor() ([]byte, []int) { 388 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{6} 389 | } 390 | 391 | func (x *LoginResponse) GetToken() string { 392 | if x != nil { 393 | return x.Token 394 | } 395 | return "" 396 | } 397 | 398 | func (x *LoginResponse) GetStatus() int64 { 399 | if x != nil { 400 | return x.Status 401 | } 402 | return 0 403 | } 404 | 405 | func (x *LoginResponse) GetError() string { 406 | if x != nil { 407 | return x.Error 408 | } 409 | return "" 410 | } 411 | 412 | type ValidateRequest struct { 413 | state protoimpl.MessageState `protogen:"open.v1"` 414 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 415 | unknownFields protoimpl.UnknownFields 416 | sizeCache protoimpl.SizeCache 417 | } 418 | 419 | func (x *ValidateRequest) Reset() { 420 | *x = ValidateRequest{} 421 | mi := &file_internal_auth_pb_auth_proto_msgTypes[7] 422 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 423 | ms.StoreMessageInfo(mi) 424 | } 425 | 426 | func (x *ValidateRequest) String() string { 427 | return protoimpl.X.MessageStringOf(x) 428 | } 429 | 430 | func (*ValidateRequest) ProtoMessage() {} 431 | 432 | func (x *ValidateRequest) ProtoReflect() protoreflect.Message { 433 | mi := &file_internal_auth_pb_auth_proto_msgTypes[7] 434 | if x != nil { 435 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 436 | if ms.LoadMessageInfo() == nil { 437 | ms.StoreMessageInfo(mi) 438 | } 439 | return ms 440 | } 441 | return mi.MessageOf(x) 442 | } 443 | 444 | // Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead. 445 | func (*ValidateRequest) Descriptor() ([]byte, []int) { 446 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{7} 447 | } 448 | 449 | func (x *ValidateRequest) GetToken() string { 450 | if x != nil { 451 | return x.Token 452 | } 453 | return "" 454 | } 455 | 456 | type ValidateResponse struct { 457 | state protoimpl.MessageState `protogen:"open.v1"` 458 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 459 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 460 | UserID int64 `protobuf:"varint,3,opt,name=userID,proto3" json:"userID,omitempty"` 461 | unknownFields protoimpl.UnknownFields 462 | sizeCache protoimpl.SizeCache 463 | } 464 | 465 | func (x *ValidateResponse) Reset() { 466 | *x = ValidateResponse{} 467 | mi := &file_internal_auth_pb_auth_proto_msgTypes[8] 468 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 469 | ms.StoreMessageInfo(mi) 470 | } 471 | 472 | func (x *ValidateResponse) String() string { 473 | return protoimpl.X.MessageStringOf(x) 474 | } 475 | 476 | func (*ValidateResponse) ProtoMessage() {} 477 | 478 | func (x *ValidateResponse) ProtoReflect() protoreflect.Message { 479 | mi := &file_internal_auth_pb_auth_proto_msgTypes[8] 480 | if x != nil { 481 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 482 | if ms.LoadMessageInfo() == nil { 483 | ms.StoreMessageInfo(mi) 484 | } 485 | return ms 486 | } 487 | return mi.MessageOf(x) 488 | } 489 | 490 | // Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead. 491 | func (*ValidateResponse) Descriptor() ([]byte, []int) { 492 | return file_internal_auth_pb_auth_proto_rawDescGZIP(), []int{8} 493 | } 494 | 495 | func (x *ValidateResponse) GetStatus() int64 { 496 | if x != nil { 497 | return x.Status 498 | } 499 | return 0 500 | } 501 | 502 | func (x *ValidateResponse) GetError() string { 503 | if x != nil { 504 | return x.Error 505 | } 506 | return "" 507 | } 508 | 509 | func (x *ValidateResponse) GetUserID() int64 { 510 | if x != nil { 511 | return x.UserID 512 | } 513 | return 0 514 | } 515 | 516 | var File_internal_auth_pb_auth_proto protoreflect.FileDescriptor 517 | 518 | const file_internal_auth_pb_auth_proto_rawDesc = "" + 519 | "\n" + 520 | "\x1binternal/auth/pb/auth.proto\x12\x04auth\"_\n" + 521 | "\x0fRegisterRequest\x12\x1a\n" + 522 | "\busername\x18\x01 \x01(\tR\busername\x12\x14\n" + 523 | "\x05email\x18\x02 \x01(\tR\x05email\x12\x1a\n" + 524 | "\bpassword\x18\x03 \x01(\tR\bpassword\"P\n" + 525 | "\x10RegisterResponse\x12\x0e\n" + 526 | "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + 527 | "\x06status\x18\x02 \x01(\x03R\x06status\x12\x14\n" + 528 | "\x05error\x18\x03 \x01(\tR\x05error\"N\n" + 529 | "\x14AdminRegisterRequest\x12\x1a\n" + 530 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 531 | "\bpassword\x18\x02 \x01(\tR\bpassword\"O\n" + 532 | "\x15AdminRegisterResponse\x12\x1a\n" + 533 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 534 | "\bpassword\x18\x02 \x01(\tR\bpassword\"@\n" + 535 | "\fLoginRequest\x12\x14\n" + 536 | "\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" + 537 | "\bpassword\x18\x02 \x01(\tR\bpassword\"K\n" + 538 | "\x11AdminLoginRequest\x12\x1a\n" + 539 | "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + 540 | "\bpassword\x18\x02 \x01(\tR\bpassword\"S\n" + 541 | "\rLoginResponse\x12\x14\n" + 542 | "\x05token\x18\x01 \x01(\tR\x05token\x12\x16\n" + 543 | "\x06status\x18\x02 \x01(\x03R\x06status\x12\x14\n" + 544 | "\x05error\x18\x03 \x01(\tR\x05error\"'\n" + 545 | "\x0fValidateRequest\x12\x14\n" + 546 | "\x05token\x18\x01 \x01(\tR\x05token\"X\n" + 547 | "\x10ValidateResponse\x12\x16\n" + 548 | "\x06status\x18\x01 \x01(\x03R\x06status\x12\x14\n" + 549 | "\x05error\x18\x02 \x01(\tR\x05error\x12\x16\n" + 550 | "\x06userID\x18\x03 \x01(\x03R\x06userID2\xb6\x02\n" + 551 | "\vAuthService\x129\n" + 552 | "\bRegister\x12\x15.auth.RegisterRequest\x1a\x16.auth.RegisterResponse\x12C\n" + 553 | "\rAdminRegister\x12\x1a.auth.AdminRegisterRequest\x1a\x16.auth.RegisterResponse\x120\n" + 554 | "\x05Login\x12\x12.auth.LoginRequest\x1a\x13.auth.LoginResponse\x12:\n" + 555 | "\n" + 556 | "AdminLogin\x12\x17.auth.AdminLoginRequest\x1a\x13.auth.LoginResponse\x129\n" + 557 | "\bValidate\x12\x15.auth.ValidateRequest\x1a\x16.auth.ValidateResponseB\x14Z\x12./internal/auth/pbb\x06proto3" 558 | 559 | var ( 560 | file_internal_auth_pb_auth_proto_rawDescOnce sync.Once 561 | file_internal_auth_pb_auth_proto_rawDescData []byte 562 | ) 563 | 564 | func file_internal_auth_pb_auth_proto_rawDescGZIP() []byte { 565 | file_internal_auth_pb_auth_proto_rawDescOnce.Do(func() { 566 | file_internal_auth_pb_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_auth_pb_auth_proto_rawDesc), len(file_internal_auth_pb_auth_proto_rawDesc))) 567 | }) 568 | return file_internal_auth_pb_auth_proto_rawDescData 569 | } 570 | 571 | var file_internal_auth_pb_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 9) 572 | var file_internal_auth_pb_auth_proto_goTypes = []any{ 573 | (*RegisterRequest)(nil), // 0: auth.RegisterRequest 574 | (*RegisterResponse)(nil), // 1: auth.RegisterResponse 575 | (*AdminRegisterRequest)(nil), // 2: auth.AdminRegisterRequest 576 | (*AdminRegisterResponse)(nil), // 3: auth.AdminRegisterResponse 577 | (*LoginRequest)(nil), // 4: auth.LoginRequest 578 | (*AdminLoginRequest)(nil), // 5: auth.AdminLoginRequest 579 | (*LoginResponse)(nil), // 6: auth.LoginResponse 580 | (*ValidateRequest)(nil), // 7: auth.ValidateRequest 581 | (*ValidateResponse)(nil), // 8: auth.ValidateResponse 582 | } 583 | var file_internal_auth_pb_auth_proto_depIdxs = []int32{ 584 | 0, // 0: auth.AuthService.Register:input_type -> auth.RegisterRequest 585 | 2, // 1: auth.AuthService.AdminRegister:input_type -> auth.AdminRegisterRequest 586 | 4, // 2: auth.AuthService.Login:input_type -> auth.LoginRequest 587 | 5, // 3: auth.AuthService.AdminLogin:input_type -> auth.AdminLoginRequest 588 | 7, // 4: auth.AuthService.Validate:input_type -> auth.ValidateRequest 589 | 1, // 5: auth.AuthService.Register:output_type -> auth.RegisterResponse 590 | 1, // 6: auth.AuthService.AdminRegister:output_type -> auth.RegisterResponse 591 | 6, // 7: auth.AuthService.Login:output_type -> auth.LoginResponse 592 | 6, // 8: auth.AuthService.AdminLogin:output_type -> auth.LoginResponse 593 | 8, // 9: auth.AuthService.Validate:output_type -> auth.ValidateResponse 594 | 5, // [5:10] is the sub-list for method output_type 595 | 0, // [0:5] is the sub-list for method input_type 596 | 0, // [0:0] is the sub-list for extension type_name 597 | 0, // [0:0] is the sub-list for extension extendee 598 | 0, // [0:0] is the sub-list for field type_name 599 | } 600 | 601 | func init() { file_internal_auth_pb_auth_proto_init() } 602 | func file_internal_auth_pb_auth_proto_init() { 603 | if File_internal_auth_pb_auth_proto != nil { 604 | return 605 | } 606 | type x struct{} 607 | out := protoimpl.TypeBuilder{ 608 | File: protoimpl.DescBuilder{ 609 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 610 | RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_auth_pb_auth_proto_rawDesc), len(file_internal_auth_pb_auth_proto_rawDesc)), 611 | NumEnums: 0, 612 | NumMessages: 9, 613 | NumExtensions: 0, 614 | NumServices: 1, 615 | }, 616 | GoTypes: file_internal_auth_pb_auth_proto_goTypes, 617 | DependencyIndexes: file_internal_auth_pb_auth_proto_depIdxs, 618 | MessageInfos: file_internal_auth_pb_auth_proto_msgTypes, 619 | }.Build() 620 | File_internal_auth_pb_auth_proto = out.File 621 | file_internal_auth_pb_auth_proto_goTypes = nil 622 | file_internal_auth_pb_auth_proto_depIdxs = nil 623 | } 624 | --------------------------------------------------------------------------------