Skip to content

Commit

Permalink
feat : username, updateAt 컬럼 추가 in templatePreviewDto, BaseBlueprint 상속
Browse files Browse the repository at this point in the history
  • Loading branch information
nookcoder committed Aug 30, 2023
1 parent 888ade9 commit f8485f9
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 67 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.kumofactory.cloud.blueprint.domain;

import com.kumofactory.cloud.member.domain.Member;
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;

@Getter
@Setter
@NoArgsConstructor
@Entity
public class BaseBluePrint {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@CreationTimestamp
private Date created_at;

@UpdateTimestamp
private Date updated_at;

private String uuid; // Client 에서 생성하는 uuid

private String name; // 블루프린트 이름

private String description; // 블루프린트 설명

private String keyName; // 썸네일 이미지 파일명 (S3)

@Column(columnDefinition = "int default 0")
private Integer downloadCount; // 다운로드 횟수

@Enumerated(EnumType.STRING)
private ProvisionStatus status; // 배포 상태

@Enumerated(EnumType.STRING)
private BluePrintScope scope; // 블루프린트 공개 범위

@ManyToOne
private Member member;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kumofactory.cloud.blueprint.domain.aws;

import com.kumofactory.cloud.blueprint.domain.BaseBluePrint;
import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.ComponentLine;
import com.kumofactory.cloud.blueprint.domain.ProvisionStatus;
Expand All @@ -19,38 +20,7 @@
@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 uuid; // Client 에서 생성하는 uuid

private String name; // 블루프린트 이름

private String description; // 블루프린트 설명

private String keyName; // 썸네일 이미지 파일명 (S3)

@Column(columnDefinition = "int default 0")
private Integer downloadCount; // 다운로드 횟수

@Enumerated(EnumType.STRING)
private ProvisionStatus status; // 배포 상태

@Enumerated(EnumType.STRING)
private BluePrintScope scope; // 블루프린트 공개 범위

@ManyToOne
private Member member;

public class AwsBluePrint extends BaseBluePrint {
@OneToMany(mappedBy = "bluePrint", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<AwsArea> areas;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,44 @@

import com.kumofactory.cloud.blueprint.domain.BluePrintScope;
import com.kumofactory.cloud.blueprint.domain.ProvisionStatus;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@Builder
@Schema(name = "AwsBluePrintListDto", description = "AwsBluePrintListDto")
public class AwsBluePrintListDto {

private Long id;
private String uuid;
private String name;
private String description;
private Long downloadCount;
private Integer downloadCount;
private BluePrintScope scope;
private Date createdAt;
private Date updatedAt;
private String presignedUrl;
private ProvisionStatus status;

public static AwsBluePrintListDto fromAwsBluePrint(AwsBluePrint awsBluePrint, String presignedUrl) {
return AwsBluePrintListDto.builder()
.id(awsBluePrint.getId())
.uuid(awsBluePrint.getUuid())
.name(awsBluePrint.getName())
.description(awsBluePrint.getDescription())
.downloadCount(awsBluePrint.getDownloadCount())
.scope(awsBluePrint.getScope())
.scope(awsBluePrint.getScope())
.createdAt(awsBluePrint.getCreated_at())
.updatedAt(awsBluePrint.getUpdated_at())
.presignedUrl(presignedUrl)
.status(awsBluePrint.getStatus())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@Builder
public class TemplatePreviewDto {
private String uuid;
private String name;
private Date createdAt;
private Date updatedAt;
private String username;
private BluePrintScope scope;
private String presignedUrl;
private String description;
Expand All @@ -21,6 +26,9 @@ public static TemplatePreviewDto mapper(AwsBluePrint bluePrint, String thumbnail
return TemplatePreviewDto.builder()
.uuid(bluePrint.getUuid())
.name(bluePrint.getName())
.createdAt(bluePrint.getCreated_at())
.updatedAt(bluePrint.getUpdated_at())
.username(bluePrint.getMember().getProfileName())
.description(bluePrint.getDescription())
.downloadCount(bluePrint.getDownloadCount())
.scope(bluePrint.getScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

@Repository
public interface AwsBluePrintRepository extends JpaRepository<AwsBluePrint, Long> {
AwsBluePrint findAwsBluePrintById(long id);
AwsBluePrint findAwsBluePrintById(long id);

AwsBluePrint findAwsBluePrintByUuid(String uuid);
AwsBluePrint findAwsBluePrintByUuid(String uuid);

AwsBluePrint findAwsBluePrintByMemberId(long memberId);
AwsBluePrint findAwsBluePrintByMemberId(long memberId);

List<AwsBluePrint> findAllByScopeNot(BluePrintScope scope, Pageable pageable);
List<AwsBluePrint> findAllByScopeNot(BluePrintScope scope, Pageable pageable);

List<AwsBluePrint> findAwsBluePrintsByMember(Member member);
List<AwsBluePrint> findAwsBluePrintsByMember(Member member);

List<AwsBluePrint> findAllByScope(BluePrintScope scope, Pageable pageable);
List<AwsBluePrint> findAllByScope(BluePrintScope scope, Pageable pageable);

List<AwsBluePrint> findAllByNameContainsAndScope(String name, Pageable pageable, BluePrintScope scope);
List<AwsBluePrint> findAllByNameContainsAndScope(String name, Pageable pageable, BluePrintScope scope);

List<AwsBluePrint> findAllByName(String name, Pageable pageable);
List<AwsBluePrint> findAllByName(String name, Pageable pageable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,8 @@ public List<AwsBluePrintListDto> getMyAwsBlueprints(String oauthId) {
List<AwsBluePrint> awsBluePrints = awsBluePrintRepository.findAwsBluePrintsByMember(member);
List<AwsBluePrintListDto> awsBluePrintDtos = new ArrayList<>();
for (AwsBluePrint awsBluePrint : awsBluePrints) {
AwsBluePrintListDto dto = new AwsBluePrintListDto();
dto.setName(awsBluePrint.getName());
dto.setUuid(awsBluePrint.getUuid());
dto.setId(awsBluePrint.getId());
dto.setCreatedAt(awsBluePrint.getCreated_at());
dto.setStatus(awsBluePrint.getStatus());
dto.setScope(awsBluePrint.getScope());
dto.setPresignedUrl(awsS3Helper.getPresignedUrl(awsBluePrint.getKeyName()));
String presignedUrl = awsS3Helper.getPresignedUrl(awsBluePrint.getKeyName());
AwsBluePrintListDto dto = AwsBluePrintListDto.fromAwsBluePrint(awsBluePrint, presignedUrl);
awsBluePrintDtos.add(dto);
}
return awsBluePrintDtos;
Expand Down
37 changes: 19 additions & 18 deletions src/main/java/com/kumofactory/cloud/member/domain/Member.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kumofactory.cloud.member.domain;

import com.kumofactory.cloud.blueprint.domain.BaseBluePrint;
import com.kumofactory.cloud.blueprint.domain.aws.AwsBluePrint;

import java.util.List;
Expand All @@ -20,28 +21,28 @@
@Setter
public class Member {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String oauthId;
private String oauthId;

private String provider;
private String provider;

private String githubAccessToken;
private String githubAccessToken;

private String profileName;
private String profileName;

@OneToMany(mappedBy = "member")
private List<AwsBluePrint> bluePrints;
@OneToMany(mappedBy = "member")
private List<BaseBluePrint> bluePrints;

// =========== 생성함수 =========== //
public static Member createMember(UserInfoDto userInfoDto) {
Member member = new Member();
member.setOauthId(userInfoDto.id());
member.setProvider(userInfoDto.provider());
member.setGithubAccessToken(userInfoDto.accessToken());
member.setProfileName(userInfoDto.profileName());
return member;
}
// =========== 생성함수 =========== //
public static Member createMember(UserInfoDto userInfoDto) {
Member member = new Member();
member.setOauthId(userInfoDto.id());
member.setProvider(userInfoDto.provider());
member.setGithubAccessToken(userInfoDto.accessToken());
member.setProfileName(userInfoDto.profileName());
return member;
}
}

0 comments on commit f8485f9

Please sign in to comment.