Add: DB 설계 및 구현
This commit is contained in:
19
ReadMe.md
19
ReadMe.md
@@ -1,2 +1,19 @@
|
|||||||
# UrlShortener
|
# UrlShortener
|
||||||
원본 URL을 짧게 요약시키는 시스템
|
원본 URL을 짧게 단축시키는 시스템
|
||||||
|
### Use Skill tree
|
||||||
|
| | Skills |
|
||||||
|
|---|---|
|
||||||
|
| <b>Back-End</b> | Spring Framework(MVC, JPA) |
|
||||||
|
| <b>Front-End</b> | Thyme-leaf |
|
||||||
|
| <b>Infra</b> | Linux, MariaDB |
|
||||||
|
### 주요 기능
|
||||||
|
1. 긴 원본 URL을 짧은 형태나 사용자가 희망하는 단어의 형태로 URL 단축
|
||||||
|
2. 단축된 URL로 접속 시도 시, (존재하는 URL의 경우) 원본 URL로 Redirect 처리
|
||||||
|
3. 정상적인 HTTP(HTTPS) URL인지 검증한 후 단축 진행
|
||||||
|
4. 단축 URL을 특정 기간에만 유지되도록 하고, 특정 기간을 경과하면 접속 차단<br>
|
||||||
|
### 구현 현황
|
||||||
|
- [x] 개발 환경 구축
|
||||||
|
- [x] DB 설계 및 Entity 구현
|
||||||
|
- [x] URL 단축 알고리즘 구현
|
||||||
|
- [ ] URL 단축 저장 및 조회 기능 구현
|
||||||
|
- [ ] 테스트 및 배포
|
||||||
23
pom.xml
23
pom.xml
@@ -38,10 +38,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
@@ -50,10 +50,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.thymeleaf.extras</groupId>
|
<groupId>org.thymeleaf.extras</groupId>
|
||||||
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -61,12 +61,12 @@
|
|||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-docker-compose</artifactId>
|
<artifactId>spring-boot-docker-compose</artifactId>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
<artifactId>mariadb-java-client</artifactId>
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
@@ -80,17 +80,24 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<scope>test</scope>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.restdocs</groupId>
|
<groupId>org.springframework.restdocs</groupId>
|
||||||
<artifactId>spring-restdocs-mockmvc</artifactId>
|
<artifactId>spring-restdocs-mockmvc</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.springframework.security</groupId>
|
<groupId>org.springframework.security</groupId>
|
||||||
<artifactId>spring-security-test</artifactId>
|
<artifactId>spring-security-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
</dependency> -->
|
||||||
|
|
||||||
|
<!-- Base62 Library -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.seruco.encoding</groupId>
|
||||||
|
<artifactId>base62</artifactId>
|
||||||
|
<version>0.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
29
sql/DDL.sql
Normal file
29
sql/DDL.sql
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
CREATE DATABASE `hangyub_url_shortener`;
|
||||||
|
|
||||||
|
USE hangyub_url_shortener;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS url_map;
|
||||||
|
DROP TABLE IF EXISTS users;
|
||||||
|
|
||||||
|
CREATE TABLE `users`(
|
||||||
|
`user_id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`user_email` VARCHAR(100) NOT NULL,
|
||||||
|
`user_password` VARCHAR(30) NOT NULL,
|
||||||
|
`user_nickname` VARCHAR(20) NOT NULL,
|
||||||
|
`user_created_at` DATETIME NOT NULL,
|
||||||
|
PRIMARY KEY(user_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `url_map`(
|
||||||
|
`url_map_id` INT NOT NULL AUTO_INCREMENT,
|
||||||
|
`url_map_original` VARCHAR(255) NOT NULL,
|
||||||
|
`url_map_short` VARCHAR(7) NOT NULL,
|
||||||
|
`url_map_is_active` TINYINT(1) NOT NULL,
|
||||||
|
`user_id` INT NULL,
|
||||||
|
`url_map_click` INT NOT NULL DEFAULT 0,
|
||||||
|
`url_map_created_at` DATETIME NOT NULL,
|
||||||
|
`url_map_edited_at` DATETIME NOT NULL,
|
||||||
|
`url_map_expired_at` DATETIME NULL,
|
||||||
|
PRIMARY KEY(url_map_id),
|
||||||
|
FOREIGN KEY(user_id) REFERENCES users(user_id)
|
||||||
|
);
|
||||||
29
src/main/java/be/gyu/urlShortener/entity/UrlMap.java
Normal file
29
src/main/java/be/gyu/urlShortener/entity/UrlMap.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package be.gyu.urlShortener.entity;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Getter
|
||||||
|
public class UrlMap {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
private int urlMapId;
|
||||||
|
private String urlMapOriginal;
|
||||||
|
private String urlMapShort;
|
||||||
|
private boolean urlMapIsActive;
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name="user_id")
|
||||||
|
private Users user;
|
||||||
|
private int urlMapClick;
|
||||||
|
private LocalDateTime urlMapCreatedAt;
|
||||||
|
private LocalDateTime urlMapEditedAt;
|
||||||
|
private LocalDateTime urlMapExpiredAt;
|
||||||
|
}
|
||||||
21
src/main/java/be/gyu/urlShortener/entity/Users.java
Normal file
21
src/main/java/be/gyu/urlShortener/entity/Users.java
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package be.gyu.urlShortener.entity;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Getter
|
||||||
|
public class Users {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
private int userId;
|
||||||
|
private String userEmail;
|
||||||
|
private String userPassword;
|
||||||
|
private String userNickname;
|
||||||
|
private LocalDateTime userCreatedAt;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user