fix
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/server/shopping-cart-confirmation/internal/types"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/basic"
|
||||
|
||||
"context"
|
||||
|
||||
"fusenapi/server/shopping-cart-confirmation/internal/svc"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CartNumberLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCartNumberLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartNumberLogic {
|
||||
return &CartNumberLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CartNumberLogic) CartNumber(userinfo *auth.UserInfo) (resp *basic.Response) {
|
||||
cartModel := gmodel.NewFsCartModel(l.svcCtx.MysqlConn)
|
||||
total, err := cartModel.CountUserCart(l.ctx, userinfo.UserId)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeApiErr, "failed to get count of your cart")
|
||||
}
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.CartNumberRsp{
|
||||
Num: total,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user