Skip to content

Commit

Permalink
Merge pull request #98 from Team-Sopetit/feature/#58-add-routine-api
Browse files Browse the repository at this point in the history
[FEAT] 행복루틴 달성
  • Loading branch information
csb9427 committed Jan 13, 2024
2 parents 4dbd352 + c1258f8 commit 7eaebef
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 62 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/soptie/server/member/entity/Cotton.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ protected void addDailyCotton() {
this.dailyCottonCount++;
}

protected void addHappinessCotton(){
this.happinessCottonCount++;
}

protected int subtractDailyCotton() {
this.dailyCottonCount--;
return this.dailyCottonCount;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/soptie/server/member/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ public void addDailyCotton() {
this.cottonInfo.addDailyCotton();
}

public void addHappinessCotton() {
this.cottonInfo.addHappinessCotton();
}

public int subtractDailyCotton() {
return this.cottonInfo.subtractDailyCotton();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,11 @@ public ResponseEntity<Response> deleteMemberHappinessRoutine(Principal principal
memberHappinessRoutineService.deleteMemberHappinessRoutine(memberId, routineId);
return ResponseEntity.ok(success(SUCCESS_DELETE_ROUTINE.getMessage()));
}

@PatchMapping("/routine/{routineId}")
public ResponseEntity<Response> achieveMemberHappinessRoutine(Principal principal, @PathVariable Long routineId){
val memberId = Long.parseLong(principal.getName());
memberHappinessRoutineService.achieveMemberHappinessRoutine(memberId, routineId);
return ResponseEntity.ok(success(SUCCESS_ACHIEVE_ROUTINE.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public interface MemberHappinessRoutineService {
MemberHappinessRoutineResponse createMemberHappinessRoutine(Long memberId, MemberHappinessRoutineRequest request);
MemberHappinessRoutinesResponse getMemberHappinessRoutine(Long memberId);
void deleteMemberHappinessRoutine(Long memberId, Long routineId);

void achieveMemberHappinessRoutine(Long memberId, Long routineId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ private void deleteMemberRoutine(MemberHappinessRoutine routine) {
memberHappinessRoutineRepository.delete(routine);
}

@Override
@Transactional
public void achieveMemberHappinessRoutine(Long memberId, Long routineId) {
val member = findMember(memberId);
val memberRoutine = findMemberRoutine(routineId);
checkRoutineForMember(member, memberRoutine);
member.addHappinessCotton();
deleteMemberRoutine(memberRoutine);
}

private MemberHappinessRoutine findMemberRoutine(Long id) {
return memberHappinessRoutineRepository.findById(id)
.orElseThrow(() -> new EntityNotFoundException(INVALID_ROUTINE.getMessage()));
Expand Down
281 changes: 220 additions & 61 deletions src/main/resources/static/docs/open-api-3.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,53 @@
}
}
},
"/api/v1/members" : {
"post" : {
"tags" : [ "MEMBER" ],
"summary" : "프로필 생성",
"description" : "프로필 생성",
"operationId" : "post-member-profile-docs",
"requestBody" : {
"content" : {
"application/json;charset=UTF-8" : {
"schema" : {
"$ref" : "#/components/schemas/api-v1-members-2061462562"
},
"examples" : {
"post-member-profile-docs" : {
"value" : "{\n \"dollType\" : \"BROWN\",\n \"name\" : \"소프티\",\n \"routines\" : [ 1, 2, 3 ]\n}"
}
}
}
}
},
"responses" : {
"201" : {
"description" : "201",
"headers" : {
"Location" : {
"description" : "Redirect URI",
"schema" : {
"type" : "string"
}
}
},
"content" : {
"application/json;charset=UTF-8" : {
"schema" : {
"$ref" : "#/components/schemas/api-v1-routines-daily-member-routine-routineId594740350"
},
"examples" : {
"post-member-profile-docs" : {
"value" : "{\n \"success\" : true,\n \"message\" : \"프로필 생성 성공\",\n \"data\" : null\n}"
}
}
}
}
}
}
}
},
"/api/v1/test" : {
"get" : {
"tags" : [ "TEST" ],
Expand Down Expand Up @@ -247,6 +294,31 @@
}
}
},
"/api/v1/routines/happiness/member" : {
"get" : {
"tags" : [ "MEMBER HAPPINESS ROUTINE" ],
"summary" : "회원 별 행복 루틴 리스트 조회",
"description" : "회원 별 행복 루틴 리스트 조회",
"operationId" : "get-member-happiness-routine-docs",
"responses" : {
"200" : {
"description" : "200",
"content" : {
"application/json;charset=UTF-8" : {
"schema" : {
"$ref" : "#/components/schemas/api-v1-routines-happiness-member-160843619"
},
"examples" : {
"get-member-happiness-routine-docs" : {
"value" : "{\n \"success\" : true,\n \"message\" : \"루틴 조회 성공\",\n \"data\" : {\n \"routineId\" : 1,\n \"iconImageUrl\" : \"icon-image-url\",\n \"contentImageUrl\" : \"content-image-url\",\n \"themeName\" : \"태마 이름\",\n \"themeNameColor\" : \"#ffcdc5\",\n \"title\" : \"루틴 제목\",\n \"content\" : \"routine-content\",\n \"detailContent\" : \"routine-detail-content\",\n \"place\" : \"루틴 장소\",\n \"timeTaken\" : \"5~10분 소요\"\n }\n}"
}
}
}
}
}
}
}
},
"/api/v1/routines/daily/theme/{themeId}" : {
"get" : {
"tags" : [ "DAILY ROUTINE" ],
Expand Down Expand Up @@ -350,33 +422,6 @@
},
"components" : {
"schemas" : {
"api-v1-auth162170271" : {
"type" : "object",
"properties" : {
"data" : {
"type" : "object",
"properties" : {
"accessToken" : {
"type" : "string",
"description" : "Access Token"
},
"refreshToken" : {
"type" : "string",
"description" : "Refresh Token"
}
},
"description" : "응답 데이터"
},
"success" : {
"type" : "boolean",
"description" : "응답 성공 여부"
},
"message" : {
"type" : "string",
"description" : "응답 메시지"
}
}
},
"api-v1-routines-daily-theme-themeId-54531209" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -502,6 +547,132 @@
}
}
},
"api-v1-auth-1040425838" : {
"type" : "object",
"properties" : {
"socialType" : {
"type" : "string",
"description" : "소셜 종류"
}
}
},
"api-v1-routines-daily-member-routine-routineId-2021368021" : {
"type" : "object",
"properties" : {
"data" : {
"type" : "object",
"properties" : {
"achieveCount" : {
"type" : "number",
"description" : "달성 횟수"
},
"routineId" : {
"type" : "number",
"description" : "루틴 id"
},
"isAchieve" : {
"type" : "boolean",
"description" : "달성 여부"
}
},
"description" : "응답 데이터"
},
"success" : {
"type" : "boolean",
"description" : "응답 성공 여부"
},
"message" : {
"type" : "string",
"description" : "응답 메시지"
}
}
},
"api-v1-routines-happiness-member-160843619" : {
"type" : "object",
"properties" : {
"data" : {
"type" : "object",
"properties" : {
"timeTaken" : {
"type" : "string",
"description" : "소요 시간"
},
"detailContent" : {
"type" : "string",
"description" : "루틴 상세 내용"
},
"themeName" : {
"type" : "string",
"description" : "테마 이름"
},
"contentImageUrl" : {
"type" : "string",
"description" : "카드 이미지 url"
},
"themeNameColor" : {
"type" : "string",
"description" : "테마 이름 색상"
},
"iconImageUrl" : {
"type" : "string",
"description" : "아이콘 이미지 url"
},
"place" : {
"type" : "string",
"description" : "장소"
},
"title" : {
"type" : "string",
"description" : "루틴 제목"
},
"routineId" : {
"type" : "number",
"description" : "루틴 id"
},
"content" : {
"type" : "string",
"description" : "루틴 내용"
}
},
"description" : "응답 데이터"
},
"success" : {
"type" : "boolean",
"description" : "응답 성공 여부"
},
"message" : {
"type" : "string",
"description" : "응답 메시지"
}
}
},
"api-v1-auth162170271" : {
"type" : "object",
"properties" : {
"data" : {
"type" : "object",
"properties" : {
"accessToken" : {
"type" : "string",
"description" : "Access Token"
},
"refreshToken" : {
"type" : "string",
"description" : "Refresh Token"
}
},
"description" : "응답 데이터"
},
"success" : {
"type" : "boolean",
"description" : "응답 성공 여부"
},
"message" : {
"type" : "string",
"description" : "응답 메시지"
}
}
},
"api-v1-routines-daily-member1327124516" : {
"type" : "object",
"properties" : {
Expand Down Expand Up @@ -573,48 +744,36 @@
}
}
},
"api-v1-auth-1040425838" : {
"api-v1-members-2061462562" : {
"type" : "object",
"properties" : {
"socialType" : {
"name" : {
"type" : "string",
"description" : "소셜 종류"
}
}
},
"api-v1-test486549215" : {
"type" : "object"
},
"api-v1-routines-daily-member-routine-routineId-2021368021" : {
"type" : "object",
"properties" : {
"data" : {
"type" : "object",
"properties" : {
"achieveCount" : {
"type" : "number",
"description" : "달성 횟수"
},
"routineId" : {
"type" : "number",
"description" : "루틴 id"
},
"isAchieve" : {
"type" : "boolean",
"description" : "달성 여부"
}
},
"description" : "응답 데이터"
"description" : "인형 이름"
},
"success" : {
"type" : "boolean",
"description" : "응답 성공 여부"
"routines" : {
"type" : "array",
"description" : "인형 종류",
"items" : {
"oneOf" : [ {
"type" : "object"
}, {
"type" : "boolean"
}, {
"type" : "string"
}, {
"type" : "number"
} ]
}
},
"message" : {
"dollType" : {
"type" : "string",
"description" : "응답 메시지"
"description" : "인형 종류"
}
}
},
"api-v1-test486549215" : {
"type" : "object"
}
}
}
Expand Down

0 comments on commit 7eaebef

Please sign in to comment.