-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/#17 blueprint
- Loading branch information
Showing
27 changed files
with
752 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '2.7.12' | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
id 'java' | ||
id 'org.springframework.boot' version '2.7.12' | ||
id 'io.spring.dependency-management' version '1.0.15.RELEASE' | ||
} | ||
|
||
group = 'com.kumofactory' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '17' | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
developmentOnly 'org.springframework.boot:spring-boot-devtools' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
compileOnly 'org.projectlombok:lombok:1.18.24' | ||
annotationProcessor 'org.projectlombok:lombok:1.18.24' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
developmentOnly 'org.springframework.boot:spring-boot-devtools' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
implementation 'mysql:mysql-connector-java:8.0.33' | ||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
compileOnly 'org.projectlombok:lombok:1.18.24' | ||
implementation 'io.jsonwebtoken:jjwt-api:0.11.5' | ||
|
||
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2' | ||
implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2' | ||
implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2' | ||
annotationProcessor 'org.projectlombok:lombok:1.18.24' | ||
|
||
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2' | ||
implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2' | ||
implementation group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2' | ||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
useJUnitPlatform() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/kumofactory/cloud/blueprint/BlueprintController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.kumofactory.cloud.blueprint; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint; | ||
import com.kumofactory.cloud.blueprint.dto.aws.AwsBluePrintDto; | ||
import com.kumofactory.cloud.blueprint.service.AwsBlueprintService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/blueprint") | ||
@Slf4j | ||
public class BlueprintController { | ||
private final Logger logger = LoggerFactory.getLogger(BlueprintController.class); | ||
private final AwsBlueprintService awsBlueprintService; | ||
|
||
// TODO : 토큰에서 유저 정보 가져오는 로직 추가 | ||
// TODO : blueprint list 주는 api 추가 | ||
// TODO : blueprint id 값으로 blueprint 가져오는 api 추가 | ||
@GetMapping("/aws") | ||
public AwsBluePrintDto getAwsBlueprint() { | ||
try { | ||
AwsBluePrintDto awsBlueprint = awsBlueprintService.getAwsBlueprint(); | ||
return awsBlueprint; | ||
} catch (RuntimeException e) { | ||
return null; | ||
} | ||
} | ||
|
||
@PostMapping("/aws") | ||
public String createAwsBlueprint(@RequestBody AwsBluePrintDto awsBluePrintDto) { | ||
awsBlueprintService.store(awsBluePrintDto); | ||
return "hello-world"; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/com/kumofactory/cloud/blueprint/domain/ComponentDot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.kumofactory.cloud.blueprint.domain; | ||
|
||
import com.kumofactory.cloud.blueprint.dto.ComponentDotDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ComponentDot { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@CreationTimestamp | ||
private Date created_at; | ||
@UpdateTimestamp | ||
private Date updated_at; | ||
|
||
private Integer x; // 점의 x 좌표 | ||
private Integer y; // 점의 y 좌표 | ||
private String componentId; // 점이 속한 컴포넌트의 id | ||
|
||
public static ComponentDot createComponentDot(ComponentDotDto componentDotDto) { | ||
ComponentDot componentDot = new ComponentDot(); | ||
componentDot.setComponentId(componentDotDto.getComponentId()); | ||
componentDot.setX(componentDotDto.getX()); | ||
componentDot.setY(componentDotDto.getY()); | ||
return componentDot; | ||
} | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/kumofactory/cloud/blueprint/domain/ComponentLine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.kumofactory.cloud.blueprint.domain; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint; | ||
import com.kumofactory.cloud.blueprint.dto.ComponentLineDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
import javax.persistence.*; | ||
import java.util.Date; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class ComponentLine { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@CreationTimestamp | ||
private Date created_at; | ||
@UpdateTimestamp | ||
private Date updated_at; | ||
|
||
private String ui_id; // Client 에서 생성하는 uuid | ||
@OneToOne(cascade = CascadeType.ALL) | ||
private ComponentDot source; | ||
@OneToOne(cascade = CascadeType.ALL) | ||
private ComponentDot destination; | ||
@ManyToOne | ||
private AwsBluePrint bluePrint; | ||
|
||
public static ComponentLine createComponentLink(ComponentLineDto lineDto, AwsBluePrint bluePrint) { | ||
ComponentLine componentLink = new ComponentLine(); | ||
componentLink.setUi_id(lineDto.getId()); | ||
componentLink.setSource(ComponentDot.createComponentDot(lineDto.getSrc())); | ||
componentLink.setDestination(ComponentDot.createComponentDot(lineDto.getDst())); | ||
componentLink.setBluePrint(bluePrint); | ||
return componentLink; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/kumofactory/cloud/blueprint/domain/aws/AwsBluePrint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.kumofactory.cloud.blueprint.domain.aws; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.ComponentLine; | ||
import com.kumofactory.cloud.member.domain.Member; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import javax.persistence.CascadeType; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.OneToMany; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class AwsBluePrint { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@CreationTimestamp | ||
private Date created_at; | ||
@UpdateTimestamp | ||
private Date updated_at; | ||
|
||
private String name; // 블루프린트 이름 | ||
|
||
@ManyToOne | ||
private Member member; | ||
|
||
@OneToMany(mappedBy = "bluePrint", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY) | ||
private List<AwsComponent> cspComponents; | ||
|
||
@OneToMany(mappedBy = "bluePrint", cascade = CascadeType.REMOVE, fetch = FetchType.LAZY) | ||
private List<ComponentLine> lines; | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/com/kumofactory/cloud/blueprint/domain/aws/AwsComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.kumofactory.cloud.blueprint.domain.aws; | ||
|
||
import com.kumofactory.cloud.blueprint.dto.aws.AwsComponentDto; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
import javax.persistence.*; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.CreationTimestamp; | ||
import org.hibernate.annotations.UpdateTimestamp; | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class AwsComponent { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@CreationTimestamp | ||
private Date created_at; | ||
@UpdateTimestamp | ||
private Date updated_at; | ||
|
||
@Column(unique = true) | ||
private String ui_id; // Client 에서 생성하는 uuid | ||
|
||
@Enumerated(EnumType.STRING) | ||
private AwsComponentType type; // Component 타입 (vm, vpc, subnet, ...) | ||
|
||
// Component 의 좌측 상단 좌표 | ||
private Integer position_x; | ||
private Integer position_y; | ||
|
||
@ManyToOne | ||
private AwsBluePrint bluePrint; | ||
|
||
// ============== 생성함수 ================= // | ||
public static AwsComponent createAwsComponent(AwsComponentDto awsComponentDto, | ||
AwsBluePrint awsBluePrint) { | ||
AwsComponent awsComponent = new AwsComponent(); | ||
awsComponent.setUi_id(awsComponentDto.getId()); | ||
awsComponent.setPosition_x(awsComponentDto.getX()); | ||
awsComponent.setPosition_y(awsComponentDto.getY()); | ||
awsComponent.setType(awsComponentDto.getType()); | ||
awsComponent.setBluePrint(awsBluePrint); | ||
return awsComponent; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/kumofactory/cloud/blueprint/domain/aws/AwsComponentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.kumofactory.cloud.blueprint.domain.aws; | ||
|
||
public enum AwsComponentType { | ||
VPC, SUBNET, ELB, EC2, EFS, WAF, ROUTE53, NAT_GATEWAY, RDS, | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/kumofactory/cloud/blueprint/dto/ComponentDotDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kumofactory.cloud.blueprint.dto; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.ComponentDot; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ComponentDotDto { | ||
private Integer x; | ||
private Integer y; | ||
private String componentId; | ||
|
||
public static ComponentDotDto mapper(ComponentDot componentDot) { | ||
ComponentDotDto componentDotDto = new ComponentDotDto(); | ||
componentDotDto.setX(componentDot.getX()); | ||
componentDotDto.setY(componentDot.getY()); | ||
componentDotDto.setComponentId(componentDot.getComponentId()); | ||
return componentDotDto; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/kumofactory/cloud/blueprint/dto/ComponentLineDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.kumofactory.cloud.blueprint.dto; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.ComponentLine; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
public class ComponentLineDto { | ||
private String id; // Client 에서 생성하는 uuid | ||
private ComponentDotDto src; | ||
private ComponentDotDto dst; | ||
|
||
public static ComponentLineDto mapper(ComponentLine componentLink) { | ||
ComponentLineDto componentLinkDto = new ComponentLineDto(); | ||
componentLinkDto.setId(componentLink.getUi_id()); | ||
componentLinkDto.setSrc(ComponentDotDto.mapper(componentLink.getSource())); | ||
componentLinkDto.setDst(ComponentDotDto.mapper(componentLink.getDestination())); | ||
return componentLinkDto; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/kumofactory/cloud/blueprint/dto/aws/AwsBluePrintDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.kumofactory.cloud.blueprint.dto.aws; | ||
|
||
import com.kumofactory.cloud.blueprint.domain.ComponentLine; | ||
import com.kumofactory.cloud.blueprint.domain.aws.AwsComponent; | ||
import com.kumofactory.cloud.blueprint.dto.ComponentLineDto; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import lombok.Data; | ||
|
||
|
||
@Data | ||
public class AwsBluePrintDto { | ||
|
||
private String name; | ||
private List<AwsComponentDto> components; | ||
private List<ComponentLineDto> links; | ||
|
||
public static List<AwsComponentDto> awsComponentDtosMapper(List<AwsComponent> awsComponentDtos) { | ||
List<AwsComponentDto> awsComponentDtoList = new ArrayList<>(); | ||
for (AwsComponent awsComponent : awsComponentDtos) { | ||
awsComponentDtoList.add(AwsComponentDto.mapper(awsComponent)); | ||
} | ||
return awsComponentDtoList; | ||
} | ||
|
||
public static List<ComponentLineDto> componentLinkDtoListMapper(List<ComponentLine> componentLinks) { | ||
List<ComponentLineDto> componentLinkDtoList = new ArrayList<>(); | ||
for (ComponentLine pointLink : componentLinks) { | ||
componentLinkDtoList.add(ComponentLineDto.mapper(pointLink)); | ||
} | ||
return componentLinkDtoList; | ||
} | ||
} |
Oops, something went wrong.