fix(store-service, owner vue): category Dto 리팩토링
-category Dto 에 Store entity가 존재하는것 수정 -owner vue에 category 조회시 error 수정
This commit is contained in:
@@ -56,7 +56,7 @@
|
||||
|
||||
<script>
|
||||
import draggable from 'vuedraggable'
|
||||
import store from "@/api/store";
|
||||
import storeApi from "@/api/store";
|
||||
import {
|
||||
mdiContentSave, mdiDelete,
|
||||
mdiPlus,
|
||||
@@ -103,7 +103,7 @@ export default {
|
||||
let data = {
|
||||
storeId : "1",
|
||||
categoryList: [],
|
||||
deletedList: vm.deletedList
|
||||
deletedList: this.deletedList
|
||||
}
|
||||
|
||||
var categoryEl = document.querySelector("#categoryEl");
|
||||
@@ -116,16 +116,17 @@ export default {
|
||||
data.categoryList.push(category)
|
||||
})
|
||||
|
||||
store.putCategoryList(data)
|
||||
storeApi.putCategoryList(data)
|
||||
.then(function () {
|
||||
vm.deletedList=[]
|
||||
vm.getCategoryList()
|
||||
});
|
||||
|
||||
},
|
||||
getCategoryList:function(){
|
||||
this.deletedList=[]
|
||||
this.categoryList = [];
|
||||
var vm =this;
|
||||
store.getCategoryList()
|
||||
storeApi.getCategoryList()
|
||||
.then(function (response) {
|
||||
vm.categoryList = response.data.data;
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.justpickup.storeservice.domain.category.dto;
|
||||
import com.justpickup.storeservice.domain.category.entity.Category;
|
||||
import com.justpickup.storeservice.domain.category.web.CategoryOwnerApiController;
|
||||
import com.justpickup.storeservice.domain.item.dto.ItemDto;
|
||||
import com.justpickup.storeservice.domain.store.dto.StoreDto;
|
||||
import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import lombok.*;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class CategoryDto {
|
||||
private Long id;
|
||||
private String name;
|
||||
private Integer order;
|
||||
private Store store;
|
||||
private StoreDto storeDto;
|
||||
private List<ItemDto> items;
|
||||
|
||||
|
||||
@@ -37,15 +38,4 @@ public class CategoryDto {
|
||||
this.order = category.getOrder();
|
||||
}
|
||||
|
||||
public static Category createCategory(CategoryDto categoryDto){
|
||||
return Category.createCategory(
|
||||
categoryDto.getId()
|
||||
,categoryDto.getName()
|
||||
, categoryDto.getOrder()
|
||||
, categoryDto.getStore());
|
||||
}
|
||||
|
||||
public void setStore(Store store){
|
||||
this.store=store;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,17 +49,13 @@ public class Category extends BaseEntity {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
private Category (Long id , String name, Integer order, Store store){
|
||||
public Category (Long id , String name, Integer order, Store store){
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.order = order;
|
||||
this.store = store;
|
||||
}
|
||||
|
||||
public static Category createCategory(Long id ,String name, Integer order, Store store){
|
||||
return new Category(id,name,order,store);
|
||||
}
|
||||
|
||||
public static Category of(String name, Integer order, Store store) {
|
||||
Category category = new Category();
|
||||
category.name = name;
|
||||
|
||||
@@ -35,23 +35,21 @@ public class CategoryService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void putCategoryList(Long storeId , List<CategoryDto> categoryDtoList , List<CategoryDto> deletedCategoryDtoList ){
|
||||
public void putCategoryList(Long storeId ,
|
||||
List<CategoryDto> categoryDtoList ,
|
||||
List<CategoryDto> deletedCategoryDtoList ){
|
||||
|
||||
Store store = storeRepository.findById(storeId)
|
||||
.orElseThrow(() -> new NotFoundStoreException(HttpStatus.BAD_REQUEST,"존재하지않는 Store"));
|
||||
|
||||
List<Category> categoryList =categoryDtoList.stream()
|
||||
.map(categoryDto -> {
|
||||
categoryDto.setStore(store);
|
||||
return CategoryDto.createCategory(categoryDto);
|
||||
})
|
||||
.map(categoryDto ->
|
||||
new Category(categoryDto.getId(), categoryDto.getName(), categoryDto.getOrder(), store))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Category> deletedCategoryList =deletedCategoryDtoList.stream()
|
||||
.map(categoryDto -> {
|
||||
categoryDto.setStore(store);
|
||||
return CategoryDto.createCategory(categoryDto);
|
||||
})
|
||||
.map(categoryDto ->
|
||||
new Category(categoryDto.getId(), categoryDto.getName(), categoryDto.getOrder(), store))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
categoryList.forEach(
|
||||
|
||||
@@ -40,7 +40,7 @@ public class FetchItemDto {
|
||||
this.price = item.getPrice();
|
||||
this.categoryDto = new CategoryDto(item.getCategory());
|
||||
this.itemOptions = item.getItemOptions().stream().map(ItemOptionDto::new).collect(Collectors.toList());
|
||||
this.storeDto = new StoreDto(item.getStore().getId(), item.getStore().getName());
|
||||
this.storeDto = new StoreDto(item.getStore().getId(), item.getStore().getName(), item.getStore().getPhoneNumber());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.justpickup.storeservice.domain.item.exception.NotExistItemException;
|
||||
import com.justpickup.storeservice.domain.item.repository.ItemRepository;
|
||||
import com.justpickup.storeservice.domain.item.repository.ItemRepositoryCustom;
|
||||
import com.justpickup.storeservice.domain.itemoption.dto.ItemOptionDto;
|
||||
import com.justpickup.storeservice.domain.itemoption.entity.ItemOption;
|
||||
import com.justpickup.storeservice.domain.itemoption.repository.ItemOptionRepository;
|
||||
import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import com.justpickup.storeservice.domain.store.repository.StoreRepository;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ItemCustomerApiController {
|
||||
this.itemOptions = fetchItemDto.getItemOptions()
|
||||
.stream().map(ItemOptionResponse::new)
|
||||
.collect(Collectors.toList());
|
||||
this.storeId = fetchItemDto.getStoreDto().getStoreId();
|
||||
this.storeId = fetchItemDto.getStoreDto().getId();
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -60,15 +60,12 @@ public class ItemCustomerApiController {
|
||||
|
||||
private OptionType optionType;
|
||||
|
||||
private Long price;
|
||||
|
||||
private String name;
|
||||
|
||||
public ItemOptionResponse(ItemOptionDto itemOptionDto) {
|
||||
|
||||
this.id = itemOptionDto.getId();
|
||||
this.optionType = itemOptionDto.getOptionType();
|
||||
this.price = itemOptionDto.getPrice();
|
||||
this.name = itemOptionDto.getName();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user