File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
src/main/java/org/umc/travlocksserver/domain Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 66import org .springframework .data .domain .PageRequest ;
77import org .springframework .stereotype .Service ;
88import org .springframework .transaction .annotation .Transactional ;
9+ import org .umc .travlocksserver .domain .member .service .query .MemberQueryService ;
910import org .umc .travlocksserver .domain .template .dto .response .VlockSuggestionsResponseDTO ;
1011import org .umc .travlocksserver .domain .template .entity .Template ;
1112import org .umc .travlocksserver .domain .template .entity .TemplateDay ;
@@ -127,6 +128,7 @@ public TemplateVlockAddResponseDTO addVlock(
127128
128129 // 5. vlockCount 증가
129130 templateDay .incrementVlockCount ();
131+ vlock .increaseUsageCount ();
130132
131133 // 6. 경고 메시지 생성
132134 String warning = null ;
@@ -174,6 +176,7 @@ public TemplateVlockDeleteResponseDTO deleteVlock(
174176
175177 // 6. vlockCount 감소
176178 templateDay .decrementVlockCount ();
179+ templateVlock .getVlock ().decreaseUsageCount ();
177180
178181 return TemplateVlockDeleteResponseDTO .from (
179182 templateVlocksId ,
Original file line number Diff line number Diff line change @@ -129,4 +129,14 @@ public void update(VlockUpdateCommand command) {
129129 this .isPublic = command .isPublic ();
130130 }
131131 }
132+
133+ public void increaseUsageCount () {
134+ this .usageCount ++;
135+ }
136+
137+ public void decreaseUsageCount () {
138+ if (this .usageCount > 0 ) {
139+ this .usageCount --;
140+ }
141+ }
132142}
You can’t perform that action at this time.
0 commit comments