Skip to content

Commit

Permalink
Merge pull request #82 from ClothingStoreService/refactor/remove-mybatis
Browse files Browse the repository at this point in the history
Refactor/remove mybatis
  • Loading branch information
Ogu1208 authored Jul 3, 2024
2 parents ebb2368 + 7b7a930 commit 9f86a80
Show file tree
Hide file tree
Showing 44 changed files with 291 additions and 1,255 deletions.

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/org/store/clothstar/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

//@EnableJpaAuditing
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.store.clothstar.category.domain.Category;
import org.store.clothstar.category.entity.CategoryEntity;

@Getter
@Builder
Expand All @@ -18,8 +18,8 @@ public class CreateCategoryRequest {
@NotBlank(message = "카테고리 타입을 입력해주세요.")
private String categoryType;

public Category toCategory() {
return Category.builder()
public CategoryEntity toCategoryEntity() {
return CategoryEntity.builder()
.categoryType(categoryType)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import lombok.Builder;
import lombok.Getter;
import org.store.clothstar.category.domain.Category;
import org.store.clothstar.category.entity.CategoryEntity;

@Getter
@Builder
public class CategoryDetailResponse {
private Long categoryId;
private String categoryType;

public static CategoryDetailResponse from(Category category) {
public static CategoryDetailResponse from(CategoryEntity category) {
return CategoryDetailResponse.builder()
.categoryId(category.getCategoryId())
.categoryType(category.getCategoryType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import org.store.clothstar.category.domain.Category;
import org.store.clothstar.category.entity.CategoryEntity;

@Repository
public interface CategoryJpaRepository extends JpaRepository<Category, Long> {
public interface CategoryJpaRepository extends JpaRepository<CategoryEntity, Long> {

}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.server.ResponseStatusException;
import org.store.clothstar.category.domain.Category;
import org.store.clothstar.category.dto.request.CreateCategoryRequest;
import org.store.clothstar.category.dto.request.UpdateCategoryRequest;
import org.store.clothstar.category.dto.response.CategoryDetailResponse;
import org.store.clothstar.category.dto.response.CategoryResponse;
import org.store.clothstar.category.repository.CategoryRepository;
import org.store.clothstar.category.entity.CategoryEntity;
import org.store.clothstar.category.repository.CategoryJpaRepository;

import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -19,35 +19,36 @@
@RequiredArgsConstructor
public class CategoryService {

private final CategoryRepository categoryRepository;
private final CategoryJpaRepository categoryRepository;

@Transactional(readOnly = true)
public List<CategoryResponse> getAllCategories() {
return categoryRepository.selectAllCategory().stream()
return categoryRepository.findAll().stream()
.map(CategoryResponse::from)
.collect(Collectors.toList());
}

@Transactional(readOnly = true)
public CategoryDetailResponse getCategory(Long categoryId) {
Category category = categoryRepository.selectCategoryById(categoryId)
CategoryEntity category = categoryRepository.findById(categoryId)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "해당 카테고리를 찾을 수 없습니다."));

return CategoryDetailResponse.from(category);
}

@Transactional
public Long createCategory(CreateCategoryRequest createCategoryRequest) {
Category category = createCategoryRequest.toCategory();
categoryRepository.save(category);
return category.getCategoryId();
CategoryEntity category = createCategoryRequest.toCategoryEntity();
CategoryEntity savedCategory = categoryRepository.save(category);

return savedCategory.getCategoryId();
}

@Transactional
public void updateCategory(Long categoryId, UpdateCategoryRequest updateProductRequest) {
Category category = categoryRepository.selectCategoryById(categoryId)
CategoryEntity category = categoryRepository.findById(categoryId)
.orElseThrow(() -> new ResponseStatusException(HttpStatus.BAD_REQUEST, "해당 카테고리를 찾을 수 없습니다."));
category.updateCategory(updateProductRequest);

categoryRepository.updateCategory(category);
category.updateCategory(updateProductRequest);
}
}

This file was deleted.

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

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.store.clothstar.common.dto.MessageDTO;
import org.store.clothstar.order.dto.reponse.OrderResponse;
import org.store.clothstar.order.entity.OrderEntity;
import org.store.clothstar.order.service.OrderSellerService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.store.clothstar.order.dto.reponse.OrderResponse;
import org.store.clothstar.order.entity.OrderEntity;
import org.store.clothstar.order.repository.order.OrderRepository;
import org.store.clothstar.order.repository.orderSeller.JpaOrderSellerRepository;
import org.store.clothstar.order.repository.orderSeller.OrderSellerRepository;
import org.store.clothstar.order.type.Status;
import org.store.clothstar.orderDetail.service.OrderDetailService;
Expand Down
Loading

0 comments on commit 9f86a80

Please sign in to comment.