-
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.
- Loading branch information
Showing
22 changed files
with
222 additions
and
420 deletions.
There are no files selected for viewing
27 changes: 15 additions & 12 deletions
27
src/main/java/com/example/healthylife/config/CorsConfig.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 |
---|---|---|
@@ -1,24 +1,27 @@ | ||
package com.example.healthylife.config; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Configuration | ||
public class CorsConfig { | ||
|
||
@Bean | ||
public WebMvcConfigurer corsConfigurer() { | ||
return new WebMvcConfigurer() { | ||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("http://localhost:3000", | ||
"https://trendy-healthy.store") // 허용할 도메인 | ||
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD") | ||
.allowedHeaders("*") | ||
.allowCredentials(true); | ||
} | ||
}; | ||
public CorsFilter corsFilter() { | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
CorsConfiguration config = new CorsConfiguration(); | ||
config.addAllowedOriginPattern("http://localhost:8081/swagger-ui/index.html"); // 특정 origin 허용 | ||
config.addAllowedOriginPattern("https://trendy-healthy-backend.store/swagger-ui/"); // 특정 origin 허용 | ||
config.addAllowedOriginPattern("http://localhost:3000"); | ||
config.addAllowedOriginPattern("https://trendy-healthy.store/"); | ||
config.addAllowedMethod("*"); // 모든 HTTP 메서드 허용 | ||
config.addAllowedHeader("*"); // 모든 헤더 허용 | ||
config.setAllowCredentials(true); // 자격 증명 허용 | ||
source.registerCorsConfiguration("/**", config); | ||
return new CorsFilter(source); | ||
} | ||
} |
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
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
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
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
5 changes: 0 additions & 5 deletions
5
src/main/java/com/example/healthylife/controller/UserController.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
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
4 changes: 0 additions & 4 deletions
4
src/main/java/com/example/healthylife/exception/ErrorCode.java
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/main/java/com/example/healthylife/exception/S3Exception.java
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
src/main/java/com/example/healthylife/health/CustomHealthIndicator
This file was deleted.
Oops, something went wrong.
27 changes: 21 additions & 6 deletions
27
src/main/java/com/example/healthylife/service/CommunityCommentsService.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 |
---|---|---|
@@ -1,21 +1,36 @@ | ||
package com.example.healthylife.service; | ||
|
||
import com.example.healthylife.entity.CommunityCommentsEntity; | ||
import com.example.healthylife.repository.CommunityCommentsRepository; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
public interface CommunityCommentsService { | ||
public class CommunityCommentsService { | ||
private final CommunityCommentsRepository communityCommentsRepository; | ||
|
||
public CommunityCommentsService(CommunityCommentsRepository communityCommentsRepository){ | ||
this.communityCommentsRepository=communityCommentsRepository; | ||
} | ||
|
||
//댓글 전체 리스트 | ||
List<CommunityCommentsEntity> communityCommentsList(); | ||
public List<CommunityCommentsEntity> communityCommentsList() { | ||
return communityCommentsRepository.findAll(); | ||
} | ||
|
||
//댓글등록 | ||
CommunityCommentsEntity insertComments(CommunityCommentsEntity communityCommentsEntity); | ||
public CommunityCommentsEntity insertComments(CommunityCommentsEntity communityCommentsEntity) { | ||
return communityCommentsRepository.save(communityCommentsEntity); | ||
} | ||
|
||
//댓글삭제 | ||
void deleteBySq(long commentsSq); | ||
public void deleteBySq(long commentsSq) { | ||
|
||
communityCommentsRepository.deleteById(commentsSq); | ||
} | ||
|
||
//커뮤니티 내가 쓴 댓글 | ||
List<CommunityCommentsEntity> findMyCommunityComments(String userId); | ||
public List<CommunityCommentsEntity> findMyCommunityComments(String userId) { | ||
return communityCommentsRepository.findByUserUserId(userId); | ||
} | ||
} |
60 changes: 48 additions & 12 deletions
60
src/main/java/com/example/healthylife/service/CommunityService.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 |
---|---|---|
@@ -1,24 +1,60 @@ | ||
package com.example.healthylife.service; | ||
|
||
|
||
import com.example.healthylife.entity.CommunityEntity; | ||
import com.example.healthylife.entity.UserEntity; | ||
import com.example.healthylife.repository.CommunityRepository; | ||
import com.example.healthylife.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
@RequiredArgsConstructor | ||
@Service | ||
public class CommunityService { | ||
|
||
private final CommunityRepository communityRepository; | ||
private final UserRepository userRepository; | ||
|
||
|
||
|
||
public interface CommunityService { | ||
//글전체조회 | ||
List<CommunityEntity> communityList(); | ||
//글등록 | ||
CommunityEntity registerCommunity(CommunityEntity communityEntity); | ||
//글 수정 | ||
CommunityEntity updateCommunity(CommunityEntity communityEntity); | ||
//글삭제 | ||
void deleteBySq(long communitySq); | ||
public List<CommunityEntity> communityList() { | ||
return communityRepository.findAll(); | ||
} | ||
|
||
|
||
//커뮤니티 글 작성 | ||
public CommunityEntity registerCommunity(CommunityEntity communityEntity) { | ||
return communityRepository.save(communityEntity); | ||
} | ||
|
||
|
||
//커뮤니티 글 수정 | ||
@Transactional | ||
public CommunityEntity updateCommunity(CommunityEntity communityEntity) { | ||
|
||
List<CommunityEntity> findMyContents(String userId); | ||
return communityRepository.save(communityEntity); | ||
} | ||
|
||
//커뮤니티 글 삭제 | ||
public void deleteBySq(long communitySq) { | ||
|
||
communityRepository.deleteById(communitySq); | ||
} | ||
|
||
public List<CommunityEntity> findMyContents(String userId) { | ||
return communityRepository.findByUserUserId(userId); | ||
} | ||
} | ||
//커뮤니티 내가 쓴 글 조회 | ||
// @Override | ||
// public List<CommunityEntity> findMyContents(long userSq) { | ||
// return communityRepository.findByUserUserId(userSq); | ||
// } | ||
|
||
|
||
|
||
|
||
|
||
|
42 changes: 0 additions & 42 deletions
42
src/main/java/com/example/healthylife/service/Impl/CommunityCommentsImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.