Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#79 #88

Merged
merged 24 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
37e899c
[Feat]: ๋งค๋‹ˆ์ €, ์–ด๋“œ๋ฏผ ๊ณ„์ • ์กฐํšŒ api ์ŠคํŽ™ ์ •์˜
kwonssshyeon Sep 5, 2024
b1165ba
[Feat]: ๋งค๋‹ˆ์ €, ์–ด๋“œ๋ฏผ ๊ณ„์ • ์กฐํšŒ ๊ธฐ๋Šฅ ๊ตฌํ˜„
kwonssshyeon Sep 5, 2024
8908d3f
[Feat]: ์—๋Ÿฌ ๋กœ๊ทธ ์ถœ๋ ฅ ์ฝ”๋“œ ์ถ”๊ฐ€
kwonssshyeon Sep 7, 2024
36f6827
[Fix]: ์ฑŒ๋ฆฐ์ง€ ์ƒ์„ฑ request ์ˆ˜์ •
kwonssshyeon Sep 7, 2024
5bdc67d
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ˆ˜์ • api spec ์ •์˜
kwonssshyeon Sep 7, 2024
ff9b1ad
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ˆ˜์ • command ํด๋ž˜์Šค ์ถ”๊ฐ€
kwonssshyeon Sep 7, 2024
cf460c8
[Feat]: ์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน, ์ฑŒ๋ฆฐ์ง€ ์—”ํ‹ฐํ‹ฐ ์—…๋ฐ์ดํŠธ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
kwonssshyeon Sep 7, 2024
d3b521b
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ˆ˜์ • ๊ธฐ๋Šฅ ๊ตฌํ˜„
kwonssshyeon Sep 7, 2024
cf89166
[Fix]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ model inner ํด๋ž˜์Šค๋กœ ๋ณ€๊ฒฝ
kwonssshyeon Sep 7, 2024
7334b9e
[Fix]: user challenge ์ƒ์„ฑ์‹œ active ๋‚ ์งœ ํ•„๋“œ ์ถ”๊ฐ€
kwonssshyeon Sep 8, 2024
0f83ff5
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ๋ชฉ๋ก ์กฐํšŒ api ์ŠคํŽ™ ์ •์˜
kwonssshyeon Sep 8, 2024
e37769c
[Feat]: ๊ด€๋ฆฌ์ž์˜ ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ model ์ž‘์„ฑ
kwonssshyeon Sep 8, 2024
5e90a9e
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์กฐํšŒ ์ฟผ๋ฆฌ ์ž‘์„ฑ ๋ฐ ๊ธฐ๋Šฅ ๊ตฌํ˜„
kwonssshyeon Sep 8, 2024
394d23f
[Fix]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ service ํด๋ž˜์Šค๋ช… ์˜คํƒ€ ์ˆ˜์ •
kwonssshyeon Sep 8, 2024
765d4fe
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ๊ฒ€ํ†  api ์ŠคํŽ™ ์ •์˜
kwonssshyeon Sep 8, 2024
a065dfc
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์ƒํƒœ ๋ณ€๊ฒฝ, ๊ฒฝํ—˜์น˜ ์—…๋ฐ์ดํŠธ ๋ฉ”์†Œ๋“œ ์ž‘์„ฑ
kwonssshyeon Sep 8, 2024
df2f92a
[Feat]: ์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ๊ฒ€ํ†  ๊ธฐ๋Šฅ ๊ตฌํ˜„
kwonssshyeon Sep 8, 2024
3a9985e
[Fix]: UserChallenge ์ตœ๊ทผ ์„ฑ๊ณต์ผ์ž ์กฐํšŒ ํ•จ์ˆ˜ -> getRecentDate๋กœ ์ด๋ฆ„ ๋ณ€๊ฒฝ
kwonssshyeon Sep 9, 2024
58f3545
[Fix]: (์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์กฐํšŒ) ์ œ๋ชฉ ๊ฒ€์ƒ‰ ํ•จ์ˆ˜๋ช… eq -> contains ์ˆ˜์ •
kwonssshyeon Sep 9, 2024
2d7599a
[Fix]: ์ฑŒ๋ฆฐ์ง€ ์ˆ˜์ • request์—์„œ create์ฑŒ๋ฆฐ์ง€์™€ update์ฑŒ๋ฆฐ์ง€ ๋ถ„๋ฆฌ + ๊ทธ์— ๋”ฐ๋ฅธ ๋กœ์ง ์ˆ˜์ •
kwonssshyeon Sep 9, 2024
747d292
[Fix]: ์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน์˜ ์ฑŒ๋ฆฐ์ง€ ๊ฐ€์ ธ์˜ค๋Š” ๋กœ์ง ๋ณ€๊ฒฝ
kwonssshyeon Sep 10, 2024
b5bad9e
Merge branch 'main' of https://github.com/KNU-HAEDAL/ZZANSUNI_BE intoโ€ฆ
kwonssshyeon Sep 10, 2024
4c571de
[Fix]: ๊ฒฝํ—˜์น˜ ๋กค๋ฐฑ(User, ChallengeGroupUserExp) use case ์ด์šฉ
kwonssshyeon Sep 10, 2024
e605148
[Fix]: ์˜ค๋ฅ˜๋‚˜๋Š” ํ…Œ์ŠคํŠธ ์ฃผ์„ ์ฒ˜๋ฆฌ
kwonssshyeon Sep 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,30 @@
import lombok.RequiredArgsConstructor;
import org.haedal.zzansuni.auth.controller.AuthReq;
import org.haedal.zzansuni.auth.domain.AuthService;
import org.haedal.zzansuni.challengegroup.controller.ChallengeGroupReq;
import org.haedal.zzansuni.challengegroup.domain.application.ChallengeGroupService;
import org.haedal.zzansuni.common.controller.PagingRequest;
import org.haedal.zzansuni.common.controller.PagingResponse;
import org.haedal.zzansuni.core.api.ApiResponse;
import org.haedal.zzansuni.user.domain.UserModel;
import org.haedal.zzansuni.user.domain.UserService;
import org.haedal.zzansuni.userchallenge.controller.ChallengeRes;
import org.haedal.zzansuni.userchallenge.domain.ChallengeVerificationStatus;
import org.haedal.zzansuni.userchallenge.domain.application.ChallengeVerificationService;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "admin", description = "๊ด€๋ฆฌ์ž API")
@RequiredArgsConstructor
@RestController
public class AdminController {

private final AuthService authService;
private final ChallengeGroupService challengeGroupService;
private final UserService userService;
private final ChallengeVerificationService challengeVerificationService;

@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "๋งค๋‹ˆ์ € ๋“ฑ๋ก", description = "๋งค๋‹ˆ์ €๋ฅผ ๋“ฑ๋กํ•œ๋‹ค.")
Expand All @@ -27,6 +39,15 @@ public ApiResponse<Void> createManager(@RequestBody @Valid AuthReq.EmailSignupRe
return ApiResponse.success(null, "๋งค๋‹ˆ์ € ๋“ฑ๋ก ์„ฑ๊ณต");
}

@ResponseStatus(HttpStatus.OK)
@Operation(summary = "๋งค๋‹ˆ์ €, ์–ด๋“œ๋ฏผ ๊ณ„์ • ์กฐํšŒ", description = "๋งค๋‹ˆ์ €, ์–ด๋“œ๋ฏผ ๊ณ„์ •์„ ์กฐํšŒํ•œ๋‹ค.")
@GetMapping("/api/admin/auth/manager")
public ApiResponse<List<AdminRes.ManagerAndAdmin>> getAdminAndManager() {
List<UserModel.Main> managerAndAdmin = userService.getManagerAndAdmin();
return ApiResponse.success(AdminRes.ManagerAndAdmin.from(managerAndAdmin), "๋งค๋‹ˆ์ €, ์–ด๋“œ๋ฏผ ๊ณ„์ • ์กฐํšŒ ์„ฑ๊ณต");
}


@ResponseStatus(HttpStatus.CREATED)
@Operation(summary = "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน ์ƒ์„ฑ", description = "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน๊ณผ ํ•ด๋‹นํ•˜๋Š” ์ฑŒ๋ฆฐ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค")
@PostMapping("/api/admin/challengeGroups")
Expand All @@ -42,4 +63,32 @@ public ApiResponse<Void> deleteChallengeGroup(@PathVariable Long challengeGroupI
challengeGroupService.deleteChallengeGroup(challengeGroupId);
return ApiResponse.success(null, "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน ์‚ญ์ œ ์„ฑ๊ณต");
}

@ResponseStatus(HttpStatus.OK)
@Operation(summary = "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน ์ˆ˜์ •", description = "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน์„ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค. ์ƒˆ๋กœ์šด ์ฑŒ๋ฆฐ์ง€๋ฅผ ์ถ”๊ฐ€ํ• ๋• id=-1๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.")
@PutMapping("/api/admin/challengeGroups/{challengeGroupId}")
public ApiResponse<Void> updateChallengeGroup(@Valid @RequestBody ChallengeGroupReq.Update request) {
challengeGroupService.updateChallengeGroup(request.toCommand());
return ApiResponse.success(null, "์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน ์ˆ˜์ • ์„ฑ๊ณต");
}

@ResponseStatus(HttpStatus.OK)
@Operation(summary = "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์กฐํšŒ", description = "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„ ํŽ˜์ด์ง• ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค. ์ฑŒ๋ฆฐ์ง€ ์ด๋ฆ„์œผ๋กœ ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.")
@GetMapping("/api/admin/challenges/verifications")
public ApiResponse<PagingResponse<ChallengeRes.ChallengeVerification>> getChallengeVerifications(
@Valid PagingRequest pagingRequest,
@RequestParam(required = false) String challengeTitle){
var verificationPage = challengeVerificationService.getChallengeVerifications(pagingRequest.toPageable(), challengeTitle);
return ApiResponse.success(PagingResponse.from(verificationPage, ChallengeRes.ChallengeVerification::from), "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์กฐํšŒ ์„ฑ๊ณต");
}

@ResponseStatus(HttpStatus.OK)
@Operation(summary = "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์Šน์ธ/๊ฑฐ์ ˆ", description = "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ์„ ์Šน์ธ/๊ฑฐ์ ˆํ•ฉ๋‹ˆ๋‹ค. ๊ฑฐ์ ˆ์‹œ ๊ฒฝํ—˜์น˜๊ฐ€ ์ทจ์†Œ๋ฉ๋‹ˆ๋‹ค.")
@PatchMapping("/api/admin/challenges/verifications/{challengeVerificationId}")
public ApiResponse<Void> approveChallengeVerification(@PathVariable Long challengeVerificationId,
@Valid @RequestParam ChallengeVerificationStatus status) {
challengeVerificationService.confirm(challengeVerificationId, status);
return ApiResponse.success(null, "์ฑŒ๋ฆฐ์ง€ ์ธ์ฆ ์Šน์ธ/๊ฑฐ์ ˆ ์„ฑ๊ณต");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public record CreateChallengeGroupRequest(
String guide,
@NotNull(message = "category๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
ChallengeCategory category,
@NotNull(message = "joinStartDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
LocalDate joinStartDate,
@NotNull(message = "joinEndDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
LocalDate joinEndDate,
@NotNull(message = "challenges๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
List<CreateChallengeRequest> challenges
){
Expand All @@ -27,30 +31,32 @@ public ChallengeGroupCommand.Create toCommand() {
.content(content)
.guide(guide)
.category(category)
.joinStartDate(joinStartDate)
.joinEndDate(joinEndDate)
.createChallenges(challenges.stream().map(CreateChallengeRequest::toCommand).toList())
.build();
}
}

public record CreateChallengeRequest(
@NotNull(message = "startDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
LocalDate startDate,
@NotNull(message = "endDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
@NotNull(message = "requiredCount๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer requiredCount,
@NotNull(message = "onceExp๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer onceExp,
@NotNull(message = "successExp๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer successExp,
@NotNull(message = "difficulty๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer difficulty
Integer difficulty,
@NotNull(message = "activePeriod๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer activePeriod
){
public ChallengeGroupCommand.CreateChallenge toCommand() {
return ChallengeGroupCommand.CreateChallenge.builder()
.requiredCount(requiredCount)
.onceExp(onceExp)
.successExp(successExp)
.difficulty(difficulty)
.activePeriod(activePeriod)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.haedal.zzansuni.admin.controller;

import lombok.Builder;
import org.haedal.zzansuni.user.domain.UserModel;

import java.time.LocalDateTime;
import java.util.List;

public class AdminRes {
@Builder
public record ManagerAndAdmin(
Long id,
String email,
String name,
String role,
LocalDateTime createdAt
) {
public static ManagerAndAdmin from(UserModel.Main userMain) {
return ManagerAndAdmin.builder()
.id(userMain.id())
.email(userMain.email())
.name(userMain.nickname())
.role(userMain.role().name())
.createdAt(userMain.createdAt())
.build();
}

public static List<ManagerAndAdmin> from(List<UserModel.Main> userMainList) {
return userMainList.stream()
.map(ManagerAndAdmin::from)
.toList();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
package org.haedal.zzansuni.challengegroup.controller;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.haedal.zzansuni.admin.controller.AdminReq;
import org.haedal.zzansuni.challengegroup.domain.ChallengeCategory;
import org.haedal.zzansuni.challengegroup.domain.ChallengeGroupCommand;

import java.time.LocalDate;
import java.util.List;

public class ChallengeGroupReq {
public record Update(
@NotNull(message = "id๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Long id,
@NotBlank(message = "title์€ ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
String title,
@NotBlank(message = "content๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
String content,
@NotBlank(message = "guide๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
String guide,
@NotNull(message = "category๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
ChallengeCategory category,
@NotNull(message = "joinStartDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
LocalDate joinStartDate,
@NotNull(message = "joinEndDate๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
LocalDate joinEndDate,
List<UpdateChallenge> updateChallenges,
List<AdminReq.CreateChallengeRequest> createChallenges
) {
public ChallengeGroupCommand.Update toCommand() {
return ChallengeGroupCommand.Update.builder()
.id(id)
.title(title)
.content(content)
.guide(guide)
.category(category)
.joinStartDate(joinStartDate)
.joinEndDate(joinEndDate)
.updateChallenges(updateChallenges.stream().map(UpdateChallenge::toCommand).toList())
.createChallenges(createChallenges.stream().map(AdminReq.CreateChallengeRequest::toCommand).toList())
.build();
}
}


public record UpdateChallenge(
@NotNull(message = "id๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Long id,
@NotNull(message = "activePeriod๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer activePeriod,
@NotNull(message = "requiredCount๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer requiredCount,
@NotNull(message = "onceExp๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer onceExp,
@NotNull(message = "successExp๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer successExp,
@NotNull(message = "difficulty๋Š” ํ•„์ˆ˜๊ฐ’์ž…๋‹ˆ๋‹ค.")
Integer difficulty
){
public ChallengeGroupCommand.UpdateChallenge toCommand() {
return ChallengeGroupCommand.UpdateChallenge.builder()
.id(id)
.activePeriod(activePeriod)
.requiredCount(requiredCount)
.onceExp(onceExp)
.successExp(successExp)
.difficulty(difficulty)
.build();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import jakarta.persistence.*;

import java.time.LocalDate;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down Expand Up @@ -53,6 +52,15 @@ public static Challenge create(ChallengeGroupCommand.CreateChallenge command, Ch
.build();
}

public Challenge update(ChallengeGroupCommand.UpdateChallenge command) {
this.onceExp = command.getOnceExp();
this.successExp = command.getSuccessExp();
this.difficulty = command.getDifficulty();
this.requiredCount = command.getRequiredCount();
this.activePeriod = command.getActivePeriod();
return this;
}

/**
* ์ฑŒ๋ฆฐ์ง€ ๊ทธ๋ฃน ์•„์ด๋”” ๋ฐ˜ํ™˜
* FK๋Š” LAZY ์—ฌ๋„ ์ด๋ฏธ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์— ์กด์žฌํ•˜๋ฏ€๋กœ ์ถ”๊ฐ€ ์กฐํšŒ ์—†์ด ๋ฐ”๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down Expand Up @@ -65,10 +66,36 @@ public static ChallengeGroup create(ChallengeGroupCommand.Create command) {
.content(command.getContent())
.guide(command.getGuide())
.cumulativeCount(0)
.joinStartDate(command.getJoinStartDate())
.joinEndDate(command.getJoinEndDate())
.challenges(challenges)
.build();
command.getCreateChallenges().stream().map(challenge -> Challenge.create(challenge, group))
.forEach(challenges::add);
return group;
}

public ChallengeGroup update(ChallengeGroupCommand.Update command) {
this.category = command.getCategory();
this.title = command.getTitle();
this.content = command.getContent();
this.guide = command.getGuide();
this.joinStartDate = command.getJoinStartDate();
this.joinEndDate = command.getJoinEndDate();
return this;
}

public void addChallenges(List<Challenge> challenges) {
this.challenges.addAll(challenges);
}

public void removeChallenges(List<Challenge> challenges) {
this.challenges.removeAll(challenges);
}

public Optional<Challenge> getChallengeById(Long challengeId) {
return this.challenges.stream()
.filter(challenge -> challenge.getId().equals(challengeId))
.findFirst();
}
}
Loading
Loading