You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
647 B
Go
35 lines
647 B
Go
package logic
|
|
|
|
import (
|
|
"bookstore/rpc/check/internal/svc"
|
|
check "bookstore/rpc/check/pb"
|
|
"context"
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
)
|
|
|
|
type CheckLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckLogic {
|
|
return &CheckLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *CheckLogic) Check(in *check.CheckReq) (*check.CheckResp, error) {
|
|
resp, err := l.svcCtx.Model.FindOne(in.Book)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &check.CheckResp{
|
|
Found: true,
|
|
Price: resp.Price,
|
|
}, nil
|
|
} |