|
|
@@ -265,7 +265,13 @@ public class CollectionService {
|
|
|
}
|
|
|
|
|
|
public synchronized Integer getNextNumber(Long collectionId) {
|
|
|
- redisTemplate.opsForValue().increment("collectionNumber::" + collectionId);
|
|
|
- return (Integer) redisTemplate.opsForValue().get("collectionNumber::" + collectionId);
|
|
|
+ Collection collection = collectionRepo.findById(collectionId).orElse(null);
|
|
|
+ if (collection == null) return 0;
|
|
|
+ if (collection.getCurrentNumber() == null) {
|
|
|
+ collection.setCurrentNumber(0);
|
|
|
+ }
|
|
|
+ collection.setCurrentNumber(collection.getCurrentNumber() + 1);
|
|
|
+ collectionRepo.save(collection);
|
|
|
+ return collection.getCurrentNumber();
|
|
|
}
|
|
|
}
|