Skip to content

Commit

Permalink
fix: "Already stamped
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jul 1, 2024
1 parent 921e93e commit 77cc5c4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/stamp/stamp.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ func (s *serviceImpl) StampByUserId(_ context.Context, in *proto.StampByUserIdRe
}

tempStrStamp := []byte(stamp.Stamp)
if tempStrStamp[actIdx] == '1' {
return nil, status.Error(codes.Internal, errors.New("Already stamped").Error())
}

tempStrStamp[actIdx] = '1'
stamp.Stamp = string(tempStrStamp)
s.skillsCalc(stamp, actIdx)
s.addNewScore(stamp, actIdx)

err = s.repo.StampByUserId(in.UserId, stamp)
if err != nil {
Expand All @@ -81,7 +85,7 @@ func (s *serviceImpl) modelToProto(stamp *model.Stamp) *proto.Stamp {
}
}

func (s *serviceImpl) skillsCalc(stamp *model.Stamp, idx int) {
func (s *serviceImpl) addNewScore(stamp *model.Stamp, idx int) {
if idx <= 1 {
stamp.PointB += 2
stamp.PointD += 2
Expand Down

0 comments on commit 77cc5c4

Please sign in to comment.