Skip to content

Commit

Permalink
[BE] 운영 서버 배포 (#579)
Browse files Browse the repository at this point in the history
* refactor: 링크 조회시에도 카테고리 리턴타입 변경

* style: api 엔드포인트 변경

* [BE] 개발(테스트) 서버와 프로덕션 서버 oauth secret분리 (#571)

* fix: cors 오류 해결

* [BE] 잘못된 test yml 수정

* [BE] 개발(테스트) 서버와 프로덕션 서버 oauth secret분리 (#581)

Co-authored-by: Redddy <[email protected]>

---------

Co-authored-by: lemone <[email protected]>
Co-authored-by: 김민종 <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 8c06b01 commit 2738bf4
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/be_cd-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ jobs:
DDL_AUTO=${{ secrets.DDL_AUTO }}
# OAUTH & JWT
CLIENT_ID=${{ secrets.CLIENT_ID }}
CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}
CLIENT_REDIRECT_URI=${{ secrets.CLIENT_REDIRECT_URI }}
CLIENT_ID=${{ secrets.TEST_CLIENT_ID }}
CLIENT_SECRET=${{ secrets.TEST_CLIENT_SECRET }}
CLIENT_REDIRECT_URI=${{ secrets.TEST_CLIENT_REDIRECT_URI }}
JWT_KEY=${{ secrets.JWT_KEY}}
# Server App
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public void configurePathMatch(final PathMatchConfigurer configurer) {
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("*")
.allowedOrigins("http://localhost:3000", "https://coduo.site", "http://coduo.site:443",
"https://test.coduo.site")
.allowedOrigins("http://localhost:3000", "https://coduo.site", "https://test.coduo.site",
"https://api-test.coduo.site/")
.allowCredentials(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public ResponseEntity<CategoryUpdateResponse> updateCategory(
return ResponseEntity.ok(response);
}

@DeleteMapping("/{accessCode}/category/{categoryName}")
@DeleteMapping("/{accessCode}/category/{categoryId}")
public ResponseEntity<Void> deleteCategory(
@PathVariable("accessCode") String accessCode,
@PathVariable("categoryName") Long categoryId
@PathVariable("categoryId") Long categoryId
) {
categoryService.deleteCategory(accessCode, categoryId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public List<CategoryReadResponse> findAllByPairRoomAccessCode(final String acces
public CategoryCreateResponse createCategory(final String accessCode, final CategoryCreateRequest request) {
final PairRoomEntity pairRoomEntity = pairRoomRepository.fetchByAccessCode(new AccessCode(accessCode));
validateDuplicated(request.value(), pairRoomEntity);
final CategoryEntity saved = categoryRepository.save(
final CategoryEntity categoryEntity = categoryRepository.save(
new CategoryEntity(pairRoomEntity, new Category(request.value())));

return new CategoryCreateResponse(saved.getId(), saved.getCategoryName());
return CategoryCreateResponse.from(categoryEntity);
}

private void validateDuplicated(final String categoryName, final PairRoomEntity pairRoomEntity) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package site.coduo.referencelink.service.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import site.coduo.referencelink.repository.CategoryEntity;

@Schema(description = "카테고리 생성 응답")
public record CategoryCreateResponse(
@Schema(description = "카테고리 ID")
Long id,
String id,

@Schema(description = "카테고리 값")
String value
) {

public static CategoryCreateResponse from(final CategoryEntity category) {
return new CategoryCreateResponse(String.valueOf(category.getId()), category.getCategoryName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
@Schema(description = "카테고리 조회 응답")
public record CategoryReadResponse(
@Schema(description = "카테고리 ID", example = "0")
Long id,
String id,

@Schema(description = "카테고리 값", example = "카테고리 없음")
String value
) {

public static CategoryReadResponse from(final CategoryEntity category) {
return new CategoryReadResponse(category.getId(), category.getCategoryName());
return new CategoryReadResponse(String.valueOf(category.getId()), category.getCategoryName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void update_category() {
new CategoryCreateRequest("이전 카테고리"));

final String updateName = "변경된 카테고리";
final CategoryUpdateRequest request = new CategoryUpdateRequest(previousCategory.id(), updateName);
final CategoryUpdateRequest request = new CategoryUpdateRequest(Long.parseLong(previousCategory.id()), updateName);

//when & then
final CategoryUpdateResponse categoryUpdateResponse = RestAssured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void update_category() {

//when
final CategoryUpdateResponse updatedCategory = categoryService.updateCategoryName(ACCESS_CODE.getValue(),
new CategoryUpdateRequest(createdCategory.id(), "파이썬"));
new CategoryUpdateRequest(Long.parseLong(createdCategory.id()), "파이썬"));

//then
final List<CategoryReadResponse> categories = categoryService.findAllByPairRoomAccessCode(
Expand Down Expand Up @@ -144,7 +144,7 @@ void delete_category() {
final List<CategoryReadResponse> beforeDelete = categoryService.findAllByPairRoomAccessCode(
ACCESS_CODE.getValue());

categoryService.deleteCategory(ACCESS_CODE.getValue(), category.id());
categoryService.deleteCategory(ACCESS_CODE.getValue(), Long.parseLong(category.id()));

final List<CategoryReadResponse> afterDelete = categoryService.findAllByPairRoomAccessCode(
ACCESS_CODE.getValue());
Expand Down

0 comments on commit 2738bf4

Please sign in to comment.