Skip to content
This repository was archived by the owner on Aug 13, 2022. It is now read-only.

[#75] 주문 단위테스트 제작 #73

Open
wants to merge 20 commits into
base: delivery_service
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
112 changes: 95 additions & 17 deletions bin/src/main/resources/mybatis/mapper/shop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
delivery_type deliveryType,
signature_menu_id signatureMenuId,
tel,
zipcode,
address,
address_detail addressDetail,
address_code addressCode,
address_detail addressDetail,
biz_number bizNumber,
info,
min_order_price minOrderPrice,
notice,
operating_time operatingTime,
delivery_location deliveryLocation,
owner_id ownerId,
created_at createdAt,
updated_at updatedAt,
Expand All @@ -28,23 +26,34 @@


<insert id="insertShop" parameterType="com.delfood.dto.ShopDTO">
INSERT INTO SHOP(name, delivery_type, signature_menu_id, tel, zipcode, address,
address_detail, biz_number, info, min_order_price, notice, operating_time, delivery_location,
owner_id, order_type, origin_info)
INSERT INTO SHOP(
name,
delivery_type,
signature_menu_id,
tel,
address_code,
address_detail,
biz_number,
info,
min_order_price,
notice,
operating_time,
owner_id,
order_type,
origin_info
)
VALUES(
#{name},
#{deliveryType},
#{signatureMenuId},
#{tel},
#{zipcode},
#{address},
#{addressCode},
#{addressDetail},
#{bizNumber},
#{info},
#{minOrderPrice},
#{notice},
#{operatingTime},
#{deliveryLocation},
#{ownerId},
#{orderType},
#{originInfo}
Expand Down Expand Up @@ -79,17 +88,15 @@
-->
<update id="updateShop">
UPDATE SHOP
SET <if test="name != null">name = #{name},</if>
<if test="deliveryType != null">delivery_type = #{deliveryType},</if>
<if test="signatureMenuId != null">signature_menu_id = #{signatureMenuId},</if>
SET
<if test="tel != null">tel = #{tel},</if>
<if test="deliveryType != null">delivery_type = #{deliveryType},</if>
<if test="operatingTime != null">operating_time = #{operatingTime},</if>
<if test="info != null">info = #{info},</if>
<if test="minOrderPrice != null">min_order_price = #{minOrderPrice},</if>
<if test="originInfo != null">origin_info = #{originInfo},</if>
<if test="notice != null">notice = #{notice},</if>
<if test="operatingTime != null">operating_time = #{operatingTime},</if>
<if test="deliveryLocation != null">delivery_location = #{deliveryLocation},</if>
<if test="minOrderPrice != null">min_order_price = #{minOrderPrice},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="originInfo != null">origin_info = #{originInfo},</if>
updated_at = NOW()

WHERE id = #{id}
Expand All @@ -101,4 +108,75 @@
FROM SHOP
WHERE owner_id = #{ownerId}
</select>

<select id="countByOwnerIdAndShopId" resultType="Integer">
SELECT COUNT(*)
FROM SHOP
WHERE id = #{shopId}
AND owner_id = #{ownerId}
</select>

<select id="countByShopIdAndOwnerId" resultType="long">
SELECT COUNT(*)
FROM SHOP
WHERE id = #{shopId}
AND owner_id = #{ownerId}
</select>

<update id="updateShopOpenById">
UPDATE SHOP
SET work_condition = 'OPEN'
WHERE id = #{shopId}
</update>

<update id="updateShopCloseById">
UPDATE SHOP
SET work_condition = 'CLOSE'
WHERE id=#{shopId}
</update>

<select id="countByIdIsNotOpen" resultType="long">
SELECT COUNT(*)
FROM SHOP
WHERE id = #{shopId}
AND work_condition != 'OPEN'
</select>

<select id="findByTownCode" resultType="com.delfood.dto.ShopDTO">
SELECT A.id,
A.name,
A.delivery_type deliveryType,
A.signature_menu_id signatureMenuId,
A.info,
A.order_type orderType
FROM SHOP A JOIN DELIVERY_LOCATION B
ON A.id = B.shop_id
WHERE A.status != 'DELETE'
AND B.town_code = #{townCode}
ORDER BY work_condition DESC
</select>


<select id="findByBeOpen" resultType="com.delfood.dto.ShopDTO">
SELECT id, name
FROM SHOP
WHERE status != 'DELETE'
AND owner_id = #{ownerId}
AND work_condition = 'CLOSE'
</select>

<select id="findByBeClose" resultType="com.delfood.dto.ShopDTO">
SELECT id, name
FROM SHOP
WHERE status != 'DELETE'
AND owner_id = #{ownerId}
AND work_condition = 'OPEN'
</select>

<select id="findIdAndNameByMenuId" resultType="com.delfood.dto.ItemsBillDTO$ShopInfo">
SELECT s.id, s.name, address_code addressCode
FROM SHOP s JOIN MENU_GROUP g ON (s.id = g.shop_id)
JOIN MENU m ON (g.id = m.menu_group_id)
WHERE m.id = #{menuId}
</select>
</mapper>
1 change: 0 additions & 1 deletion src/main/java/com/delfood/FoodDeliveryApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
@EnableAsync // 메서드를 비동기 방식으로 실행할 수 있도록 설정한다.
@EnableScheduling // 스케줄링을 허용한다.
public class FoodDeliveryApplication {

public static void main(String[] args) {
SpringApplication.run(FoodDeliveryApplication.class, args);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/delfood/dao/FcmDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public class FcmDao {
@Autowired
private ObjectMapper objectMapper;

@Value("#{expire.fcm.rider}")
private static Long riderTokenExpireSecond;
@Value("${expire.fcm.rider}")
private Long riderTokenExpireSecond;

@Value("${expire.fcm.member}")
private static Long memberTokenExpireSecond;
private Long memberTokenExpireSecond;

@Value("${expire.fcm.owner}")
private static Long ownerTokenExpireSecond;
private Long ownerTokenExpireSecond;

/**
* 고객이 발급받은 토큰을 저장한다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public class LocalMemoryDeliveryDao implements DeliveryDao{
private ConcurrentHashMap<String, DeliveryRiderDTO> riders;
private ConcurrentHashMap<Long, OrderStatus> orders;

@Value("rider.expire")
private static Long expireTime;
@Value("${rider.expire}")
private Long expireTime;

@Autowired
private OrderService orderService;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/delfood/dto/ItemDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static class CacheShopDTO {

@Getter
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public static class CacheOptionDTO {
private Long id;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/delfood/dto/OrderDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ public enum OrderStatus {

@Builder
public OrderDTO(String memberId, String addressCode, String addressDetail, Long shopId,
long deliveryCost) {
long deliveryCost, long id) {
this.orderStatus = OrderStatus.BEFORE_PAYMENT;
this.memberId = memberId;
this.addressCode = addressCode;
this.addressDetail = addressDetail;
this.shopId = shopId;
this.deliveryCost = deliveryCost;
this.id = id;
}
}
7 changes: 3 additions & 4 deletions src/main/java/com/delfood/mapper/MemberMapper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.delfood.mapper;

import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.delfood.dto.MemberDTO;

Expand All @@ -12,13 +11,13 @@ public interface MemberMapper {

public int insertMember(MemberDTO memberInfo);

public MemberDTO findByIdAndPassword(String id, String password);
public MemberDTO findByIdAndPassword(@Param("id") String id, @Param("password") String password);

public int updateMemberPassword(String id, String password);

public int deleteMember(String id);

int updateMemberAddress(String id, String addressCode, String addressDetail);
int updateMemberAddress(@Param("id") String id, @Param("addressCode") String addressCode, @Param("addressDetail") String addressDetail);

int idCheck(String id);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/delfood/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public OrderResponse order(String memberId, List<OrderItemDTO> items, long shopI
* @return
*/
@Transactional(propagation = Propagation.NESTED)
private Long doOrder(String memberId, List<OrderItemDTO> items, Long shopId) {
public Long doOrder(String memberId, List<OrderItemDTO> items, Long shopId) {
MemberDTO memberInfo = memberService.getMemberInfo(memberId);
OrderDTO order = OrderDTO
.builder()
Expand Down
Loading