feat: make file (#1)
Co-authored-by: daniel.w <daniel.w@intteam.net> Reviewed-on: #1
This commit is contained in:
parent
4790a6439d
commit
d72993368e
|
@ -0,0 +1,37 @@
|
||||||
|
GO_CTL_NAME=goctl
|
||||||
|
|
||||||
|
|
||||||
|
# go-zero 生成風格
|
||||||
|
GO_ZERO_STYLE=go_zero
|
||||||
|
|
||||||
|
GO ?= go
|
||||||
|
GOFMT ?= gofmt "-s"
|
||||||
|
GOFILES := $(shell find . -name "*.go")
|
||||||
|
LDFLAGS := -s -w
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: # 進行測試
|
||||||
|
go test -v --cover ./...
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt: # 格式優化
|
||||||
|
$(GOFMT) -w $(GOFILES)
|
||||||
|
goimports -w ./
|
||||||
|
|
||||||
|
.PHONY: gen-rpc
|
||||||
|
gen-rpc: # 建立 rpc code
|
||||||
|
$(GO_CTL_NAME) rpc protoc ./generate/protobuf/service.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
||||||
|
copy ./etc/service.yaml ./etc/service.example.yaml
|
||||||
|
go mod tidy
|
||||||
|
@echo "Generate core-api files successfully"
|
||||||
|
|
||||||
|
.PHONY: gen-clean
|
||||||
|
gen-clean: # 建立 rpc code
|
||||||
|
rm -rf ./client
|
||||||
|
rm -rf ./etc
|
||||||
|
rm -rf ./gen_result
|
||||||
|
rm -rf ./internal
|
||||||
|
rm -rf go.mod
|
||||||
|
rm -rf go.sum
|
||||||
|
rm -rf service.go
|
||||||
|
@echo "Generate core-api files successfully"
|
|
@ -0,0 +1,66 @@
|
||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// Source: service.proto
|
||||||
|
|
||||||
|
package senderservice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/zrpc"
|
||||||
|
"google.golang.org/grpc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
NoneReq = notification.NoneReq
|
||||||
|
OKResp = notification.OKResp
|
||||||
|
SendByTemplateIDReq = notification.SendByTemplateIDReq
|
||||||
|
SendMailReq = notification.SendMailReq
|
||||||
|
SendSMSReq = notification.SendSMSReq
|
||||||
|
|
||||||
|
SenderService interface {
|
||||||
|
// SendMail 寄信
|
||||||
|
SendMail(ctx context.Context, in *SendMailReq, opts ...grpc.CallOption) (*OKResp, error)
|
||||||
|
// SendSMS 寄簡訊
|
||||||
|
SendSms(ctx context.Context, in *SendSMSReq, opts ...grpc.CallOption) (*OKResp, error)
|
||||||
|
// SendMailByTemplateID 寄送模板信件
|
||||||
|
SendMailByTemplateId(ctx context.Context, in *SendByTemplateIDReq, opts ...grpc.CallOption) (*OKResp, error)
|
||||||
|
// SendSMSByTemplateID 寄送模板簡訊
|
||||||
|
SendSmsByTemplateId(ctx context.Context, in *SendByTemplateIDReq, opts ...grpc.CallOption) (*OKResp, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultSenderService struct {
|
||||||
|
cli zrpc.Client
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewSenderService(cli zrpc.Client) SenderService {
|
||||||
|
return &defaultSenderService{
|
||||||
|
cli: cli,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMail 寄信
|
||||||
|
func (m *defaultSenderService) SendMail(ctx context.Context, in *SendMailReq, opts ...grpc.CallOption) (*OKResp, error) {
|
||||||
|
client := notification.NewSenderServiceClient(m.cli.Conn())
|
||||||
|
return client.SendMail(ctx, in, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMS 寄簡訊
|
||||||
|
func (m *defaultSenderService) SendSms(ctx context.Context, in *SendSMSReq, opts ...grpc.CallOption) (*OKResp, error) {
|
||||||
|
client := notification.NewSenderServiceClient(m.cli.Conn())
|
||||||
|
return client.SendSms(ctx, in, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMailByTemplateID 寄送模板信件
|
||||||
|
func (m *defaultSenderService) SendMailByTemplateId(ctx context.Context, in *SendByTemplateIDReq, opts ...grpc.CallOption) (*OKResp, error) {
|
||||||
|
client := notification.NewSenderServiceClient(m.cli.Conn())
|
||||||
|
return client.SendMailByTemplateId(ctx, in, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMSByTemplateID 寄送模板簡訊
|
||||||
|
func (m *defaultSenderService) SendSmsByTemplateId(ctx context.Context, in *SendByTemplateIDReq, opts ...grpc.CallOption) (*OKResp, error) {
|
||||||
|
client := notification.NewSenderServiceClient(m.cli.Conn())
|
||||||
|
return client.SendSmsByTemplateId(ctx, in, opts...)
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
Name: service.rpc
|
||||||
|
ListenOn: 0.0.0.0:8080
|
||||||
|
Etcd:
|
||||||
|
Hosts:
|
||||||
|
- 127.0.0.1:2379
|
||||||
|
Key: service.rpc
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
## 安裝 make
|
## 安裝 make
|
||||||
```shell
|
```shell
|
||||||
brew install makefile
|
brew install Makefile
|
||||||
```
|
```
|
||||||
|
|
||||||
## 安裝 golang-migrate
|
## 安裝 golang-migrate
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
syntax = "proto3";
|
|
||||||
|
|
||||||
package "app-cloudep-notification-service";
|
|
||||||
|
|
||||||
option go_package="./app-cloudep-notification-service";
|
|
||||||
|
|
||||||
// OKResp
|
|
||||||
message OKResp {}
|
|
||||||
// NoneReq
|
|
||||||
message NoneReq {}
|
|
||||||
|
|
||||||
|
|
||||||
// DemoService ...
|
|
||||||
service NotificationService {
|
|
||||||
// Ping ...
|
|
||||||
rpc Ping(OKResp)returns(NoneReq);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package notification;
|
||||||
|
|
||||||
|
option go_package="./notification";
|
||||||
|
|
||||||
|
// OKResp
|
||||||
|
message OKResp {}
|
||||||
|
// NoneReq
|
||||||
|
message NoneReq {}
|
||||||
|
|
||||||
|
message SendMailReq {
|
||||||
|
string to = 1;
|
||||||
|
string subject = 2;
|
||||||
|
string body = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendSMSReq {
|
||||||
|
string to = 1;
|
||||||
|
string body = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SendByTemplateIDReq {
|
||||||
|
string to = 1;
|
||||||
|
string template_id =2;
|
||||||
|
string lang=3;
|
||||||
|
map<string, string> content_data = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
service SenderService {
|
||||||
|
// SendMail 寄信
|
||||||
|
rpc SendMail(SendMailReq) returns(OKResp);
|
||||||
|
// SendSMS 寄簡訊
|
||||||
|
rpc SendSms(SendSMSReq) returns(OKResp);
|
||||||
|
// SendMailByTemplateID 寄送模板信件
|
||||||
|
rpc SendMailByTemplateId(SendByTemplateIDReq) returns(OKResp);
|
||||||
|
// SendSMSByTemplateID 寄送模板簡訊
|
||||||
|
rpc SendSmsByTemplateId(SendByTemplateIDReq) returns(OKResp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
module app-cloudep-notification-service
|
||||||
|
|
||||||
|
go 1.22.3
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/zeromicro/go-zero v1.7.0
|
||||||
|
google.golang.org/grpc v1.65.0
|
||||||
|
google.golang.org/protobuf v1.34.2
|
||||||
|
)
|
||||||
|
|
||||||
|
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.17.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/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.19.1 // indirect
|
||||||
|
github.com/prometheus/client_model v0.5.0 // indirect
|
||||||
|
github.com/prometheus/common v0.48.0 // indirect
|
||||||
|
github.com/prometheus/procfs v0.12.0 // indirect
|
||||||
|
github.com/redis/go-redis/v9 v9.6.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/otel v1.24.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.24.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/sdk v1.24.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
|
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
|
||||||
|
go.uber.org/atomic v1.10.0 // indirect
|
||||||
|
go.uber.org/automaxprocs v1.5.3 // indirect
|
||||||
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
|
go.uber.org/zap v1.24.0 // indirect
|
||||||
|
golang.org/x/net v0.27.0 // indirect
|
||||||
|
golang.org/x/oauth2 v0.20.0 // indirect
|
||||||
|
golang.org/x/sys v0.22.0 // indirect
|
||||||
|
golang.org/x/term v0.22.0 // indirect
|
||||||
|
golang.org/x/text v0.16.0 // indirect
|
||||||
|
golang.org/x/time v0.5.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // 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 senderservicelogic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendMailByTemplateIdLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSendMailByTemplateIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMailByTemplateIdLogic {
|
||||||
|
return &SendMailByTemplateIdLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMailByTemplateID 寄送模板信件
|
||||||
|
func (l *SendMailByTemplateIdLogic) SendMailByTemplateId(in *notification.SendByTemplateIDReq) (*notification.OKResp, error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return ¬ification.OKResp{}, nil
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package senderservicelogic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendMailLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMailLogic {
|
||||||
|
return &SendMailLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMail 寄信
|
||||||
|
func (l *SendMailLogic) SendMail(in *notification.SendMailReq) (*notification.OKResp, error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return ¬ification.OKResp{}, nil
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package senderservicelogic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendSmsByTemplateIdLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSendSmsByTemplateIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsByTemplateIdLogic {
|
||||||
|
return &SendSmsByTemplateIdLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMSByTemplateID 寄送模板簡訊
|
||||||
|
func (l *SendSmsByTemplateIdLogic) SendSmsByTemplateId(in *notification.SendByTemplateIDReq) (*notification.OKResp, error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return ¬ification.OKResp{}, nil
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package senderservicelogic
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/svc"
|
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SendSmsLogic struct {
|
||||||
|
ctx context.Context
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
logx.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLogic {
|
||||||
|
return &SendSmsLogic{
|
||||||
|
ctx: ctx,
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
Logger: logx.WithContext(ctx),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMS 寄簡訊
|
||||||
|
func (l *SendSmsLogic) SendSms(in *notification.SendSMSReq) (*notification.OKResp, error) {
|
||||||
|
// todo: add your logic here and delete this line
|
||||||
|
|
||||||
|
return ¬ification.OKResp{}, nil
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// Source: service.proto
|
||||||
|
|
||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/logic/senderservice"
|
||||||
|
"app-cloudep-notification-service/internal/svc"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SenderServiceServer struct {
|
||||||
|
svcCtx *svc.ServiceContext
|
||||||
|
notification.UnimplementedSenderServiceServer
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSenderServiceServer(svcCtx *svc.ServiceContext) *SenderServiceServer {
|
||||||
|
return &SenderServiceServer{
|
||||||
|
svcCtx: svcCtx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMail 寄信
|
||||||
|
func (s *SenderServiceServer) SendMail(ctx context.Context, in *notification.SendMailReq) (*notification.OKResp, error) {
|
||||||
|
l := senderservicelogic.NewSendMailLogic(ctx, s.svcCtx)
|
||||||
|
return l.SendMail(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMS 寄簡訊
|
||||||
|
func (s *SenderServiceServer) SendSms(ctx context.Context, in *notification.SendSMSReq) (*notification.OKResp, error) {
|
||||||
|
l := senderservicelogic.NewSendSmsLogic(ctx, s.svcCtx)
|
||||||
|
return l.SendSms(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendMailByTemplateID 寄送模板信件
|
||||||
|
func (s *SenderServiceServer) SendMailByTemplateId(ctx context.Context, in *notification.SendByTemplateIDReq) (*notification.OKResp, error) {
|
||||||
|
l := senderservicelogic.NewSendMailByTemplateIdLogic(ctx, s.svcCtx)
|
||||||
|
return l.SendMailByTemplateId(in)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendSMSByTemplateID 寄送模板簡訊
|
||||||
|
func (s *SenderServiceServer) SendSmsByTemplateId(ctx context.Context, in *notification.SendByTemplateIDReq) (*notification.OKResp, error) {
|
||||||
|
l := senderservicelogic.NewSendSmsByTemplateIdLogic(ctx, s.svcCtx)
|
||||||
|
return l.SendSmsByTemplateId(in)
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package svc
|
||||||
|
|
||||||
|
import "app-cloudep-notification-service/internal/config"
|
||||||
|
|
||||||
|
type ServiceContext struct {
|
||||||
|
Config config.Config
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServiceContext(c config.Config) *ServiceContext {
|
||||||
|
return &ServiceContext{
|
||||||
|
Config: c,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"app-cloudep-notification-service/gen_result/pb/notification"
|
||||||
|
"app-cloudep-notification-service/internal/config"
|
||||||
|
senderserviceServer "app-cloudep-notification-service/internal/server/senderservice"
|
||||||
|
"app-cloudep-notification-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/service.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) {
|
||||||
|
notification.RegisterSenderServiceServer(grpcServer, senderserviceServer.NewSenderServiceServer(ctx))
|
||||||
|
|
||||||
|
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
||||||
|
reflection.Register(grpcServer)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
defer s.Stop()
|
||||||
|
|
||||||
|
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
||||||
|
s.Start()
|
||||||
|
}
|
Loading…
Reference in New Issue