Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d02edeb
:sparkles: feat: add main and detail page
DHKIM-0511 Feb 10, 2025
8494317
:sparkles: feat: add logo
DHKIM-0511 Feb 10, 2025
c94c81c
:sparkles: feat: add header.html
DHKIM-0511 Feb 10, 2025
b1ca310
:sparkles: feat: add chefs-read
linkpond Feb 10, 2025
eff3ed1
:pencil2: fix: fix chefs-read
linkpond Feb 10, 2025
0d64858
:pencil2: fix: fix chefs-read
linkpond Feb 10, 2025
2abc318
:pencil2: fix: fix chefs-read
linkpond Feb 10, 2025
b19d620
:sparkles: feat CRUD & API_test_완료 & ãs3완료
syjoy1993 Feb 10, 2025
c9885fa
:sparkles: feat Dockerfile
syjoy1993 Feb 10, 2025
bd0f906
:sparkles: feat: add chefs-read
linkpond Feb 10, 2025
b5d55d0
:pencil2: fix: modify aws configuration
DHKIM-0511 Feb 10, 2025
576895f
Merge pull request #3 from Cloud-Engineering2/feature/chefs-read
DHKIM-0511 Feb 10, 2025
478daad
edit build.gradle
syjoy1993 Feb 10, 2025
7b5e41c
Merge branch 'dev' into restaurants/CRUD
DHKIM-0511 Feb 10, 2025
7802dc8
Merge branch 'dev' of https://github.com/Cloud-Engineering2/project2-…
DHKIM-0511 Feb 10, 2025
695eb48
:feat: feat: add chef pictures at main page
DHKIM-0511 Feb 10, 2025
fee2ca4
:zap: feat: create Comment CRUD API
minjko Feb 10, 2025
2f81c30
:fire: remove: add 'empty - application.properties'
minjko Feb 11, 2025
3d713d6
:art: refactor: 주석 제거
minjko Feb 11, 2025
e22dfe8
:art: refactor: remove needless s3 library
minjko Feb 11, 2025
4a8a40e
:art: refactor: remove 'System.out.println'
minjko Feb 11, 2025
450310c
Merge pull request #4 from Cloud-Engineering2/feature/comments
DHKIM-0511 Feb 11, 2025
9f60837
:zap: feat: merge dev(comment api) into fe main and detail
DHKIM-0511 Feb 11, 2025
c8c96f4
:zap: feat: Add get by id method
DHKIM-0511 Feb 11, 2025
0df2123
Merge branch 'dev' into restaurants/CRUD
DHKIM-0511 Feb 11, 2025
aa293c4
Merge pull request #2 from Cloud-Engineering2/restaurants/CRUD
DHKIM-0511 Feb 11, 2025
b9091de
:zap: feat: merge dev(restaurant and s3 api) into fe main and detail
DHKIM-0511 Feb 11, 2025
9ffd7b9
:pencil2: fix: fix code
DHKIM-0511 Feb 11, 2025
f794176
Merge branch 'dev' of https://github.com/Cloud-Engineering2/project2-…
DHKIM-0511 Feb 11, 2025
a972c51
:zap: feat: feat main and detail
DHKIM-0511 Feb 11, 2025
84f0a15
:sparkles: set securityConfig && User CRUD complate && add ErrorPage
syjoy1993 Feb 12, 2025
0f14da1
Merge pull request #5 from Cloud-Engineering2/feature/security
DHKIM-0511 Feb 12, 2025
51eae3d
Merge branch 'dev' of https://github.com/Cloud-Engineering2/project2-…
DHKIM-0511 Feb 12, 2025
727ff13
:zap: feat: comment register
DHKIM-0511 Feb 12, 2025
ccde481
현재 변경사항 커밋
syjoy1993 Feb 12, 2025
804d34e
AWS Keyremove applicationproperties
syjoy1993 Feb 12, 2025
78f7614
:sparkles: feat chefcreate && s3 upload
syjoy1993 Feb 12, 2025
aae13fd
:zap: feat: add comment crud
DHKIM-0511 Feb 12, 2025
48c725e
:zap: feat: add header
DHKIM-0511 Feb 12, 2025
c5aa202
:zap: feat: add favicon
DHKIM-0511 Feb 12, 2025
b628695
sparkles: Add github action
DHKIM-0511 Feb 12, 2025
3d28645
Merge branch 'dev' of https://github.com/Cloud-Engineering2/project2-…
DHKIM-0511 Feb 12, 2025
e00eba1
Merge pull request #6 from Cloud-Engineering2/feature/chefcreate
DHKIM-0511 Feb 12, 2025
d850c77
:zap: feat: merge dev(s3 & chef) into main and detail
DHKIM-0511 Feb 12, 2025
fdf16c3
Merge pull request #7 from Cloud-Engineering2/feature/fe-main-and-detail
DHKIM-0511 Feb 12, 2025
c399eac
:bug: fix Security&&Thymeleaf ì수정: 비회원 상세페이지 접근 가능
syjoy1993 Feb 12, 2025
e172454
Merge pull request #8 from Cloud-Engineering2/feature/securityFix
DHKIM-0511 Feb 12, 2025
a21c883
:lipstic: fe-edit
syjoy1993 Feb 13, 2025
d3949fa
:bug: fix: Fix logout url
DHKIM-0511 Feb 13, 2025
2650d33
Merge pull request #9 from Cloud-Engineering2/feature/fe
DHKIM-0511 Feb 13, 2025
0b88c41
Merge pull request #10 from Cloud-Engineering2/feature/fix
DHKIM-0511 Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions .github/workflows/wbc-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: App with Github Actions, wbc

on:
# workflow_dispatch
push:
branches:
- dev

jobs:
ci-cd:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Make application.properties
run: |
cd ./src/main/resources
touch ./application.properties
echo "${{ secrets.PROPERTIES }}" > ./application.properties
shell: bash

- name: Grant execute permission for Gradle Wrapper
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean build -x test
# env:
# GRADLE_OPTS: "-Dorg.gradle.daemon=false"

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: app
path: build/libs

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

- name: Update application image version for ArgoCD
uses: actions/checkout@v4
with:
repository: ${{ secrets.G_USER }}/${{ secrets.G_REPOSITORY }}
ref: main
token: ${{ secrets.G_TOKEN }}

- name: Set up Image
run: |
sed -i "s%image: ${{ secrets.AWS_ECR_ID }}.dkr.ecr.${{ secrets.AWS_ECR_REGION }}.amazonaws.com/${{ secrets.AWS_ECR_REPOSITORY }}:[a-zA-Z0-9]*%image: ${{ secrets.AWS_ECR_ID }}.dkr.ecr.${{ secrets.AWS_ECR_REGION }}.amazonaws.com/${{ secrets.AWS_ECR_REPOSITORY }}:${{ github.sha }}%" ./manifest/wbc-app-manifest.yaml

- name: Commit and push changes
run: |
git config --local user.email "${{ secrets.G_USER_EMAIL }}"
git config --local user.name "${{ secrets.G_USER_NAME }}"
git add .
git commit -m "Update application image version for ArgoCD"
git push
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ dependencies {
implementation platform('software.amazon.awssdk:bom:2.27.21')
implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3:3.0.2'
implementation 'software.amazon.awssdk:s3'




}

tasks.named('test') {
Expand Down
2 changes: 1 addition & 1 deletion setting.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## db
git ## db

- 로컬에 db 계정 먼저 해주세용
- user: wbc
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ce3/wbc/WbcApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@EnableJpaAuditing
@SpringBootApplication
public class WbcApplication {

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ce3/wbc/config/S3Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class S3Config {
@Bean
public S3Client s3client() {

// S3 사용 인증 객체
// S3 사용 인증 객체
//AWSCredentials credentials = new BasicAWSCredentials(awsAccessKey, awsSecretKey);

// 리전 정보 입력 -> S3 사용 객체 생성
Expand Down
88 changes: 87 additions & 1 deletion src/main/java/ce3/wbc/config/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,98 @@
package ce3.wbc.config;

import ce3.wbc.security.WbcAuthenticationFailureHandler;
import ce3.wbc.security.WbcAuthenticationSuccessHandler;
import ce3.wbc.security.WbcUserDetailsService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;

@EnableMethodSecurity(prePostEnabled = true,securedEnabled = true)
@EnableMethodSecurity(prePostEnabled = true, securedEnabled = true)
@EnableWebSecurity
@Configuration
@RequiredArgsConstructor
public class SecurityConfig {

private final WbcAuthenticationSuccessHandler wbcAuthenticationSuccessHandler;
private final WbcAuthenticationFailureHandler wbcAuthenticationFailureHandler;
private final WbcUserDetailsService wbcUserDetailsService;

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity security) throws Exception {
security.csrf(csrf -> csrf.disable())
.cors(cors -> cors.disable());
//인가
security.authorizeHttpRequests((authorize ->
authorize
.requestMatchers(HttpMethod.GET,"/restaurants/{restId}").permitAll()
.requestMatchers(HttpMethod.GET,"/api/restaurants/{restId}").permitAll()
.requestMatchers(HttpMethod.POST, "/users/sign-up").permitAll()
.requestMatchers(HttpMethod.POST, "/replies/**").authenticated()
.requestMatchers(HttpMethod.PUT, "/replies/**").authenticated()
.requestMatchers(HttpMethod.DELETE, "/replies/**").authenticated()

.requestMatchers("/favicon.ico").permitAll()
.requestMatchers("/error", "/error/**").permitAll()
.anyRequest().permitAll()

));
//로그인 폼사용
security.formLogin(form -> form
.loginPage("/users/login")
.loginProcessingUrl("/users/login") //프론트엔드에서 action="/users/login"으로 설정할것
.successHandler(wbcAuthenticationSuccessHandler) // 로그인 처리
.failureUrl("/login?error=true")
.failureHandler(wbcAuthenticationFailureHandler)

);

//Spring Security기본설정 : POST /logout
security.logout(logout -> logout.logoutSuccessUrl("/chefs")) //Spring Security기본설정 : POST /logout
.logout(logout -> logout.logoutUrl("/users/logout") //FE GET/logout,추가
.logoutSuccessUrl("/chefs").invalidateHttpSession(true)
.deleteCookies("JSESSIONID"));

// 세션
security.sessionManagement(httpSecuritySessionManagementConfigurer
-> httpSecuritySessionManagementConfigurer
.invalidSessionUrl("/login")
.sessionFixation().migrateSession()
.maximumSessions(2)
.expiredUrl("/login"));

return security.build();
}

@Bean
public AuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(wbcUserDetailsService); //WbcUserDetailsService
authProvider.setPasswordEncoder(passwordEncoder()); //비밀번호 암호화 설정
return authProvider;
}

//비밀번호 암호화 규칙
@Bean
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}



@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}

}
37 changes: 34 additions & 3 deletions src/main/java/ce3/wbc/controller/ChefController.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
package ce3.wbc.controller;

import ce3.wbc.controller.rto.request.ChefCreate;
import ce3.wbc.controller.rto.response.ChefRes;
import ce3.wbc.dto.ChefDto;
import ce3.wbc.service.ChefService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("wbs/chefs")
@RequestMapping("/chefs")
@RequiredArgsConstructor
public class ChefController {

private final ChefService chefService;

@GetMapping
public String getAllChefs(Model model) {
List<ChefRes> chefs = chefService.getAllChefs();
model.addAttribute("chefs", chefs);
return "main";
}

@GetMapping("/groupedByCategory")
public String getChefsGroupedByCategory(Model model) {
Map<String, List<ChefRes>> groupedChefs = chefService.getChefsGroupedByCategory();
model.addAttribute("groupedChefs", groupedChefs);
return "groupedByCategory";
}

@ResponseStatus(HttpStatus.CREATED)
@ResponseBody
@PostMapping(value = "/create", consumes = {MediaType.APPLICATION_JSON_VALUE, MediaType.MULTIPART_FORM_DATA_VALUE})
public ChefRes createChef (@RequestPart(value = "chefCreate") @Valid ChefCreate chefCreate,
@RequestPart(value = "file", required = false) MultipartFile file) {

}
ChefDto chefDto = chefService.saveChef(ChefCreate.toChefDto(chefCreate), file);
return ChefRes.toResponse(chefDto);
}
}
83 changes: 80 additions & 3 deletions src/main/java/ce3/wbc/controller/CommentController.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,92 @@
package ce3.wbc.controller;

import java.util.List;
import java.util.stream.Collectors;

import ce3.wbc.security.WbcUserDetails;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import ce3.wbc.controller.rto.request.CommentReq;
import ce3.wbc.controller.rto.request.CommentUpdateReq;
import ce3.wbc.controller.rto.response.CommentRes;
import ce3.wbc.dto.CommentDto;
import ce3.wbc.dto.UserDto;
import ce3.wbc.service.CommentService;
import ce3.wbc.service.RestaurantService;
import ce3.wbc.service.UserService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
@RequestMapping("wbs/replies")
@RequestMapping("replies")
@RequiredArgsConstructor
public class CommentController {

private final CommentService commentService;
private final RestaurantService restaurantService;
private final UserService userService;

/************************************************** 댓글 등록 **************************************************/
@PostMapping
public ResponseEntity<Void> registerComment(@RequestBody @Valid CommentReq commentReq,
BindingResult bindingResult,
@AuthenticationPrincipal WbcUserDetails wbcUser) {
// 댓글과 별점
String content = commentReq.getCommContent();
String star = commentReq.getCommStar();

UserDto userDto = UserDto.toDto(wbcUser.getUser());

// 식당
Integer restId = commentReq.getRestId();

// 댓글 생성
CommentDto commentDto = CommentDto.of(content, star, restId, userDto);

// DB에 저장
commentService.addComment(commentReq, userDto);
return new ResponseEntity<>(HttpStatus.OK);
}


/******************************************* 댓글 조회: restaurant id *******************************************/
@GetMapping
public ResponseEntity<List<CommentRes>> getComments(@RequestParam("restaurant") Integer restId) {

List<CommentDto> comments = commentService.getComments(restId);

List<CommentRes> response = comments.stream()
.map(CommentRes::toResponse)
.collect(Collectors.toList());

return ResponseEntity.ok(response); // 200
}

/********************************************* 댓글 수정: comment id *********************************************/
@PutMapping("/{commId}")
public ResponseEntity<CommentRes> updateComment(@PathVariable("commId") Integer commId,
@RequestBody @Valid CommentUpdateReq commentUpdateReq, BindingResult bindingResult) {
// 요청 유효성 검사
if (bindingResult.hasErrors()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); // 400
}

CommentDto commentDto = commentService.updateComment(commId, commentUpdateReq.getCommContent(), commentUpdateReq.getCommStar());
CommentRes response = CommentRes.toResponse(commentDto);

return ResponseEntity.ok(response); // 200
}

/********************************************* 댓글 삭제: comment id *********************************************/
@DeleteMapping("/{commId}")
public ResponseEntity<Void> deleteComment(@PathVariable("commId") Integer commId) {

commentService.deleteComment(commId);
return ResponseEntity.noContent().build();
}
}
Loading