Skip to content

Commit

Permalink
Revert "[remove] : Remove Attach"
Browse files Browse the repository at this point in the history
  • Loading branch information
oznchex authored Sep 15, 2024
1 parent c065780 commit 193045e
Show file tree
Hide file tree
Showing 22 changed files with 1,156 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package liaison.linkit.profile.domain.attach;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QAttachUrl is a Querydsl query type for AttachUrl
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QAttachUrl extends EntityPathBase<AttachUrl> {

private static final long serialVersionUID = 1845519294L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QAttachUrl attachUrl = new QAttachUrl("attachUrl");

public final StringPath attachUrlName = createString("attachUrlName");

public final StringPath attachUrlPath = createString("attachUrlPath");

public final NumberPath<Long> id = createNumber("id", Long.class);

public final liaison.linkit.profile.domain.QProfile profile;

public QAttachUrl(String variable) {
this(AttachUrl.class, forVariable(variable), INITS);
}

public QAttachUrl(Path<? extends AttachUrl> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}

public QAttachUrl(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}

public QAttachUrl(PathMetadata metadata, PathInits inits) {
this(AttachUrl.class, metadata, inits);
}

public QAttachUrl(Class<? extends AttachUrl> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.profile = inits.isInitialized("profile") ? new liaison.linkit.profile.domain.QProfile(forProperty("profile"), inits.get("profile")) : null;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package liaison.linkit.team.domain.miniprofile;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;
import com.querydsl.core.types.dsl.PathInits;


/**
* QTeamKeyword is a Querydsl query type for TeamKeyword
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QTeamKeyword extends EntityPathBase<TeamKeyword> {

private static final long serialVersionUID = -1972105873L;

private static final PathInits INITS = PathInits.DIRECT2;

public static final QTeamKeyword teamKeyword = new QTeamKeyword("teamKeyword");

public final NumberPath<Long> id = createNumber("id", Long.class);

public final liaison.linkit.team.domain.QTeam team;

public final StringPath teamKeywordNames = createString("teamKeywordNames");

public QTeamKeyword(String variable) {
this(TeamKeyword.class, forVariable(variable), INITS);
}

public QTeamKeyword(Path<? extends TeamKeyword> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}

public QTeamKeyword(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}

public QTeamKeyword(PathMetadata metadata, PathInits inits) {
this(TeamKeyword.class, metadata, inits);
}

public QTeamKeyword(Class<? extends TeamKeyword> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.team = inits.isInitialized("team") ? new liaison.linkit.team.domain.QTeam(forProperty("team"), inits.get("team")) : null;
}

}

52 changes: 52 additions & 0 deletions src/main/java/liaison/linkit/profile/domain/attach/AttachFile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//package liaison.linkit.profile.domain.attach;
//
//import jakarta.persistence.*;
//import liaison.linkit.profile.domain.Profile;
//import liaison.linkit.profile.dto.request.attach.AttachFileUpdateRequest;
//import lombok.AccessLevel;
//import lombok.AllArgsConstructor;
//import lombok.Getter;
//import lombok.NoArgsConstructor;
//
//import static jakarta.persistence.CascadeType.ALL;
//import static jakarta.persistence.FetchType.LAZY;
//
//@Entity
//@Getter
//@AllArgsConstructor
//@NoArgsConstructor(access = AccessLevel.PROTECTED)
//@Table(name = "attach_file")
//public class AttachFile {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "attach_file_id")
// private Long id;
//
// @ManyToOne(fetch = LAZY, cascade = ALL)
// @JoinColumn(name = "profile_id")
// private Profile profile;
//
// @Column(nullable = false)
// private String attachFileName;
//
// @Column(nullable = false)
// private String attachFilePath;
//
// public static AttachFile of(
// final Profile profile,
// final String attachFileName,
// final String attachFilePath
// ) {
// return new AttachFile(
// null,
// profile,
// attachFileName,
// attachFilePath
// );
// }
//
// public void update(final AttachFileUpdateRequest updateRequest) {
// this.attachFilePath = updateRequest.getAttachFilePath();
// }
//}
54 changes: 54 additions & 0 deletions src/main/java/liaison/linkit/profile/domain/attach/AttachUrl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package liaison.linkit.profile.domain.attach;

import jakarta.persistence.*;
import liaison.linkit.profile.domain.Profile;
import liaison.linkit.profile.dto.request.attach.AttachUrlUpdateRequest;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import static jakarta.persistence.FetchType.LAZY;
import static jakarta.persistence.GenerationType.IDENTITY;

@Entity
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "attach_url")
public class AttachUrl {

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "attach_url_id")
private Long id;

@ManyToOne(fetch = LAZY)
@JoinColumn(name = "profile_id")
private Profile profile;

// 웹 링크 이름
@Column(nullable = false)
private String attachUrlName;

@Column(nullable = false)
private String attachUrlPath;

public static AttachUrl of(
final Profile profile,
final String attachUrlName,
final String attachUrlPath
) {
return new AttachUrl(
null,
profile,
attachUrlName,
attachUrlPath
);
}

public void update(final AttachUrlUpdateRequest updateRequest) {
this.attachUrlName = updateRequest.getAttachUrlName();
this.attachUrlPath = updateRequest.getAttachUrlPath();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//package liaison.linkit.profile.domain.repository.attach;
//
//import liaison.linkit.profile.domain.attach.AttachFile;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.query.Param;
//
//import java.util.List;
//
//public interface AttachFileRepository extends JpaRepository<AttachFile, Long> {
// boolean existsByProfileId(final Long profileId);
//
// AttachFile findByProfileId(@Param("profileId") final Long profileId);
//
// @Query("SELECT attachFile FROM AttachFile attachFile WHERE attachFile.profile.id = :profileId")
// List<AttachFile> findAllByProfileId(@Param("profileId") Long profileId);
//}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package liaison.linkit.profile.domain.repository.attach;

import liaison.linkit.profile.domain.attach.AttachUrl;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AttachUrlRepository extends JpaRepository<AttachUrl, Long>, AttachUrlRepositoryCustom{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package liaison.linkit.profile.domain.repository.attach;

import liaison.linkit.profile.domain.attach.AttachUrl;

import java.util.List;
import java.util.Optional;

public interface AttachUrlRepositoryCustom {
Optional<AttachUrl> findByProfileId(final Long profileId);
boolean existsByProfileId(final Long profileId);
List<AttachUrl> findAllByProfileId(final Long profileId);
void deleteAllByProfileId(final Long profileId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package liaison.linkit.profile.domain.repository.attach;

import com.querydsl.jpa.impl.JPAQueryFactory;
import liaison.linkit.profile.domain.attach.AttachUrl;
import liaison.linkit.profile.domain.attach.QAttachUrl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@RequiredArgsConstructor
@Slf4j
public class AttachUrlRepositoryCustomImpl implements AttachUrlRepositoryCustom {

private final JPAQueryFactory jpaQueryFactory;

@Override
public Optional<AttachUrl> findByProfileId(Long profileId) {
QAttachUrl attachUrl = QAttachUrl.attachUrl;

AttachUrl result = jpaQueryFactory
.selectFrom(attachUrl)
.where(attachUrl.profile.id.eq(profileId))
.fetchOne();

return Optional.ofNullable(result);
}

@Override
public boolean existsByProfileId(final Long profileId) {
QAttachUrl attachUrl = QAttachUrl.attachUrl;

long count = jpaQueryFactory
.selectFrom(attachUrl)
.where(attachUrl.profile.id.eq(profileId))
.fetchCount(); // 레코드의 수를 반환

return count > 0; // 0보다 크면 true, 그렇지 않으면 false
}

@Override
public List<AttachUrl> findAllByProfileId(final Long profileId){
QAttachUrl attachUrl = QAttachUrl.attachUrl;
return jpaQueryFactory.selectFrom(attachUrl)
.where(attachUrl.profile.id.eq(profileId))
.fetch();
}


@Override
@Transactional
public void deleteAllByProfileId(final Long profileId){
log.info("Deleting all AttachUrls for profileId: {}", profileId);
QAttachUrl attachUrl = QAttachUrl.attachUrl;
jpaQueryFactory.delete(attachUrl)
.where(attachUrl.profile.id.eq(profileId))
.execute();
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package liaison.linkit.profile.dto.response;

import liaison.linkit.profile.dto.response.antecedents.AntecedentsResponse;
import liaison.linkit.profile.dto.response.attach.AttachResponse;
import liaison.linkit.profile.dto.response.awards.AwardsResponse;
import liaison.linkit.profile.dto.response.completion.CompletionResponse;
import liaison.linkit.profile.dto.response.education.EducationResponse;
import liaison.linkit.profile.dto.response.miniProfile.MiniProfileResponse;
import liaison.linkit.profile.dto.response.onBoarding.JobAndSkillResponse;
import liaison.linkit.profile.dto.response.profileRegion.ProfileRegionResponse;
import liaison.linkit.profile.dto.response.teamBuilding.ProfileTeamBuildingFieldResponse;
import liaison.linkit.profile.dto.response.profileRegion.ProfileRegionResponse;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

Expand All @@ -28,6 +29,7 @@ public class ProfileResponse {
private final List<AntecedentsResponse> antecedentsResponse;
private final List<EducationResponse> educationResponse;
private final List<AwardsResponse> awardsResponse;
private final AttachResponse attachResponse;

public ProfileResponse() {
this.isPrivateProfileEssential = false;
Expand All @@ -40,6 +42,7 @@ public ProfileResponse() {
this.antecedentsResponse = null;
this.educationResponse = null;
this.awardsResponse = null;
this.attachResponse = null;
}

public static ProfileResponse profileItems(
Expand All @@ -52,7 +55,8 @@ public static ProfileResponse profileItems(
final ProfileRegionResponse profileRegionResponse,
final List<AntecedentsResponse> antecedentsResponses,
final List<EducationResponse> educationResponses,
final List<AwardsResponse> awardsResponses
final List<AwardsResponse> awardsResponses,
final AttachResponse attachResponse
) {

return new ProfileResponse(
Expand All @@ -65,7 +69,8 @@ public static ProfileResponse profileItems(
profileRegionResponse,
antecedentsResponses,
educationResponses,
awardsResponses
awardsResponses,
attachResponse
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//package liaison.linkit.profile.dto.response.attach;
//
//import liaison.linkit.profile.domain.attach.AttachFile;
//import lombok.AllArgsConstructor;
//import lombok.Getter;
//
//@Getter
//@AllArgsConstructor
//public class AttachFileResponse {
// private Long id;
// private String attachFileName;
// private String attachFilePath;
//
// public static AttachFileResponse personalAttachFile(
// final AttachFile attachFile
// ) {
// return new AttachFileResponse(
// attachFile.getId(),
// attachFile.getAttachFileName(),
// attachFile.getAttachFilePath()
// );
// }
//}
Loading

0 comments on commit 193045e

Please sign in to comment.