商品已完成优化
This commit is contained in:
@@ -208,7 +208,7 @@ func (r *Repository) Update(ctx context.Context, ownerID uint64, listingID uint6
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if listing.Status == "rented" || listing.InTransaction {
|
||||
if listingLockedForOwnerMutation(listing) {
|
||||
return ErrListingLocked
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ func (r *Repository) SubmitReview(ctx context.Context, ownerID uint64, listingID
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if listing.Status == "rented" || listing.InTransaction {
|
||||
if listingLockedForOwnerMutation(listing) {
|
||||
return ErrListingLocked
|
||||
}
|
||||
listingStatus, reviewStatus, publishedAt := initialPublishState(reviewRequired)
|
||||
@@ -346,7 +346,7 @@ func (r *Repository) Offline(ctx context.Context, ownerID uint64, listingID uint
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if listing.Status == "rented" || listing.InTransaction {
|
||||
if listingLockedForOwnerMutation(listing) {
|
||||
return ErrListingLocked
|
||||
}
|
||||
listing.Status = "offline"
|
||||
@@ -365,3 +365,10 @@ func (r *Repository) Offline(ctx context.Context, ownerID uint64, listingID uint
|
||||
})
|
||||
return dto, err
|
||||
}
|
||||
|
||||
func listingLockedForOwnerMutation(listing *model.RentalListing) bool {
|
||||
if listing == nil {
|
||||
return true
|
||||
}
|
||||
return listing.Status == "rented" || listing.Status == "completed" || listing.InTransaction
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user