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

deploy - main <- develop #173

Merged
merged 105 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
6fcdd21
fix - #155 μ±Œλ¦°μ§€ μ΅œμ†Œ μ‹œκ°„ μˆ˜μ •
kseysh Jun 11, 2024
94d9c4d
refactor - #164 μ±Œλ¦°μ§€ κΈ°κ°„ 및 λͺ©ν‘œμ‹œκ°„ validate request dtoμ—μ„œ μ§„ν–‰ν•˜λ„λ‘ λ³€κ²½
kseysh Jun 12, 2024
fbe6f92
refactor - #164 challenge 기간을 List둜 κ΄€λ¦¬ν•˜μ—¬ contain λ©”μ„œλ“œλ₯Ό 톡해 validation을 …
kseysh Jun 12, 2024
ee2e7f7
refactor - #164 appcode validation을 DTOμƒμ„±μ‹œμ— μ§„ν–‰ν•˜λ„λ‘ λ³€κ²½
kseysh Jun 12, 2024
fa5529d
refactor - #164 app λͺ©ν‘œ μ‹œκ°„ validation을 DTO 생성 λ‘œμ§μ—μ„œ μ§„ν–‰ν•˜λ„λ‘ λ³€κ²½
kseysh Jun 12, 2024
4110639
refactor - #164 request dto μ œμ•½μ‘°κ±΄ μΆ”κ°€
kseysh Jun 12, 2024
2602926
refactor - #164 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” Error constants 제거
kseysh Jun 12, 2024
017e953
refactor - #164 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” Error constants 제거
kseysh Jun 12, 2024
3f66596
refactor - #164 app time validationμ—μ„œ μ–΄λ…Έν…Œμ΄μ…˜μ—μ„œ μƒμˆ˜λ§Œμ„ μ‚¬μš©ν•΄μ•Όν•˜μ—¬ μƒμ„±μžμ—μ„œ valid…
kseysh Jun 12, 2024
35d0fda
refactor - #164 addChallenge의 λ§€κ°œλ³€μˆ˜ μˆ˜μ •
kseysh Jun 12, 2024
715ee75
Merge branch 'refactor/#164-validation-use-annotation' of https://git…
kseysh Jun 12, 2024
d1c6094
merge - #164 κΉƒμ—μ„œ 꼬인 AppError λ‹€μ‹œ 볡ꡬ
kseysh Jun 12, 2024
bfc6325
refactor - #166 μ‚¬μš©λ˜μ§€ μ•ŠλŠ” μƒμˆ˜ κ°’ μ‚­μ œ
kseysh Jun 18, 2024
9742bda
refactor - #166 μš”κ΅¬μ‚¬ν•­μ— λ§žλ„λ‘ App μ΅œλŒ€ μ‹œκ°„μ„ 2μ‹œκ°„μœΌλ‘œ λ³€κ²½
kseysh Jun 18, 2024
113f53c
refactor - #166 GOAL TIME ERROR 문ꡬ λ³€κ²½
kseysh Jun 18, 2024
1a4a98d
refactor - #166 잘λͺ» μ •μ˜λœ challenge constants λ³€κ²½
kseysh Jun 18, 2024
1f3062a
refactor - #166 AuthController valid μ–΄λ…Έν…Œμ΄μ…˜ 적용
kseysh Jun 18, 2024
38cc570
refactor - #166 ChallengeController valid μ–΄λ…Έν…Œμ΄μ…˜ 적용
kseysh Jun 18, 2024
b433262
refactor - #166 DailyChallengeController valid μ–΄λ…Έν…Œμ΄μ…˜ 적용
kseysh Jun 18, 2024
2ed097e
refactor - #166 PointController @Valid 적용
kseysh Jun 18, 2024
fd415d3
merge - #166 좩돌 병합 ν•΄
kseysh Jun 18, 2024
2622309
Merge pull request #165 from Team-HMH/refactor/#164-validation-use-an…
kseysh Jun 18, 2024
d80fd58
refactor - #122 Request to Entity의 λ©”μ„œλ“œλ‘œ μ½”λ“œ 가독성 ν–₯상
kseysh Jun 18, 2024
6fc7780
refactor - #122 User domain에 μ œμ•½μ‘°κ±΄ μΆ”κ°€
kseysh Jun 18, 2024
9542602
refactor - #122 User domain μ œμ•½μ‘°κ±΄ λ³€κ²½
kseysh Jun 18, 2024
18939dd
refactor - #122 AppService -> HistoryAppService둜 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
9c71768
refactor - #122 ChallengeAppService μΆ”κ°€
kseysh Jun 18, 2024
840ccae
refactor - #122 ChallengeFacade ChallengeService 뢄리
kseysh Jun 18, 2024
373e0be
refactor - #122 toEntity λ©”μ„œλ“œλ₯Ό μ΄μš©ν•˜μ—¬ 가독성 ν–₯상
kseysh Jun 18, 2024
47e2a69
refactor - #122 addHistoryApp 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
0a83bd1
refactor - #122 this μΆ”κ°€λ‘œ μΈν•œ 가독성 ν–₯상
kseysh Jun 18, 2024
f5bd894
refactor - #122 facadeμ—μ„œ facadeλ₯Ό μ°Έμ‘°ν•˜μ§€ μ•Šλ„λ‘ λ³€κ²½
kseysh Jun 18, 2024
4fc7307
refactor - #122 controllerκ°€ ν•˜λ‚˜μ˜ classλ₯Ό 바라보도둝 λ³€κ²½
kseysh Jun 18, 2024
2d770bc
refactor - #122 toEntity λ©”μ„œλ“œλ₯Ό μ΄μš©ν•˜μ—¬ 가독성 ν–₯상
kseysh Jun 18, 2024
376a540
refactor - #122 userService νŠΈλžœμž­μ…˜ 관리
kseysh Jun 18, 2024
b720f6e
refactor - #122 PointFacade νŠΈλžœμž­μ…˜ 관리
kseysh Jun 18, 2024
0aeb0fb
refactor - #122 DailyChallengeController νŠΈλžœμž­μ…˜ 관리
kseysh Jun 18, 2024
49808af
refactor - #122 ChallengeController νŠΈλžœμž­μ…˜ 관리
kseysh Jun 18, 2024
1a1d46a
refactor - #122 ExpiredUserDeleteScheduler νŠΈλžœμž­μ…˜ 관리
kseysh Jun 18, 2024
bd6a674
refactor - #122 AuthServiceμ—μ„œ λΆˆν•„μš”ν•œ Transactional 제거
kseysh Jun 18, 2024
e509d25
refactor - #122 AppServiceμ—μ„œ λΆˆν•„μš”ν•œ Transactional 제거
kseysh Jun 18, 2024
a7accad
refactor - #122 λΆˆν•„μš”ν•œ of λ©”μ„œλ“œ μ‚­μ œ
kseysh Jun 18, 2024
29ed909
refactor - #122 Domain sql λ‚΄λΆ€ nullable μ—¬λΆ€ λͺ…μ‹œ
kseysh Jun 18, 2024
4893720
refactor - #122 Domain λ‚΄λΆ€ @NotNull μ œμ•½μ‘°κ±΄μœΌλ‘œ μΈν•œ validation 적용
kseysh Jun 18, 2024
4354389
refactor - #122 nickname λ³€κ²½ λ©”μ„œλ“œ 이름 λ³€κ²½
kseysh Jun 18, 2024
89edffc
refactor - #122 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” import 제거
kseysh Jun 18, 2024
72deb6b
refactor - #122 λΆˆν•„μš”ν•œ μ½”λ“œ 제거
kseysh Jun 18, 2024
d6f60aa
refactor - #122 λΆˆν•„μš”ν•œ λ³€μˆ˜ 제거
kseysh Jun 18, 2024
56df303
refactor - #122 μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” import 제거
kseysh Jun 18, 2024
08af31c
refactor - #122 cotainsλ₯Ό μ΄μš©ν•œ ν•¨μˆ˜ λ‹¨μˆœν™”
kseysh Jun 18, 2024
78a12bf
refactor - #122 λΆˆν•„μš”ν•œ of ν•¨μˆ˜ 제거
kseysh Jun 18, 2024
ce890e1
refactor - #122 μ˜¨λ³΄λ”© 정보 domain에 NotNull μ œμ•½ 쑰건 μΆ”κ°€
kseysh Jun 18, 2024
dc904c7
refactor - #122 validate λ‹¨μˆœν™” 및 λ³€μˆ˜λͺ… μˆ˜μ •
kseysh Jun 18, 2024
195ce23
refactor - #122 λˆ„λ½λœ userId ν•„λ“œ μΆ”κ°€
kseysh Jun 18, 2024
abdcc8d
refactor - #122 λΆˆν•„μš”ν•œ userService λ©”μ„œλ“œ 호좜 μ€„μž„
kseysh Jun 18, 2024
db0b82b
refactor - #122 AuthFacade 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
6c3eb8d
refactor - #122 Optinal을 μ΄μš©ν•΄ nullλ‘œλΆ€ν„° μ•ˆμ „ν•˜λ„λ‘ μˆ˜μ •
kseysh Jun 18, 2024
00425ac
refactor - #122 가독성을 μœ„ν•œ 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
d4eb82a
refactor - #122 가독성을 μœ„ν•œ 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
d712315
refactor - #122 가독성을 μœ„ν•œ 넀이밍 λ³€κ²½
kseysh Jun 18, 2024
8d432d9
Merge pull request #169 from Team-HMH/refactor/#122-use-facade-pattern
kseysh Jun 21, 2024
0a832ae
feat - #171 AdminController μΆ”κ°€ 및 orderAdminLogin μΆ”κ°€
kseysh Jul 4, 2024
be36779
feat - #171 Admin exception κ΄€λ ¨ μ½”λ“œ μž‘μ„±
kseysh Jul 4, 2024
09e04d8
feat - #171 AdminLoginRequest μΆ”κ°€
kseysh Jul 4, 2024
22eae0c
modify - #171 Admin exception κ΄€λ ¨ λ©”μ‹œμ§€ μˆ˜μ •
kseysh Jul 4, 2024
b898776
fix - #171 잘λͺ» μ •μ˜ν•œ controller μ½”λ“œ μˆ˜μ •
kseysh Jul 4, 2024
9632cce
feat - #171 AdminTokenResponse μ •μ˜
kseysh Jul 4, 2024
94d3c5f
feat - #171 Admin Token 생성 둜직 μΆ”κ°€
kseysh Jul 4, 2024
a746d78
feat - #171 JwtProviderμ—μ„œ Admin Token 제곡 둜직 μΆ”κ°€
kseysh Jul 4, 2024
a181802
feat - #171 JwtConstantsμ—μ„œ ADMIN_ROLE μƒμˆ˜ μ •μ˜
kseysh Jul 4, 2024
53cec3b
feat - #171 JwtError λ©”μ‹œμ§€ μΆ”κ°€
kseysh Jul 5, 2024
d4e52a7
feat - #171 admin token λ°œκΈ‰ λ©”μ„œλ“œ μΆ”κ°€
kseysh Jul 5, 2024
ecd41cf
feat - #171 SecurityConfig에 κ΄€λ¦¬μž 둜그인 url μΆ”κ°€
kseysh Jul 5, 2024
39dc44f
refactor - #171 ν•˜λ“œ μ½”λ”©λœ String μƒμˆ˜ 처리
kseysh Jul 5, 2024
c102037
feat - #171 admin facadeλ₯Ό μ΄μš©ν•΄ κ΄€λ¦¬μž 둜그인 κΈ°λŠ₯ κ΅¬ν˜„
kseysh Jul 5, 2024
e5c7af4
feat - #171 λ°˜ν™˜ νƒ€μž…μ— μ™€μΌλ“œ μΉ΄λ“œ 지양
kseysh Jul 5, 2024
0d0980e
feat - #171 μ¦‰μ‹œ μœ μ €λ₯Ό μ‚­μ œν•˜λŠ” 둜직 μΆ”κ°€
kseysh Jul 5, 2024
46fb3a5
feat - #171 κ΄€λ¦¬μž μœ μ € μ¦‰μ‹œ μ‚­μ œ controller μΆ”κ°€
kseysh Jul 5, 2024
3e606eb
feat - #171 κ΄€λ¦¬μž μœ μ € μ¦‰μ‹œ μ‚­μ œ AdminApi μΆ”κ°€
kseysh Jul 5, 2024
2b3df31
feat - #171 κ΄€λ¦¬μž μœ μ € μ¦‰μ‹œ μ‚­μ œ service λ©”μ„œλ“œ μΆ”κ°€
kseysh Jul 5, 2024
ea3eb9e
modify - #171 doAuthenticationμ‹œμ— subjectλ₯Ό String으둜 받도둝 μˆ˜μ •
kseysh Jul 5, 2024
88f9968
modify - #171 doAuthenticationμ‹œμ— subjectλ₯Ό String으둜 받도둝 μˆ˜μ •
kseysh Jul 5, 2024
4f68e93
feat - #171 admin νƒˆν‡΄ κΈ°λŠ₯ controller κ΅¬ν˜„
kseysh Jul 5, 2024
31bd4d5
feat - #171 AdminUserIdRequest μΆ”κ°€
kseysh Jul 5, 2024
b7f8e0a
modify - #171 μ™€μΌλ“œ μΉ΄λ“œ 지양
kseysh Jul 5, 2024
fe6a8f0
modify - #171 μœ μ € μ‚­μ œ μ‹œ μœ μ €λ₯Ό 찾지 λͺ»ν•˜λ©΄ μ—λŸ¬ λ°œμƒν•˜λ„λ‘ μˆ˜μ •
kseysh Jul 5, 2024
a8d3de9
modify - #171 μœ μ € μ‚­μ œ μ‹œ μœ μ €λ₯Ό 찾지 λͺ»ν•˜λ©΄ μ—λŸ¬ λ°œμƒν•˜λ„λ‘ μˆ˜μ •
kseysh Jul 5, 2024
b522b85
feat - #171 μœ μ € 정보 λ³€κ²½ controller μΆ”κ°€
kseysh Jul 5, 2024
0cf8f92
feat - #171 μœ μ € 정보 λ³€κ²½ request μΆ”κ°€
kseysh Jul 5, 2024
6dbf1d9
refactor - #171 code 가독성 ν–₯상을 μœ„ν•œ 쀄 λ°”κΏˆ
kseysh Jul 5, 2024
a98eb47
feat - #171 admin 토큰인지 ν™•μΈν•˜λŠ” interceptor μΆ”κ°€
kseysh Jul 5, 2024
901c14c
feat - #171 JwtPrefixExtractor μΆ”κ°€
kseysh Jul 5, 2024
407978a
feat - #171 JwtPrefixExtractor μΆ”κ°€
kseysh Jul 5, 2024
252a6fc
feat - #171 κ΄€λ¦¬μž νšŒμ› 정보 λ³€κ²½ λ©”μ„œλ“œ μΆ”
kseysh Jul 5, 2024
98efb1e
refactor - #171 가독성 ν–₯상을 μœ„ν•œ μ€„λ°”κΏˆ
kseysh Jul 5, 2024
f857322
feat - #171 AdminDailyChallengeRequest μ •μ˜
kseysh Jul 5, 2024
178f17a
feat - #171 μœ μ € μ±Œλ¦°μ§€ 정보 λ³€κ²½ controller μ •μ˜
kseysh Jul 5, 2024
8bb9790
feat - #171 challenge id둜 dailyChallengeλ₯Ό μ°ΎλŠ” 둜직 μΆ”κ°€
kseysh Jul 7, 2024
88726fe
feat - #171 dailyChallenge의 정보λ₯Ό λ°”κΎΈλŠ” 둜직 μΆ”κ°€
kseysh Jul 7, 2024
7ba10f4
feat - #171 challenge 기간을 μ°ΎλŠ” 둜직 μΆ”κ°€
kseysh Jul 7, 2024
a1b41fb
feat - #171 dailyChallenge 정보λ₯Ό λ³€κ²½ν•˜λŠ” facade 둜직 μΆ”κ°€
kseysh Jul 7, 2024
16cb21e
refactor - #171 μœ μ € 아이디 리슀트둜 μ—¬λŸ¬ μ±Œλ¦°μ§€λ₯Ό μ‚­μ œν•˜λŠ” λ©”μ„œλ“œ 넀이밍 λ³€κ²½
kseysh Jul 7, 2024
65247c9
modify - #171 userλ₯Ό μ‚­μ œν•  λ•Œ μœ μ €μ™€ μ—°κ΄€λœ challenge도 μ‚­μ œν•˜λ„λ‘ λ³€κ²½
kseysh Jul 7, 2024
bbb95e8
refactor - #171 λΆˆν•„μš”ν•œ int λ³€μˆ˜λ₯Ό forλ¬Έ μ•ˆμœΌλ‘œ λ„£μŒ
kseysh Jul 7, 2024
a489c9a
Merge pull request #172 from Team-HMH/feat/#171-add-admin-api
kseysh Jul 12, 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
24 changes: 24 additions & 0 deletions src/main/java/sopt/org/hmh/domain/admin/controller/AdminApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package sopt.org.hmh.domain.admin.controller;

import io.swagger.v3.oas.annotations.Operation;
import org.springframework.http.ResponseEntity;
import sopt.org.hmh.domain.admin.dto.request.AdminDailyChallengeRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminLoginRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminUserIdRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminUserInfoRequest;
import sopt.org.hmh.domain.admin.dto.response.AdminTokenResponse;
import sopt.org.hmh.global.common.response.BaseResponse;

public interface AdminApi {
@Operation(summary = "κ΄€λ¦¬μž 둜그인")
ResponseEntity<BaseResponse<AdminTokenResponse>> orderAdminLogin(AdminLoginRequest request);

@Operation(summary = "κ΄€λ¦¬μž κΆŒν•œμœΌλ‘œ μœ μ € μ¦‰μ‹œ μ‚­μ œ")
ResponseEntity<Void> orderAdminWithdrawImmediately(AdminUserIdRequest request);

@Operation(summary = "κ΄€λ¦¬μž κΆŒν•œμœΌλ‘œ μœ μ € 정보 λ³€κ²½")
ResponseEntity<Void> orderAdminChangeUserInfo(AdminUserInfoRequest request);

@Operation(summary = "κ΄€λ¦¬μž κΆŒν•œμœΌλ‘œ μœ μ € μ±Œλ¦°μ§€ 정보 λ³€κ²½")
ResponseEntity<Void> orderAdminChangeDailyChallengeInfo(AdminDailyChallengeRequest request);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package sopt.org.hmh.domain.admin.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sopt.org.hmh.domain.admin.dto.request.AdminDailyChallengeRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminLoginRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminUserIdRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminUserInfoRequest;
import sopt.org.hmh.domain.admin.dto.response.AdminTokenResponse;
import sopt.org.hmh.domain.admin.exception.AdminSuccess;
import sopt.org.hmh.domain.admin.service.AdminFacade;
import sopt.org.hmh.global.common.response.BaseResponse;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/admin")
public class AdminController implements AdminApi {

private final AdminFacade adminFacade;

@Override
@PostMapping("/login")
public ResponseEntity<BaseResponse<AdminTokenResponse>> orderAdminLogin(
@RequestBody final AdminLoginRequest request) {
return ResponseEntity
.status(AdminSuccess.ADMIN_LOGIN_SUCCESS.getHttpStatus())
.body(BaseResponse.success(AdminSuccess.ADMIN_LOGIN_SUCCESS,
adminFacade.adminLogin(request.authCode())));
}

@Override
@DeleteMapping("/user")
public ResponseEntity<Void> orderAdminWithdrawImmediately(
@RequestBody @Valid final AdminUserIdRequest request) {
adminFacade.withdrawImmediately(request.userId());
return ResponseEntity
.noContent()
.build();
}

@Override
@PatchMapping("/user")
public ResponseEntity<Void> orderAdminChangeUserInfo(
@RequestBody @Valid final AdminUserInfoRequest request) {
adminFacade.changeUserInfo(request);
return ResponseEntity
.noContent()
.build();
}

@Override
@PatchMapping("/challenge/daily")
public ResponseEntity<Void> orderAdminChangeDailyChallengeInfo(
@RequestBody @Valid final AdminDailyChallengeRequest request) {
adminFacade.changeDailyChallengeInfo(request);
return ResponseEntity
.noContent()
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package sopt.org.hmh.domain.admin.dto.request;

import java.time.LocalDate;
import java.util.List;
import sopt.org.hmh.domain.dailychallenge.domain.Status;

public record AdminDailyChallengeRequest(
Long userId,
LocalDate startDate,
List<Status> statuses
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sopt.org.hmh.domain.admin.dto.request;

public record AdminLoginRequest(
String authCode
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package sopt.org.hmh.domain.admin.dto.request;

public record AdminUserIdRequest(
Long userId
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package sopt.org.hmh.domain.admin.dto.request;

public record AdminUserInfoRequest(
Long userId,
String name,
Integer point
) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package sopt.org.hmh.domain.admin.dto.response;

public record AdminTokenResponse(
String accessToken
) {
}
31 changes: 31 additions & 0 deletions src/main/java/sopt/org/hmh/domain/admin/exception/AdminError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package sopt.org.hmh.domain.admin.exception;

import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import sopt.org.hmh.global.common.exception.base.ErrorBase;

@AllArgsConstructor
public enum AdminError implements ErrorBase {

// 401 UNAUTHORIZED
INVALID_ADMIN_AUTH_CODE(HttpStatus.UNAUTHORIZED, "κ΄€λ¦¬μž 인증 λ²ˆν˜Έκ°€ μΌμΉ˜ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
;

private final HttpStatus status;
private final String errorMessage;

@Override
public int getHttpStatusCode() {
return this.status.value();
}

@Override
public HttpStatus getHttpStatus() {
return this.status;
}

@Override
public String getErrorMessage() {
return this.errorMessage;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package sopt.org.hmh.domain.admin.exception;

import sopt.org.hmh.global.common.exception.base.ExceptionBase;

public class AdminException extends ExceptionBase {

public AdminException(AdminError errorBase) {
super(errorBase);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package sopt.org.hmh.domain.admin.exception;

import lombok.AllArgsConstructor;
import org.springframework.http.HttpStatus;
import sopt.org.hmh.global.common.exception.base.SuccessBase;

@AllArgsConstructor
public enum AdminSuccess implements SuccessBase {

// 200 OK
ADMIN_LOGIN_SUCCESS(HttpStatus.OK, "κ΄€λ¦¬μž λ‘œκ·ΈμΈμ— μ„±κ³΅ν–ˆμŠ΅λ‹ˆλ‹€."),

// 204 NO CONTENT
ADMIN_WITHDRAW_IMMEDIATELY_SUCCESS(HttpStatus.NO_CONTENT, "κ΄€λ¦¬μž κΆŒν•œμœΌλ‘œ μœ μ € μ¦‰μ‹œ μ‚­μ œμ— μ„±κ³΅ν–ˆμŠ΅λ‹ˆλ‹€."),
;

private final HttpStatus status;
private final String successMessage;

@Override
public int getHttpStatusCode() {
return this.status.value();
}

@Override
public HttpStatus getHttpStatus() {
return this.status;
}

@Override
public String getSuccessMessage() {
return this.successMessage;
}
}
81 changes: 81 additions & 0 deletions src/main/java/sopt/org/hmh/domain/admin/service/AdminFacade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package sopt.org.hmh.domain.admin.service;

import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import sopt.org.hmh.domain.admin.dto.request.AdminDailyChallengeRequest;
import sopt.org.hmh.domain.admin.dto.request.AdminUserInfoRequest;
import sopt.org.hmh.domain.admin.dto.response.AdminTokenResponse;
import sopt.org.hmh.domain.admin.exception.AdminError;
import sopt.org.hmh.domain.admin.exception.AdminException;
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeError;
import sopt.org.hmh.domain.challenge.domain.exception.ChallengeException;
import sopt.org.hmh.domain.challenge.service.ChallengeService;
import sopt.org.hmh.domain.dailychallenge.domain.Status;
import sopt.org.hmh.domain.dailychallenge.service.DailyChallengeService;
import sopt.org.hmh.domain.user.domain.User;
import sopt.org.hmh.domain.user.service.UserService;
import sopt.org.hmh.global.auth.jwt.TokenService;

@Service
@RequiredArgsConstructor
public class AdminFacade {

@Value("${jwt.admin-auth-code}")
private String adminAuthCode;

private final UserService userService;
private final TokenService tokenService;
private final ChallengeService challengeService;
private final DailyChallengeService dailyChallengeService;

public AdminTokenResponse adminLogin(String authCode) {
validateAdminAuthCode(authCode);
return new AdminTokenResponse(tokenService.issueAdminToken());
}

private void validateAdminAuthCode(String authCode) {
if (!adminAuthCode.equals(authCode)) {
throw new AdminException(AdminError.INVALID_ADMIN_AUTH_CODE);
}
}

@Transactional
public void withdrawImmediately(Long userId) {
userService.checkIsExistUserId(userId);
challengeService.deleteChallengeRelatedByUserId(userId);
userService.withdrawImmediately(userId);
}

@Transactional
public void changeUserInfo(AdminUserInfoRequest request) {
User user = userService.findByIdOrThrowException(request.userId());
if (Objects.nonNull(request.point())) {
user.changePoint(request.point());
}
if (Objects.nonNull(request.name())) {
user.changeName(request.name());
}
}

@Transactional
public void changeDailyChallengeInfo(AdminDailyChallengeRequest request) {
Long currentChallengeId = userService.getCurrentChallengeIdByUserId(request.userId());
List<Status> statuses = request.statuses();
LocalDate challengeDate = request.startDate();

validateStatusesPeriod(currentChallengeId, statuses);
dailyChallengeService.changeInfoOfDailyChallenges(currentChallengeId, statuses, challengeDate);
}

private void validateStatusesPeriod(Long challengeId, List<Status> statuses) {
Integer challengePeriod = challengeService.getChallengePeriod(challengeId);
if (challengePeriod != statuses.size()) {
throw new ChallengeException(ChallengeError.INVALID_PERIOD_NUMERIC);
}
}
}
3 changes: 3 additions & 0 deletions src/main/java/sopt/org/hmh/domain/app/domain/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;

@Getter
Expand All @@ -14,7 +15,9 @@ public abstract class App {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@NotNull(message = "osλŠ” null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
protected String os;

@NotNull(message = "appCodeλŠ” null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
protected String appCode;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public abstract class AppConstants {
public static final Long MINIMUM_APP_TIME = 0L;
public static final Long MAXIMUM_APP_TIME = 21_600_000L; // 6μ‹œκ°„
public static final Long MAXIMUM_APP_TIME = 7_200_000L; // 2μ‹œκ°„
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sopt.org.hmh.domain.app.domain;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -16,6 +17,7 @@ public class ChallengeApp extends App {
@JoinColumn(name = "challenge_id")
private Challenge challenge;

@NotNull(message = "λͺ©ν‘œ μ‹œκ°„μ€ null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
private Long goalTime;

@Builder
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/sopt/org/hmh/domain/app/domain/HistoryApp.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sopt.org.hmh.domain.app.domain;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -16,7 +17,10 @@ public class HistoryApp extends App {
@JoinColumn(name = "daily_challenge_id")
private DailyChallenge dailyChallenge;

@NotNull(message = "μ‚¬μš© μ‹œκ°„μ€ null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
private Long usageTime;

@NotNull(message = "λͺ©ν‘œ μ‹œκ°„μ€ null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
private Long goalTime;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ public enum AppError implements ErrorBase {

APP_NOT_FOUND(HttpStatus.NOT_FOUND, "앱을 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
APP_EXIST_ALREADY(HttpStatus.CONFLICT, "이미 μΆ”κ°€λœ μ•±μž…λ‹ˆλ‹€."),
INVALID_APP_CODE_NULL(HttpStatus.BAD_REQUEST, "μ•± μ½”λ“œ 값이 λΉ„μ–΄μžˆμŠ΅λ‹ˆλ‹€"),
INVALID_TIME_RANGE(HttpStatus.BAD_REQUEST, "μ•± μ‹œκ°„μ˜ λ²”μœ„κ°€ μœ νš¨ν•œμ§€ ν™•μΈν•΄μ£Όμ„Έμš”"),
INVALID_TIME_NULL(HttpStatus.BAD_REQUEST, "μ•± μ‹œκ°„μ„ μž…λ ₯ν•΄μ£Όμ„Έμš”"),
INVALID_GOAL_TIME(HttpStatus.BAD_REQUEST, "μ•± λͺ©ν‘œ μ‹œκ°„μ΄ μœ νš¨ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€."),
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package sopt.org.hmh.domain.app.dto.request;

import jakarta.validation.constraints.NotNull;

public record AppRemoveRequest(
@NotNull(message = "μ•± μ½”λ“œλŠ” null일 수 μ—†μŠ΅λ‹ˆλ‹€.")
String appCode
) {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package sopt.org.hmh.domain.app.dto.request;

import jakarta.validation.Valid;
import java.util.List;

public record ChallengeAppArrayRequest(
List<ChallengeAppRequest> apps
List<@Valid ChallengeAppRequest> apps
) {
}
Loading
Loading