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

[FEAT] CG-01 #9 #18

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a7d740f
feat: ์œ ์ € ๊ธฐ์ดˆ ์ปจํŠธ๋กค๋Ÿฌ ์ž‘์—…
sungyeong98 Jan 24, 2025
907d63f
feat: aspect ์ž‘์„ฑ
sungyeong98 Jan 24, 2025
3671295
feat: Rq ์ž‘์„ฑ
sungyeong98 Jan 24, 2025
89410c7
feat: Security ์ž‘์—…
sungyeong98 Jan 24, 2025
b0befc2
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๊ตฌํ˜„์„ ์œ„ํ•œ ๊ธฐ์ดˆ ํŒŒ์ผ ์ƒ์„ฑ
Gonhub9 Jan 24, 2025
9a13351
feat: ๊ด€๋ฆฌ์ž ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
sungyeong98 Jan 24, 2025
a2b3a46
feat: ์œ ์ € ๊ธฐ์ดˆ ์ปจํŠธ๋กค๋Ÿฌ ์ž‘์—…
sungyeong98 Jan 24, 2025
3a3c5ab
feat: aspect ์ž‘์„ฑ
sungyeong98 Jan 24, 2025
d140257
feat: Rq ์ž‘์„ฑ
sungyeong98 Jan 24, 2025
6179d8b
feat: Security ์ž‘์—…
sungyeong98 Jan 24, 2025
847938b
feat: ๊ด€๋ฆฌ์ž ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
sungyeong98 Jan 24, 2025
7101833
feat: redis ์„ค์ • ์ถ”๊ฐ€
sungyeong98 Jan 25, 2025
aa3a062
Merge remote-tracking branch 'origin/feature/U-02' into feature/U-02
sungyeong98 Jan 25, 2025
e25a12e
feat: CustomUserDetails ์ž‘์„ฑ
sungyeong98 Jan 25, 2025
be2b042
feat: Jwt ์ธ์ฆ ๊ตฌํ˜„
sungyeong98 Jan 25, 2025
ee69994
feat: ์†Œ์…œ ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ ๊ตฌํ˜„
sungyeong98 Jan 25, 2025
f6c8f58
refactor: ์†Œ์…œ ๋กœ๊ทธ์ธ ์‘๋‹ต ํ˜•์‹ ์ˆ˜์ •
sungyeong98 Jan 25, 2025
9917087
feat: ์†Œ์…œ ๋กœ๊ทธ์ธ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
sungyeong98 Jan 27, 2025
a0c2421
refactor: ์ฝ”๋“œ ์ˆ˜์ •
sungyeong98 Jan 27, 2025
3475986
feat: ์†Œ์…œ ๋กœ๊ทธ์ธ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
sungyeong98 Jan 27, 2025
d836978
feat: ์†Œ์…œ ๋กœ๊ทธ์ธ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
sungyeong98 Jan 27, 2025
2bf5902
fix: jwt ํ† ํฐ ์˜ค๋ฅ˜
sungyeong98 Jan 27, 2025
d37c0a2
feat: ํšŒ์›๊ฐ€์ž…, ๋กœ๊ทธ์ธ, ๋กœ๊ทธ์•„์›ƒ ๊ธฐ๋Šฅ ์ตœ์ข… ์™„์„ฑ
sungyeong98 Jan 27, 2025
68b8fe6
comment: ์ปจํŠธ๋กค๋Ÿฌ ๋ฉ”์„œ๋“œ ์ฃผ์„ ์ฒ˜๋ฆฌ
sungyeong98 Jan 27, 2025
bc6435d
chore: build_test.yml ์ œ๊ฑฐ
sungyeong98 Jan 27, 2025
5cff246
feat: ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ, ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋“ฑ๋ก ๊ตฌํ˜„
Gonhub9 Jan 27, 2025
ff00f4e
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜
sungyeong98 Jan 27, 2025
47df405
remove: application-build.yml ์‚ญ์ œ
sungyeong98 Jan 27, 2025
42d8f0a
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๋งคํ•‘ ๋กœ์ง ์ถ”๊ฐ€
Gonhub9 Jan 27, 2025
bc79e88
feat: ๋“ฑ๋ก ์‚ญ์ œ ๋ฐ ์ „์ฒด ์กฐํšŒ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
Gonhub9 Jan 27, 2025
a1e7db5
refactor: GenericResponse ์ˆ˜์ •
kdo1999 Jan 27, 2025
bbf29c4
feat: ์ •์  ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
kdo1999 Jan 27, 2025
aabff3e
refactor: GlobalErrorCode ์—๋Ÿฌ ์ฝ”๋“œ ํƒ€์ž… ๋ณ€๊ฒฝ
kdo1999 Jan 27, 2025
0d528df
refactor: @Getter ์ถ”๊ฐ€
kdo1999 Jan 27, 2025
30c3958
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜
Gonhub9 Jan 27, 2025
2e82d5f
refactor: ์˜ˆ์™ธ ์‘๋‹ต ๋ถ€๋ถ„ ์ˆ˜์ •
kdo1999 Jan 27, 2025
f735063
test: ํ…Œ์ŠคํŠธ ํ™˜๊ฒฝ ํ”„๋กœํ•„ ์„ค์ •
kdo1999 Jan 27, 2025
5bc4324
Merge pull request #20 from prgrms-be-devcourse/refactor/G-01
sungyeong98 Jan 27, 2025
9cf413c
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜ - 2
Gonhub9 Jan 27, 2025
8e646b8
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๊ตฌํ˜„์„ ์œ„ํ•œ ๊ธฐ์ดˆ ํŒŒ์ผ ์ƒ์„ฑ
Gonhub9 Jan 24, 2025
54a5196
feat: ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ, ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋“ฑ๋ก ๊ตฌํ˜„
Gonhub9 Jan 27, 2025
b0f2823
Merge pull request #17 from prgrms-be-devcourse/feature/U-02
sungyeong98 Jan 27, 2025
f518dfe
refactor: ์—๋Ÿฌ ์ฝ”๋“œ ์ž๋ฃŒํ˜• ๋ณ€๊ฒฝ
sungyeong98 Jan 27, 2025
245cc92
Merge pull request #22 from prgrms-be-devcourse/feature/U-02
sungyeong98 Jan 27, 2025
40758cc
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๋งคํ•‘ ๋กœ์ง ์ถ”๊ฐ€
Gonhub9 Jan 27, 2025
f1a5e27
feat: ๋“ฑ๋ก ์‚ญ์ œ ๋ฐ ์ „์ฒด ์กฐํšŒ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
Gonhub9 Jan 27, 2025
93fc640
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜
Gonhub9 Jan 27, 2025
17d39ce
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜ - 2
Gonhub9 Jan 27, 2025
a2bdb63
Merge branch 'feature/CG-01'
Gonhub9 Jan 28, 2025
d7cbceb
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๊ตฌํ˜„์„ ์œ„ํ•œ ๊ธฐ์ดˆ ํŒŒ์ผ ์ƒ์„ฑ
Gonhub9 Jan 24, 2025
2a371b9
feat: ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ, ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋“ฑ๋ก ๊ตฌํ˜„
Gonhub9 Jan 27, 2025
68c7b45
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๋งคํ•‘ ๋กœ์ง ์ถ”๊ฐ€
Gonhub9 Jan 27, 2025
1b6e417
feat: ๋“ฑ๋ก ์‚ญ์ œ ๋ฐ ์ „์ฒด ์กฐํšŒ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
Gonhub9 Jan 27, 2025
9446504
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜
Gonhub9 Jan 27, 2025
77abefb
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜ - 2
Gonhub9 Jan 27, 2025
2fe5efd
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๊ตฌํ˜„์„ ์œ„ํ•œ ๊ธฐ์ดˆ ํŒŒ์ผ ์ƒ์„ฑ
Gonhub9 Jan 24, 2025
c305369
feat: ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ, ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๋“ฑ๋ก ๊ตฌํ˜„
Gonhub9 Jan 27, 2025
66115ff
feat: ์นดํ…Œ๊ณ ๋ฆฌ ๋งคํ•‘ ๋กœ์ง ์ถ”๊ฐ€
Gonhub9 Jan 27, 2025
ba72172
feat: ๋“ฑ๋ก ์‚ญ์ œ ๋ฐ ์ „์ฒด ์กฐํšŒ ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ž‘์„ฑ
Gonhub9 Jan 27, 2025
60427c9
refactor: ์ฝ”๋“œ ๋ฆฌ๋ทฐ ๋ฐ˜์˜
Gonhub9 Jan 27, 2025
1b95887
Merge branch 'feature/CG-01'
Gonhub9 Jan 28, 2025
7d43e72
refactor: AccessLevel PRIVATE
Gonhub9 Jan 28, 2025
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
@@ -0,0 +1,25 @@
package com.backend.category.controller;

import com.backend.category.dto.CategoryDto;
import com.backend.category.service.CategoryService;
import com.backend.global.response.GenericResponse;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/category")
@RequiredArgsConstructor
public class CategoryController {

private final CategoryService categoryService;

// ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ
@GetMapping
public GenericResponse<List<CategoryDto>> getAllCategory() {
List<CategoryDto> categorieList = categoryService.categoryList();
return GenericResponse.of(true, "200", categorieList);
}
}
18 changes: 18 additions & 0 deletions backend/src/main/java/com/backend/category/dto/CategoryDto.java
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„๊นŒ ํ™•์ธ์„ ๋ชปํ–ˆ๋˜ ๋ถ€๋ถ„์ธ๋ฐ Response์šฉ ๊ฐ์ฒด๋Š” ๊ฐ์ฒด๋ช…์„ ๋„๋ฉ”์ธ + Response๋กœ ํ†ต์ผ ์‹œ์ผœ์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ์ˆ˜์ •ํ•ด์„œ ์˜ฌ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค!

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.backend.category.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class CategoryDto {
private Long id;
private String name;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;
}
51 changes: 51 additions & 0 deletions backend/src/main/java/com/backend/category/entity/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.backend.category.entity;

import com.backend.global.baseentity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.validation.constraints.Size;
import java.util.Objects;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Builder
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Category extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
@Size(max = 25)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์œ ํšจ์„ฑ ๊ฒ€์ฆํ•  ๋•Œ ์“ฐ์ด๋Š”๊ฑฐ๋ผ ์ด๋ถ€๋ถ„ ์ œ๊ฑฐํ•ด์ฃผ์‹œ๊ณ  @column(nullable = false, length = 25) ์ด๋ ‡๊ฒŒ ์„ค์ •ํ•ด์ฃผ์‹œ๋ฉด ๋  ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋„ต ์•Œ๊ฒ ์Šต๋‹ˆ๋‹ค ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

private String name;

// category ๊ฐ์ฒด์˜ ๊ฐ’์ด ๋™์ผํ•œ์ง€ ๋น„๊ตํ•˜๋Š” ๋ฉ”์„œ๋“œ
// ํ…Œ์ŠคํŠธ ์ค‘ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ด์„œ ์ถ”๊ฐ€ํ•œ ๋ฉ”์„œ๋“œ
// ์˜ˆ์ƒ ๊ฒฐ๊ณผ์™€ ์‹ค์ œ ๊ฒฐ๊ณผ๋ฅผ ๋น„๊ตํ•  ๋•Œ ์‚ฌ์šฉ
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Category category = (Category) o;
return Objects.equals(id, category.id) && Objects.equals(name, category.name);
}

// equals() ๋ฉ”์„œ๋“œ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉ๋˜๋Š” hashCode() ๋ฉ”์„œ๋“œ
// ์ด ๋ฉ”์„œ๋“œ์—์„œ ๋น„๊ตํ•˜๋Š” ํ•„๋“œ๋“ค์„ ๊ธฐ๋ฐ˜์œผ๋กœ hashCode ๊ฐ’์„ ๊ณ„์‚ฐ, ๊ฐ์ฒด ๋น„๊ต์˜ ์ผ๊ด€์„ฑ์„ ์œ ์ง€
@Override
public int hashCode() {
return Objects.hash(id, name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.backend.category.repository;

import com.backend.category.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;

public interface CategoryRepository extends JpaRepository<Category, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.backend.category.service;

import com.backend.category.dto.CategoryDto;
import com.backend.category.entity.Category;
import com.backend.category.repository.CategoryRepository;
import java.util.List;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class CategoryService {

private final CategoryRepository categoryRepository;

// ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ
public List<CategoryDto> categoryList() {
List<Category> categoryList = categoryRepository.findAll();
return mappingCategory(categoryList);
}

// ์นดํ…Œ๊ณ ๋ฆฌ ๋งคํ•‘
public List<CategoryDto> mappingCategory(List<Category> categoryList) {
return categoryList.stream()
.map(category -> CategoryDto.builder()
.id(category.getId())
.name(category.getName())
.createdAt(category.getCreatedAt().toLocalDateTime())
.modifiedAt(category.getModifiedAt().toLocalDateTime())
.build())
.collect(Collectors.toList());
}
}
50 changes: 50 additions & 0 deletions backend/src/test/java/com/backend/CategoryControllerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.backend;

import static org.assertj.core.api.Assertions.assertThat;

import com.backend.category.dto.CategoryDto;
import com.backend.category.entity.Category;
import com.backend.category.repository.CategoryRepository;
import com.backend.category.service.CategoryService;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class CategoryControllerTest {

@Autowired
private CategoryRepository categoryRepository; // Repository ์ฃผ์ž…

@Autowired
private CategoryService categoryService;

@BeforeEach
void setup() {
// ํ…Œ์ŠคํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์ „์— ์‚ฝ์ž…
categoryRepository.save(Category.builder()
.name("Category 1")
.build());

categoryRepository.save(Category.builder()
.name("Category 2")
.build());
}

@Test
void testCategoryList_shouldReturnCategoryDtos() {
// ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ (DTO ๋ฐ˜ํ™˜)
List<CategoryDto> categoryDtos = categoryService.categoryList();

// ์นดํ…Œ๊ณ ๋ฆฌ ์ „์ฒด ์กฐํšŒ ๊ฒฐ๊ณผ๊ฐ€ 2๊ฐœ์ธ์ง€ ํ™•์ธ
assertThat(categoryDtos.size()).isEqualTo(2);

// ์ฒซ ๋ฒˆ์งธ ์นดํ…Œ๊ณ ๋ฆฌ DTO์˜ name์ด "Category 1"์ธ์ง€ ํ™•์ธ
assertThat(categoryDtos.get(0).getName()).isEqualTo("Category 1");

// ๋‘ ๋ฒˆ์งธ ์นดํ…Œ๊ณ ๋ฆฌ DTO์˜ name์ด "Category 2"์ธ์ง€ ํ™•์ธ
assertThat(categoryDtos.get(1).getName()).isEqualTo("Category 2");
}
}
Loading