feat(customer-vue): 구매자 페이지 수정
- 매장에서 장바구니로 이동하는 기능
This commit is contained in:
@@ -19,7 +19,10 @@ axios.interceptors.request.use(function (config) {
|
||||
config.headers.Authorization = "Bearer " + jwt.getToken();
|
||||
return config;
|
||||
});
|
||||
|
||||
Vue.filter('currency', function (value) {
|
||||
var num = new Number(value);
|
||||
return num.toFixed(0).replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,")
|
||||
});
|
||||
|
||||
axios.interceptors.response.use(
|
||||
(response) => {
|
||||
|
||||
@@ -133,7 +133,7 @@ export default {
|
||||
})
|
||||
.catch(error=>{
|
||||
console.log(error)
|
||||
this.$router.replace("/")
|
||||
this.$router.push("/")
|
||||
})
|
||||
},
|
||||
parseGroup: function (type){
|
||||
@@ -151,10 +151,10 @@ export default {
|
||||
orderApi.addItemToBasket(this.setItem)
|
||||
.then(response=>{
|
||||
console.log(response)
|
||||
this.$router.replace("/store/"+this.storeId)
|
||||
this.$router.push("/store/"+this.storeId)
|
||||
})
|
||||
.catch(error=>{
|
||||
console.log(error)
|
||||
console.log(error.response)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -59,7 +59,7 @@ export default {
|
||||
},
|
||||
toOrder(){
|
||||
if(confirm("주문화면으로 이동할까요?")){
|
||||
this.$router.replace("/order")
|
||||
this.$router.push("/order")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
justify="center"
|
||||
>
|
||||
<v-col class="align-content-center">
|
||||
|
||||
|
||||
<v-form ref="form" lazy-validation>
|
||||
<v-text-field
|
||||
:rules="[v => /.+@.+\..+/.test(v) || 'E-mail must be valid', v => !!v || '이메일은 필수 값입니다']"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
{{ orderItem.itemName }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="mb-5">
|
||||
수량 : {{ orderItem.count }}
|
||||
수량 : {{ orderItem.count| currency }}
|
||||
</v-list-item-subtitle>
|
||||
<div class="text-body-1 mb-5" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">
|
||||
{{ orderItem.orderItemOptionDtoList ?
|
||||
@@ -28,7 +28,7 @@
|
||||
: null}}
|
||||
</div>
|
||||
<div class="text--primary">
|
||||
합계 : <b> {{ orderItem.count * orderItem.price }} 원</b>
|
||||
합계 : <b> {{ orderItem.count * orderItem.price | currency}} 원</b>
|
||||
</div>
|
||||
</v-list-item-content>
|
||||
<v-list-item-avatar
|
||||
@@ -48,7 +48,7 @@
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<div> 합계 : {{orderData.orderPrice}} 원</div>
|
||||
<div> 합계 : {{orderData.orderPrice | currency}} 원</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-btn
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
orderApi.saveOrder()
|
||||
.then(()=>{
|
||||
alert('주문되었습니다.')
|
||||
this.$router.replace("/")
|
||||
this.$router.push("/history")
|
||||
})
|
||||
.catch(error=>{
|
||||
console.log(error)
|
||||
@@ -106,8 +106,7 @@ export default {
|
||||
})
|
||||
.catch(error=>{
|
||||
console.log(error.response)
|
||||
|
||||
// this.$router.replace("/")
|
||||
history.back();
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.justpickup.storeservice.domain.item.web;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.justpickup.storeservice.config.TestConfig;
|
||||
import com.justpickup.storeservice.domain.favoritestore.repository.FavoriteStoreRepository;
|
||||
import com.justpickup.storeservice.domain.item.dto.GetItemDto;
|
||||
import com.justpickup.storeservice.domain.item.dto.ItemDto;
|
||||
import com.justpickup.storeservice.domain.item.service.ItemService;
|
||||
import com.justpickup.storeservice.domain.itemoption.entity.OptionType;
|
||||
import com.justpickup.storeservice.domain.store.repository.StoreRepository;
|
||||
import com.justpickup.storeservice.global.dto.Code;
|
||||
import com.justpickup.storeservice.global.entity.Yn;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.ResultActions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
|
||||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
|
||||
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
|
||||
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@WebMvcTest(ItemCustomerApiController.class)
|
||||
@Import(TestConfig.class)
|
||||
@AutoConfigureRestDocs(uriHost = "just-pickup.com", uriPort = 8000)
|
||||
class ItemCustomerApiControllerTest {
|
||||
|
||||
@Autowired
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
MockMvc mockMvc;
|
||||
|
||||
@MockBean
|
||||
ItemService itemService;
|
||||
|
||||
@MockBean
|
||||
private StoreRepository storeRepository;
|
||||
|
||||
@MockBean
|
||||
private FavoriteStoreRepository favoriteStoreRepository;
|
||||
|
||||
@Test
|
||||
@DisplayName("상품리스트 조회")
|
||||
void getItem() throws Exception {
|
||||
// GIVEN
|
||||
List<String> itemIds = List.of("1","2");
|
||||
List<GetItemDto> willReturnDtoList =
|
||||
List.of(
|
||||
GetItemDto.builder()
|
||||
.id(1L)
|
||||
.salesYn(Yn.Y)
|
||||
.price(1500L)
|
||||
.name("아메리카노")
|
||||
.itemOptions(List.of(
|
||||
GetItemDto.ItemOptionDto.builder()
|
||||
.id(1L)
|
||||
.name("Hot")
|
||||
.optionType(OptionType.REQUIRED)
|
||||
.build()
|
||||
,GetItemDto.ItemOptionDto.builder()
|
||||
.id(2L)
|
||||
.name("add shot")
|
||||
.optionType(OptionType.OTHER)
|
||||
.build()
|
||||
))
|
||||
.build(),
|
||||
GetItemDto.builder()
|
||||
.id(2L)
|
||||
.salesYn(Yn.Y)
|
||||
.price(2500L)
|
||||
.name("카페라테")
|
||||
.itemOptions(List.of(
|
||||
GetItemDto.ItemOptionDto.builder()
|
||||
.id(1L)
|
||||
.name("Hot")
|
||||
.optionType(OptionType.REQUIRED)
|
||||
.build()
|
||||
,GetItemDto.ItemOptionDto.builder()
|
||||
.id(2L)
|
||||
.name("add shot")
|
||||
.optionType(OptionType.OTHER)
|
||||
.build()
|
||||
))
|
||||
.build()
|
||||
);
|
||||
|
||||
|
||||
given(itemService.getItemAndItemOptions(any() ))
|
||||
.willReturn(willReturnDtoList);
|
||||
|
||||
String param = String.join(",", itemIds);
|
||||
|
||||
// WHEN
|
||||
ResultActions actions = mockMvc.perform(get("/api/customer/items/{itemIds}", param));
|
||||
|
||||
// THEN
|
||||
actions.andExpect(status().isOk())
|
||||
.andDo(print())
|
||||
.andDo(document("customer-itemList-get",
|
||||
pathParameters(
|
||||
parameterWithName("itemIds").description("상품 고유 번호리스트")
|
||||
),
|
||||
responseFields(
|
||||
fieldWithPath("code").description("결과 코드 SUCCESS/ERROR"),
|
||||
fieldWithPath("message").description("메시지"),
|
||||
fieldWithPath("data[*].id").description("상품 고유 번호"),
|
||||
fieldWithPath("data[*].name").description("상품 이름"),
|
||||
fieldWithPath("data[*].salesYn").description("화면 표시 여부 Y/N"),
|
||||
fieldWithPath("data[*].price").description("상품 가격"),
|
||||
fieldWithPath("data[*].itemOptions[*].id").description("아이템 옵션 고유 번호"),
|
||||
fieldWithPath("data[*].itemOptions[*].optionType").description("옵션 타입"),
|
||||
fieldWithPath("data[*].itemOptions[*].name").description("옵션명")
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user