Skip to content

Commit

Permalink
Merge pull request #231 from TripInfoWeb/develop
Browse files Browse the repository at this point in the history
Release : 솔리투어 v1.0.1
  • Loading branch information
hyeonjaez authored Oct 12, 2024
2 parents 2d453e9 + f2ee628 commit 86ec6de
Show file tree
Hide file tree
Showing 25 changed files with 1,114 additions and 312 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ Temporary Items

# 설정 파일
/src/main/resources/**.yml
/src/main/resources
/src/main/resources/**.properties
31 changes: 23 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}

repositories {
mavenCentral()
}

ext {
set('snippetsDir', file("build/generated-snippets"))
set('snippetsDir', file("src/dos")) // 변경된 경로
}

dependencies {
Expand All @@ -34,7 +35,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'


implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
Expand All @@ -48,13 +48,12 @@ dependencies {
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.5.Final'

implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
// queryDsl 라이브러리
annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

runtimeOnly 'com.mysql:mysql-connector-j'

asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
Expand All @@ -68,9 +67,25 @@ tasks.named('test') {

tasks.named('asciidoctor') {
inputs.dir snippetsDir
dependsOn test
// dependsOn test 를 제거하여 순환 종속성을 피합니다.
}

asciidoctor {
configurations 'asciidoctorExt'
baseDirFollowsSourceFile()
inputs.dir snippetsDir
}

asciidoctor.doFirst {
delete file('src/main/resources/docs')
}

task copyDocument(type: Copy) {
from file("build/docs/asciidoc")
into file("src/main/resources/docs")
}

//clean {
// delete file('src/main/generated')
//}
// build 작업에 copyDocument를 추가합니다.
build {
dependsOn copyDocument
}
11 changes: 11 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
= Solitour -Resource

:doctype: book
:toc: left
:toclevels: 3
:sectnums:
:numbered:


// [[api]]
// includ::ee.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public ResponseEntity<Void> logout(HttpServletResponse response, @Authentication
return ResponseEntity.ok().build();
}


@PostMapping("/token/refresh")
public ResponseEntity<Void> reissueAccessToken(HttpServletResponse response,
@AuthenticationRefreshPrincipal Long memberId) {
Expand Down
45 changes: 45 additions & 0 deletions src/main/java/solitour_backend/solitour/auth/entity/Term.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package solitour_backend.solitour.auth.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import solitour_backend.solitour.user.entity.User;

@Getter
@NoArgsConstructor
@Entity
@Builder
@AllArgsConstructor
@Table(name = "term")
public class Term {

@Id
@Column(name = "term_id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

@Column(nullable = false, name = "term_condition_agreement")
private Boolean termCondition;

@Column(nullable = false, name = "term_privacy_agreement")
private Boolean termPrivacy;

@Column(name="term_created_at")
private LocalDateTime createdAt;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package solitour_backend.solitour.auth.entity;

import java.util.Optional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import solitour_backend.solitour.user.entity.User;

public interface TermRepository extends Repository<Term, Long> {
void save(Term term);

@Query("SELECT t FROM Term t WHERE t.user = :user")
<T> Optional<T> findByUser(User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ private void checkUserStatus(User user) {
}
}

private void saveToken(KakaoTokenResponse tokenResponse, User user) {
Token token = Token.builder()
.user(user)
.oauthToken(tokenResponse.getRefreshToken())
.build();

tokenRepository.save(token);
}

private User saveGoogleUser(GoogleUserResponse response) {
String imageUrl = getGoogleUserImage(response);
UserImage savedUserImage = userImageService.saveUserImage(imageUrl);
Expand Down Expand Up @@ -258,7 +267,7 @@ private User saveActiveKakaoUser(KakaoUserResponse kakaoUserResponse, CreateUser
UserImage savedUserImage = userImageService.saveUserImage(imageUrl);

User user = User.builder()
.userStatus(UserStatus.ACTIVATE)
.userStatus(UserStatus.PENDING)
.oauthId(String.valueOf(kakaoUserResponse.getId()))
.provider("kakao")
.isAdmin(false)
Expand All @@ -279,7 +288,7 @@ private User saveKakaoUser(KakaoUserResponse response) {
UserImage savedUserImage = userImageService.saveUserImage(imageUrl);

User user = User.builder()
.userStatus(UserStatus.INACTIVATE)
.userStatus(UserStatus.PENDING)
.oauthId(String.valueOf(response.getId()))
.provider("kakao")
.isAdmin(false)
Expand Down Expand Up @@ -337,7 +346,6 @@ private void deleteCookie(String name, String value, HttpServletResponse respons
response.addCookie(cookie);
}


public void revokeToken(String type, String token) throws IOException {
HttpStatusCode responseCode;
switch (type) {
Expand Down Expand Up @@ -376,15 +384,15 @@ private String getDefaultProfile(User user) {
return USER_PROFILE_NONE;
}

private void deleteUserProfileFromS3 (UserImage userImage, String defaultImageUrl){
String userImageUrl = userImage.getAddress();
if (userImageUrl.equals(USER_PROFILE_MALE) || userImageUrl.equals(USER_PROFILE_FEMALE)
|| userImageUrl.equals(
USER_PROFILE_NONE)) {
return;
}
s3Uploader.deleteImage(userImageUrl);
userImage.changeToDefaultProfile(defaultImageUrl);
private void deleteUserProfileFromS3(UserImage userImage, String defaultImageUrl) {
String userImageUrl = userImage.getAddress();
if (userImageUrl.equals(USER_PROFILE_MALE) || userImageUrl.equals(USER_PROFILE_FEMALE)
|| userImageUrl.equals(
USER_PROFILE_NONE)) {
return;
}

s3Uploader.deleteImage(userImageUrl);
userImage.changeToDefaultProfile(defaultImageUrl);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public void updateDiary(Long userId, Long diaryId, DiaryUpdateRequest request) {
}

private void updateDiary(Long diaryId, DiaryUpdateRequest request) {
Diary diary = diaryRepository.findById(diaryId).orElseThrow(() -> new DiaryNotExistsException("해당 일기가 존재하지 않습니다."));
Diary diary = diaryRepository.findById(diaryId)
.orElseThrow(() -> new DiaryNotExistsException("해당 일기가 존재하지 않습니다."));
deleteDiaryImage(request);
diary.getDiaryDayContent().clear();
diary.updateDiary(request);
Expand All @@ -103,6 +104,7 @@ private void updateDiary(Long diaryId, DiaryUpdateRequest request) {

private void saveDiaryDayContent(Diary savedDiary, DiaryCreateRequest request) {
for (DiaryDayRequest dayRequest : request.getDiaryDayRequests()) {
makeDiaryImagePermanent(dayRequest.getDiaryDayContentImages());
DiaryDayContent diaryDayContent = DiaryDayContent.builder()
.diary(savedDiary)
.content(dayRequest.getContent())
Expand All @@ -114,6 +116,15 @@ private void saveDiaryDayContent(Diary savedDiary, DiaryCreateRequest request) {
}
}

private void makeDiaryImagePermanent(String diaryDayContentImages) {
if (!diaryDayContentImages.isEmpty()) {
String[] contentImages = diaryDayContentImages.split(",");
for (String contentImage : contentImages) {
s3Uploader.markImagePermanent(contentImage);
}
}
}

private void updateDiaryDayContent(Diary savedDiary, DiaryUpdateRequest request) {
diaryDayContentRepository.deleteById(savedDiary.getId());
for (DiaryUpdateDayRequest dayRequest : request.getDiaryDayRequests()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import solitour_backend.solitour.auth.config.Authenticated;
import solitour_backend.solitour.auth.config.AuthenticationPrincipal;
import solitour_backend.solitour.auth.exception.TokenNotExistsException;
import solitour_backend.solitour.auth.exception.TokenNotValidException;
import solitour_backend.solitour.auth.support.CookieExtractor;
import solitour_backend.solitour.auth.support.JwtTokenProvider;
import solitour_backend.solitour.error.Utils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

@Getter
@AllArgsConstructor
@ToString
public class InformationBriefResponse {

private Long informationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
public interface InformationRepositoryCustom {
String LIKE_COUNT_SORT = "likes";
String VIEW_COUNT_SORT = "views";
Page<InformationBriefResponse> getPageInformationFilterAndOrder(Pageable pageable, InformationPageRequest informationPageRequest, Long userId, Long parentCategoryId);

Page<InformationBriefResponse> getInformationPageFilterAndOrder(Pageable pageable,
InformationPageRequest informationPageRequest,
Long userId, Long parentCategoryId);
// Page<InformationBriefResponse> getInformationPageFilterAndOrder(Pageable pageable,
// InformationPageRequest informationPageRequest,
// Long userId, Long parentCategoryId);

List<InformationRankResponse> getInformationRank();

Expand Down
Loading

0 comments on commit 86ec6de

Please sign in to comment.