|
|
|
@ -79,7 +79,7 @@
|
|
|
|
|
type (
|
|
|
|
|
addReq struct {
|
|
|
|
|
book string `form:"book"`
|
|
|
|
|
price int `form:"price"`
|
|
|
|
|
price int64 `form:"price"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addResp struct {
|
|
|
|
@ -94,7 +94,7 @@
|
|
|
|
|
|
|
|
|
|
checkResp struct {
|
|
|
|
|
found bool `json:"found"`
|
|
|
|
|
price int `json:"price"`
|
|
|
|
|
price int64 `json:"price"`
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -280,13 +280,13 @@
|
|
|
|
|
```go
|
|
|
|
|
type ServiceContext struct {
|
|
|
|
|
Config config.Config
|
|
|
|
|
Adder rpcx.Client // 手动代码
|
|
|
|
|
Adder adder.Adder // 手动代码
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
|
|
|
return &ServiceContext{
|
|
|
|
|
Config: c,
|
|
|
|
|
Adder: rpcx.MustNewClient(c.Add), // 手动代码
|
|
|
|
|
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)), // 手动代码
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -298,7 +298,7 @@
|
|
|
|
|
```go
|
|
|
|
|
func (l *AddLogic) Add(req types.AddReq) (*types.AddResp, error) {
|
|
|
|
|
// 手动代码开始
|
|
|
|
|
resp, err := adder.NewAdder(l.svcCtx.Adder).Add(l.ctx, &adder.AddReq{
|
|
|
|
|
resp, err := l.svcCtx.Adder.Add(l.ctx, &adder.AddReq{
|
|
|
|
|
Book: req.Book,
|
|
|
|
|
Price: req.Price,
|
|
|
|
|
})
|
|
|
|
@ -415,15 +415,15 @@
|
|
|
|
|
```go
|
|
|
|
|
type ServiceContext struct {
|
|
|
|
|
Config config.Config
|
|
|
|
|
Adder rpcx.Client // 手动代码
|
|
|
|
|
Checker rpcx.Client // 手动代码
|
|
|
|
|
Adder adder.Adder // 手动代码
|
|
|
|
|
Checker checker.Checker // 手动代码
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
|
|
|
return &ServiceContext{
|
|
|
|
|
Config: c,
|
|
|
|
|
Adder: rpcx.MustNewClient(c.Add), // 手动代码
|
|
|
|
|
Checker: rpcx.MustNewClient(c.Check), // 手动代码
|
|
|
|
|
Adder: adder.NewAdder(rpcx.MustNewClient(c.Add)), // 手动代码
|
|
|
|
|
Checker: checker.NewChecker(rpcx.MustNewClient(c.Check)), // 手动代码
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
@ -435,7 +435,7 @@
|
|
|
|
|
```go
|
|
|
|
|
func (l *CheckLogic) Check(req types.CheckReq) (*types.CheckResp, error) {
|
|
|
|
|
// 手动代码开始
|
|
|
|
|
resp, err := checker.NewChecker(l.svcCtx.Checker).Check(l.ctx, &checker.CheckReq{
|
|
|
|
|
resp, err := l.svcCtx.Checker.Check(l.ctx, &checker.CheckReq{
|
|
|
|
|
Book: req.Book,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|