orderList.html 주문상태 option 검색 # 회원명 대표상품 이름 대표상품 주문가격 대표상품 주문수량 상태 일시 CANCEL OrderRepository.java public List findAllByString(OrderSearch orderSearch) { //language = JPQL String jpql = "select o from Order o join o.member m"; boolean isFirstCondition = true; //주문상태 검색 if(orderSearch.getOrderStatus() != null) { if(isFirstCondition) { jpql += " where"; isFirstCondition = false; }else{ jpql += " an..
orderForm.html 주문회원 회원선택 상품명 상품선택 주문수량 Submit orderList.html 주문상태 option 검색 # 회원명 대표상품 이름 대표상품 주문가격 대표상품 주문수량 상태 일시 CANCEL df OrderController.java package com.jpabook.controller; import com.jpabook.domain.Member; import com.jpabook.domain.item.Item; import com.jpabook.service.ItemService; import com.jpabook.service.MemberService; import com.jpabook.service.OrderService; import lombok.RequiredArg..
ItemController.java /** * ITEM 수정을 위한 상세화면 * @param itemId * @param model * @return */ @GetMapping("items/{itemId}/edit") public String updateItemForm(@PathVariable("itemId") Long itemId, Model model) { Book item = (Book) itemService.findOne(itemId); BookForm form = new BookForm(); form.setId(item.getId()); form.setName(item.getName()); form.setPrice(item.getPrice()); form.setStockQuantity(item...
먼저 DTO를 생성한다. BookForm package com.kyhslam.controller; import lombok.Getter; import lombok.Setter; @Setter @Getter public class BookForm { private Long id; private String name; private int price; private int stockQuantity; private String author; private String isbn; } ItemController package com.kyhslam.controller; import com.kyhslam.domain.item.Book; import com.kyhslam.domain.item.Item; import c..
MemberForm package com.kyhslam.controller; import lombok.Getter; import lombok.Setter; import javax.validation.constraints.NotEmpty; @Setter @Getter public class MemberForm { @NotEmpty(message = "회원 이름은 필수입니다.") private String name; private String city; private String street; private String zipcode; } MemberController package com.kyhslam.controller; import com.kyhslam.domain.Address; import com...
thymeleaf 사이트 : www.thymeleaf.org/ Thymeleaf Integrations galore Eclipse, IntelliJ IDEA, Spring, Play, even the up-and-coming Model-View-Controller API for Java EE 8. Write Thymeleaf in your favourite tools, using your favourite web-development framework. Check out our Ecosystem to see more integrati www.thymeleaf.org thymeleaf 튜토리얼 : www.thymeleaf.org/doc/tutorials/3.0/thymeleafspring.html Tuto..
OrderServiceTest package com.jpabook.service; import com.jpabook.domain.Address; import com.jpabook.domain.Member; import com.jpabook.domain.Order; import com.jpabook.domain.OrderStatus; import com.jpabook.domain.item.Book; import com.jpabook.domain.item.Item; import com.jpabook.exception.NotEnoughStockException; import com.jpabook.repository.OrderRepository; import org.junit.Test; import org.ju..
Order package com.jpabook.domain; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import javax.persistence.*; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @Entity @Table(name = "orders") @Setter @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class Order { @Id @GeneratedValue @Column(n..
Order package com.jpabook.domain; import lombok.Getter; import lombok.Setter; import javax.persistence.*; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @Entity @Table(name = "orders") @Setter @Getter public class Order { @Id @GeneratedValue @Column(name="order_id") private Long id; @ManyToOne @JoinColumn(name = "member_id") private Member member; @OneToMany(m..
ItemRepository package com.jpabook.repository; import com.jpabook.domain.item.Item; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import java.util.List; @Repository @RequiredArgsConstructor public class ItemRepository { private final EntityManager em; public void save(Item item) { if(item.getId() == null) { em.per..
package com.jpabook.service; import com.jpabook.domain.Member; import com.jpabook.repository.MemberRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotat..
MemberRepository package com.kyhslam.repository; import com.kyhslam.domain.Member; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import javax.persistence.EntityManager; import java.util.List; @Repository @RequiredArgsConstructor public class MemberRepository { private final EntityManager em; public void save(Member member){ em.persist(member); } public ..