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.
37 lines
658 B
Go
37 lines
658 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
|
|
check "bookstore/rpc/check/internal/pb"
|
|
"bookstore/rpc/check/internal/svc"
|
|
|
|
"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
|
|
}
|