addlogic.go 749 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package logic
  2. import (
  3. "context"
  4. "points_service/rpc/model"
  5. "points_service/rpc/integral"
  6. "points_service/rpc/internal/svc"
  7. "github.com/tal-tech/go-zero/core/logx"
  8. )
  9. type AddLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLogic {
  15. return &AddLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *AddLogic) Add(in *integral.AddReq) (*integral.AddResp, error) {
  22. // todo: add your logic here and delete this line
  23. _, err := l.svcCtx.Model.Insert(model.Balance{
  24. UserId: in.UserId,
  25. CountPoints: in.CountPoints,
  26. })
  27. if err != nil {
  28. return nil, err
  29. }
  30. return &integral.AddResp{Status: true}, nil
  31. }