목록Spring/Spring Boot (어드민 페이지) 18
Sangwon Coding

JpaConfig.java package com.example.study.config; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @Configuration @EnableJpaAuditing public class JpaConfig { } LoginUserAuditorAware.java package com.example.study.component; import org.springframework.data.domain.AuditorAware; import org.springframework.stereotype..

User.java package com.example.study.model.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; import javax.persistence.*; import java.time.LocalDateTime; import java.util.List; @Data @AllArgsConstructor @NoArgsConstructor @Entity // ==table @ToString(exclude = {"orderGroupList"}) public class User { @Id @GeneratedValue(strategy =..

AdminUserRepositoryTest.java package com.example.study.repository; import com.example.study.StudyApplicationTests; import com.example.study.model.entity.AdminUser; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import java.time.LocalDateTime; public class AdminUserRepositoryTest extends StudyApplicationTests { @Autowired private Adm..

AdminUser.java package com.example.study.model.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import java.time.LocalDateTime; @NoArgsConstructor @AllArgsConstructor @Data @Entity public class AdminUser { @I..

앞으로 만들 어드민 프로젝트의 ERD를 설계합니다. 프로젝트 수행 전 데이터베이스 설계는 필!수! Entity Relation 최종 ERD 실행 쿼리문 -- MySQL Workbench Forward Engineering SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_..

MySql Workbench 의 Database 탭의 Reverse Engineer 를 통해 다음과 같이 ERD 생성. ERD를 완성했으면 Database 탭의 Foward Engineer 를 통해 작업 완료. JPA 연관관계 설정을 위해 관계 어노테이션 및 쿼리메소드를 사용하였다. User.java package com.example.study.model.entity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import javax.persistence.*; import java.time.LocalDateTime; import java.util.List; @Data @AllArgsConst..

UserRepositoryTest.java package com.example.study.repository; import com.example.study.StudyApplicationTests; import com.example.study.model.entity.User; import org.junit.Assert; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import javax.transaction.Transactional; import java.time.LocalDateTime; import java.util.Optional; public class UserRepositoryTest ex..

Camel Case : 단어를 표기할 때 첫 문자는 소문자로 시작하며 띄어쓰기 대신 ( 대문자 )로 단어를 구분 Java의 변수를 선언할 때 camelCase 로 선언한다. ex) phoneNumber , createdAt, updatedAt Snake Case : 단어를 표기할 때 모두 소문자로 표기하며, 띄어쓰기 대신 ( _ ) 로 표기 DB 컬럼에 사용 ex) phone_number , created_at , updated_at API를 정의하기에 따라 다르지만, 주로 API통신 규격에는 구간에서는 Snake Case를 많이 사용 합니다. Entity JPA에서는 테이블을 자동으로 생성해주는 기능 존재. DB Table == JPA Entity Jpa의 Entity 및 column 은 자동으로 ca..