feat: init project
This commit is contained in:
parent
039677b15b
commit
0c1009dddb
|
@ -0,0 +1,6 @@
|
|||
Name: order.rpc
|
||||
ListenOn: 0.0.0.0:8080
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: order.rpc
|
|
@ -0,0 +1,90 @@
|
|||
module code.30cm.net/digimon/app-cloudep-order-service
|
||||
|
||||
go 1.24.1
|
||||
|
||||
require (
|
||||
github.com/zeromicro/go-zero v1.8.1
|
||||
google.golang.org/grpc v1.71.0
|
||||
google.golang.org/protobuf v1.36.6
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/swag v0.22.4 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.4 // indirect
|
||||
github.com/google/gnostic-models v0.6.8 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/prometheus/client_golang v1.21.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/redis/go-redis/v9 v9.7.1 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.15 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.15 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.24.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.34.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.34.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/automaxprocs v1.6.0 // indirect
|
||||
go.uber.org/multierr v1.9.0 // indirect
|
||||
go.uber.org/zap v1.24.0 // indirect
|
||||
golang.org/x/net v0.35.0 // indirect
|
||||
golang.org/x/oauth2 v0.25.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/time v0.10.0 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250106144421-5f5ef82da422 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.29.3 // indirect
|
||||
k8s.io/apimachinery v0.29.4 // indirect
|
||||
k8s.io/client-go v0.29.3 // indirect
|
||||
k8s.io/klog/v2 v2.110.1 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
|
||||
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
|
||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||
)
|
|
@ -0,0 +1,7 @@
|
|||
package config
|
||||
|
||||
import "github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
type Config struct {
|
||||
zrpc.RpcServerConf
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CancelOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCancelOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelOrderLogic {
|
||||
return &CancelOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// CancelOrder 取消訂單
|
||||
func (l *CancelOrderLogic) CancelOrder(in *order.CancelOrderReq) (*order.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateOrderLogic {
|
||||
return &CreateOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// CreateOrder 建立訂單
|
||||
func (l *CreateOrderLogic) CreateOrder(in *order.CreateOrderReq) (*order.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOrderLogic {
|
||||
return &DeleteOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteOrder 刪除訂單(軟刪除)
|
||||
func (l *DeleteOrderLogic) DeleteOrder(in *order.DeleteOrderReq) (*order.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetOrderLogic {
|
||||
return &GetOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetOrder 取得訂單詳情
|
||||
func (l *GetOrderLogic) GetOrder(in *order.GetOrderReq) (*order.GetOrderResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.GetOrderResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListOrderLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListOrderLogic {
|
||||
return &ListOrderLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListOrder 取得訂單列表
|
||||
func (l *ListOrderLogic) ListOrder(in *order.ListOrderReq) (*order.ListOrderResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.ListOrderResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ModifyOrderStatusLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewModifyOrderStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ModifyOrderStatusLogic {
|
||||
return &ModifyOrderStatusLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ModifyOrderStatus 修改訂單狀態
|
||||
func (l *ModifyOrderStatusLogic) ModifyOrderStatus(in *order.ModifyOrderStatusReq) (*order.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package orderservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type OrderStatusTimeoutLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewOrderStatusTimeoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderStatusTimeoutLogic {
|
||||
return &OrderStatusTimeoutLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// OrderStatusTimeout 訂單超時任務/cron/order-status/timeout
|
||||
func (l *OrderStatusTimeoutLogic) OrderStatusTimeout(in *order.OrderStatusTimeoutReq) (*order.OKResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &order.OKResp{}, nil
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.8.1
|
||||
// Source: order.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/logic/orderservice"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
)
|
||||
|
||||
type OrderServiceServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
order.UnimplementedOrderServiceServer
|
||||
}
|
||||
|
||||
func NewOrderServiceServer(svcCtx *svc.ServiceContext) *OrderServiceServer {
|
||||
return &OrderServiceServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// CreateOrder 建立訂單
|
||||
func (s *OrderServiceServer) CreateOrder(ctx context.Context, in *order.CreateOrderReq) (*order.OKResp, error) {
|
||||
l := orderservicelogic.NewCreateOrderLogic(ctx, s.svcCtx)
|
||||
return l.CreateOrder(in)
|
||||
}
|
||||
|
||||
// CancelOrder 取消訂單
|
||||
func (s *OrderServiceServer) CancelOrder(ctx context.Context, in *order.CancelOrderReq) (*order.OKResp, error) {
|
||||
l := orderservicelogic.NewCancelOrderLogic(ctx, s.svcCtx)
|
||||
return l.CancelOrder(in)
|
||||
}
|
||||
|
||||
// ModifyOrderStatus 修改訂單狀態
|
||||
func (s *OrderServiceServer) ModifyOrderStatus(ctx context.Context, in *order.ModifyOrderStatusReq) (*order.OKResp, error) {
|
||||
l := orderservicelogic.NewModifyOrderStatusLogic(ctx, s.svcCtx)
|
||||
return l.ModifyOrderStatus(in)
|
||||
}
|
||||
|
||||
// DeleteOrder 刪除訂單(軟刪除)
|
||||
func (s *OrderServiceServer) DeleteOrder(ctx context.Context, in *order.DeleteOrderReq) (*order.OKResp, error) {
|
||||
l := orderservicelogic.NewDeleteOrderLogic(ctx, s.svcCtx)
|
||||
return l.DeleteOrder(in)
|
||||
}
|
||||
|
||||
// GetOrder 取得訂單詳情
|
||||
func (s *OrderServiceServer) GetOrder(ctx context.Context, in *order.GetOrderReq) (*order.GetOrderResp, error) {
|
||||
l := orderservicelogic.NewGetOrderLogic(ctx, s.svcCtx)
|
||||
return l.GetOrder(in)
|
||||
}
|
||||
|
||||
// ListOrder 取得訂單列表
|
||||
func (s *OrderServiceServer) ListOrder(ctx context.Context, in *order.ListOrderReq) (*order.ListOrderResp, error) {
|
||||
l := orderservicelogic.NewListOrderLogic(ctx, s.svcCtx)
|
||||
return l.ListOrder(in)
|
||||
}
|
||||
|
||||
// OrderStatusTimeout 訂單超時任務/cron/order-status/timeout
|
||||
func (s *OrderServiceServer) OrderStatusTimeout(ctx context.Context, in *order.OrderStatusTimeoutReq) (*order.OKResp, error) {
|
||||
l := orderservicelogic.NewOrderStatusTimeoutLogic(ctx, s.svcCtx)
|
||||
return l.OrderStatusTimeout(in)
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package svc
|
||||
|
||||
import "code.30cm.net/digimon/app-cloudep-order-service/internal/config"
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/gen_result/pb/order"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/config"
|
||||
orderserviceServer "code.30cm.net/digimon/app-cloudep-order-service/internal/server/orderservice"
|
||||
"code.30cm.net/digimon/app-cloudep-order-service/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/order.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
order.RegisterOrderServiceServer(grpcServer, orderserviceServer.NewOrderServiceServer(ctx))
|
||||
|
||||
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
||||
reflection.Register(grpcServer)
|
||||
}
|
||||
})
|
||||
defer s.Stop()
|
||||
|
||||
logx.Infof("Starting rpc server at %s...\n", c.ListenOn)
|
||||
s.Start()
|
||||
}
|
Loading…
Reference in New Issue