Skip to content

Commit d3cffc8

Browse files
committed
feat: Create Week8 Mission
1 parent e05e674 commit d3cffc8

File tree

54 files changed

+1274
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1274
-4
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"mcp__sequential-thinking__sequentialthinking"
5+
],
6+
"deny": [],
7+
"ask": []
8+
}
9+
}

src/main/java/com/example/umc/UmcApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
56

67
@SpringBootApplication
8+
@EnableJpaAuditing
79
public class UmcApplication {
810

911
public static void main(String[] args) {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.umc.domain.category.exception;
2+
3+
import com.example.umc.global.apiPayload.code.BaseErrorCode;
4+
import com.example.umc.global.exception.GeneralException;
5+
6+
public class CategoryException extends GeneralException {
7+
public CategoryException(BaseErrorCode code) {
8+
super(code);
9+
}
10+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.example.umc.domain.category.exception.code;
2+
3+
import com.example.umc.global.apiPayload.code.BaseErrorCode;
4+
import com.example.umc.global.apiPayload.code.ErrorReasonDto;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
import org.springframework.http.HttpStatus;
8+
9+
@Getter
10+
@AllArgsConstructor
11+
public enum CategoryErrorCode implements BaseErrorCode {
12+
13+
CATEGORY_NOT_FOUND(HttpStatus.NOT_FOUND, "CATEGORY404_1", "해당 카테고리를 찾지 못했습니다."),
14+
;
15+
16+
private final HttpStatus status;
17+
private final String code;
18+
private final String message;
19+
20+
@Override
21+
public ErrorReasonDto getReason() {
22+
return ErrorReasonDto.builder()
23+
.isSuccess(false)
24+
.code(code)
25+
.message(message)
26+
.build();
27+
}
28+
29+
@Override
30+
public ErrorReasonDto getReasonHttpStatus() {
31+
return ErrorReasonDto.builder()
32+
.isSuccess(false)
33+
.httpStatus(status)
34+
.code(code)
35+
.message(message)
36+
.build();
37+
}
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.umc.domain.category.repository;
2+
3+
import com.example.umc.domain.category.entity.PreferCategory;
4+
import org.springframework.data.jpa.repository.JpaRepository;
5+
import org.springframework.stereotype.Repository;
6+
7+
@Repository
8+
public interface PreferCategoryRepository extends JpaRepository<PreferCategory, Long> {
9+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.example.umc.domain.member.controller;
2+
3+
import com.example.umc.domain.member.dto.MemberReqDTO;
4+
import com.example.umc.domain.member.dto.MemberResDTO;
5+
import com.example.umc.domain.member.exception.code.MemberSuccessCode;
6+
import com.example.umc.domain.member.service.MemberCommandService;
7+
import com.example.umc.global.apiPayload.ApiResponse;
8+
import io.swagger.v3.oas.annotations.Operation;
9+
import io.swagger.v3.oas.annotations.tags.Tag;
10+
import jakarta.validation.Valid;
11+
import lombok.RequiredArgsConstructor;
12+
import org.springframework.web.bind.annotation.*;
13+
14+
@RestController
15+
@RequestMapping("/api/v1/members")
16+
@RequiredArgsConstructor
17+
@Tag(name = "회원", description = "회원 관련 API")
18+
public class MemberController {
19+
20+
private final MemberCommandService memberCommandService;
21+
22+
// 회원가입
23+
@PostMapping("/signup")
24+
@Operation(summary = "회원가입", description = "새로운 회원을 등록합니다.")
25+
public ApiResponse<MemberResDTO.JoinDTO> signUp(
26+
@RequestBody @Valid MemberReqDTO.JoinDTO dto
27+
) {
28+
MemberResDTO.JoinDTO response = memberCommandService.signup(dto);
29+
return ApiResponse.onSuccess(MemberSuccessCode.MEMBER_CREATED, response);
30+
}
31+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.umc.domain.member.converter;
2+
3+
import com.example.umc.domain.member.dto.MemberReqDTO;
4+
import com.example.umc.domain.member.dto.MemberResDTO;
5+
import com.example.umc.domain.user.entity.User;
6+
7+
public class MemberConverter {
8+
9+
// Entity -> DTO
10+
public static MemberResDTO.JoinDTO toJoinDTO(User member) {
11+
return MemberResDTO.JoinDTO.builder()
12+
.memberId(member.getUserId())
13+
.createdAt(member.getCreatedAt())
14+
.build();
15+
}
16+
17+
// DTO -> Entity
18+
public static User toMember(MemberReqDTO.JoinDTO dto) {
19+
return User.builder()
20+
.name(dto.name())
21+
.birth(dto.birth())
22+
.address(dto.address() != null ? dto.address().toString() : null)
23+
.gender(dto.gender())
24+
.build();
25+
}
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.example.umc.domain.member.dto;
2+
3+
import com.example.umc.domain.user.enums.Gender;
4+
5+
import java.time.LocalDate;
6+
import java.util.List;
7+
8+
public class MemberReqDTO {
9+
public record JoinDTO(
10+
String name,
11+
Gender gender,
12+
LocalDate birth,
13+
String address,
14+
String specAddress,
15+
List<Long> preferCategory
16+
) {}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.example.umc.domain.member.dto;
2+
3+
import lombok.Builder;
4+
5+
import java.time.LocalDateTime;
6+
7+
public class MemberResDTO {
8+
@Builder
9+
public record JoinDTO(
10+
Long memberId,
11+
LocalDateTime createdAt
12+
) {}
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.example.umc.domain.member.exception;
2+
3+
import com.example.umc.global.apiPayload.code.BaseErrorCode;
4+
import com.example.umc.global.exception.GeneralException;
5+
6+
public class MemberException extends GeneralException {
7+
public MemberException(BaseErrorCode code) {
8+
super(code);
9+
}
10+
}

0 commit comments

Comments
 (0)