Skip to content

Commit

Permalink
Merge pull request #58 from Team-Growthook/feat/#54-seed-lock-status-…
Browse files Browse the repository at this point in the history
…patch-api

[FEAT] 씨앗 잠금 해제 API
  • Loading branch information
yeseul106 authored Jan 8, 2024
2 parents 49ae972 + 59e0a80 commit 36d8a99
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,9 @@ public Member(String nickname, String email, SocialPlatform socialPlatform, Bool
public void incrementGatheredSsuk() {
this.gatheredSsuk = (this.gatheredSsuk == null ? 0 : this.gatheredSsuk) + 1;
}

public void useSsuck() {
this.gatheredSsuk--;
this.usedSsuk++;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ public ApiResponse<SeedAlarmGetResponseDto> getSeedAlarm(@PathVariable Long memb
return ApiResponse.success(SuccessStatus.GET_SEED_ALARM, seedService.getSeedAlarm(memberId));
}

@PatchMapping("seed/{seedId}/lock/status")
@ResponseStatus(HttpStatus.OK)
@Operation(summary = "unlockSeed", description = "인사이트 잠금을 해제하는 API입니다.")
public ApiResponse unlockSeed(@PathVariable Long seedId) {
seedService.unlockSeed(seedId);
return ApiResponse.success(SuccessStatus.UNLOCK_SEED.getStatusCode(), SuccessStatus.UNLOCK_SEED.getMessage());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ public void changeCave(Cave newCave) {
}

public void toggleScrapStatus() { this.isScraped = !this.isScraped; }

public void unlockSeed() { this.isLocked = false; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.example.growthookserver.api.actionplan.repository.ActionPlanRepository;
import com.example.growthookserver.api.cave.domain.Cave;
import com.example.growthookserver.api.cave.repository.CaveRepository;
import com.example.growthookserver.api.member.domain.Member;
import com.example.growthookserver.api.member.repository.MemberRepository;
import com.example.growthookserver.api.seed.domain.Seed;
import com.example.growthookserver.api.seed.dto.request.SeedCreateRequestDto;
import com.example.growthookserver.api.seed.dto.request.SeedMoveRequestDto;
Expand Down Expand Up @@ -35,6 +37,7 @@ public class SeedServiceImpl implements SeedService {
private final CaveRepository caveRepository;
private final SeedRepository seedRepository;
private final ActionPlanRepository actionPlanRepository;
private final MemberRepository memberRepository;

@Override
@Transactional
Expand Down Expand Up @@ -118,6 +121,17 @@ public SeedAlarmGetResponseDto getSeedAlarm(Long memberId) {
return SeedAlarmGetResponseDto.of(seedCount);
}

@Override
@Transactional
public void unlockSeed(Long seedId) {
Seed seed = seedRepository.findSeedByIdOrThrow(seedId);
seed.unlockSeed();

Long memberId = seed.getMemberId();
Member member = memberRepository.findMemberByIdOrThrow(memberId);
member.useSsuck();
}

@Override
@Transactional
public void toggleSeedScrapStatus(Long seedId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public interface SeedService {
//* 씨앗 알림 조회
SeedAlarmGetResponseDto getSeedAlarm(Long memberId);

//* 씨앗 잠금 해제
void unlockSeed(Long seedId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public enum SuccessStatus {
GET_SEED_LIST(HttpStatus.OK, "전체 씨앗 리스트 조회 성공" ),
TOGGLE_SEED_SCRAP_STATUS(HttpStatus.OK, "씨앗 스크랩 여부 토글 전환 성공"),
GET_SEED_ALARM(HttpStatus.OK,"씨앗 알람 조회 성공"),
UNLOCK_SEED(HttpStatus.OK, "씨앗 잠금 해제 성공"),

/**
* actionplan
Expand Down

0 comments on commit 36d8a99

Please sign in to comment.