-
Notifications
You must be signed in to change notification settings - Fork 2
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
52 changed files
with
723 additions
and
86 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle | ||
|
||
name: CI/CD | ||
|
||
# event trigger | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
CI-CD: | ||
runs-on: ubuntu-latest | ||
|
||
|
||
|
||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' # https://github.com/actions/setup-java | ||
|
||
## create env file | ||
- name: create env file | ||
run: | | ||
touch .env | ||
echo "${{ secrets.PROPERTIES }}" >> .env | ||
## delete : create security.properties | ||
##- name: make security.properties | ||
##run: | | ||
##cd ./src/main/resources | ||
|
||
# security.properties 파일 생성 | ||
##touch ./security.properties | ||
|
||
# GitHub-Actions에서 설정한 값을 security.properties 파일에 쓰기 | ||
##echo "${{ secrets.USERNAME }}" > ./security.properties | ||
##shell: bash | ||
|
||
- name: create firebase key | ||
run: | | ||
cd ./src/main/resources | ||
touch ./kimgreen-f33e5-firebase-adminsdk-63srz-6817b2eec4.json | ||
echo "${{ secrets.USERNAME }}" > ./kimgreen-f33e5-firebase-adminsdk-63srz-6817b2eec4.json | ||
- name: Build with Gradle | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew build -x test | ||
- name: Docker build & push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/kimgreen . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/kimgreen | ||
- name: Deploy | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.HOST}} # EC2 퍼블릭 IPv4 | ||
username: ${{ secrets.USERNAME }} # ec2-user | ||
key: ${{ secrets.PRIVATE_KEY }} # .pem | ||
script: | | ||
sudo systemctl start docker | ||
sudo docker ps | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/kimgreen | ||
docker-compose up -d | ||
sudo docker image prune -f | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,4 +127,4 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | |
|
||
return http.build(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,4 @@ private BadgeList(String name, int goal, String url,String content, int number) | |
this.content = content; | ||
} | ||
|
||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ain/java/com/kimgreen/backend/domain/community/MultipartJackson2HttpMessageConverter.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.kimgreen.backend.domain.community; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
@Component | ||
public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter { | ||
|
||
/** | ||
* Converter for support http request with header Content-Type: multipart/form-data | ||
*/ | ||
public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) { | ||
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM); | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean canWrite(MediaType mediaType) { | ||
return false; | ||
} | ||
} |
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
91 changes: 87 additions & 4 deletions
91
src/main/java/com/kimgreen/backend/domain/community/controller/PostController.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,14 +1,97 @@ | ||
package com.kimgreen.backend.domain.community.controller; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.kimgreen.backend.domain.community.dto.GetPostInfoRequestDto; | ||
import com.kimgreen.backend.domain.community.dto.WritePostRequestDto; | ||
import com.kimgreen.backend.domain.community.entity.Category; | ||
import com.kimgreen.backend.domain.member.entity.Member; | ||
import com.kimgreen.backend.domain.member.service.MemberService; | ||
import com.kimgreen.backend.domain.community.service.PostService; | ||
import com.kimgreen.backend.domain.profile.repository.BadgeRepository; | ||
import com.kimgreen.backend.response.Response; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import com.kimgreen.backend.domain.community.entity.*; | ||
|
||
|
||
import java.io.IOException; | ||
|
||
import static com.kimgreen.backend.response.Message.*; | ||
import static com.kimgreen.backend.response.Response.*; | ||
import static org.springframework.http.HttpStatus.OK; | ||
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE; | ||
|
||
@Tag(name = "Post") | ||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping(value="/post") | ||
public class PostController { | ||
|
||
} | ||
private final PostService postService; | ||
private final MemberService memberService; | ||
private final BadgeRepository badgeRepository; | ||
|
||
@Operation(summary = "게시글 작성(인증)") | ||
@ResponseStatus(OK) | ||
@PostMapping(path="/check", consumes = MULTIPART_FORM_DATA_VALUE) | ||
public Response writeCheckPost(@RequestPart(name = "jsonData") WritePostRequestDto writePostRequestDto, | ||
@RequestPart(name = "File") MultipartFile multipartFile) throws IOException { //파일 필수 O | ||
postService.writeCheckPost(writePostRequestDto, multipartFile, memberService.getCurrentMember()); | ||
return success(WRITE_CERTIFY_POST_SUCCESS); | ||
} | ||
|
||
@Operation(summary = "게시글 작성(일상)") | ||
@ResponseStatus(OK) | ||
@PostMapping(path="/daily", consumes = MULTIPART_FORM_DATA_VALUE) | ||
public Response writeDailyPost(@RequestPart(name = "jsonData") WritePostRequestDto writePostRequestDto, | ||
@RequestPart(name = "File", required = false) MultipartFile multipartFile) throws IOException { //파일 필수 X | ||
postService.writeDailyPost(writePostRequestDto, multipartFile, memberService.getCurrentMember()); | ||
return success(WRITE_DAILY_POST_SUCCESS); | ||
} | ||
|
||
@Operation(summary = "게시글 상세 보기") | ||
@ResponseStatus(OK) | ||
@GetMapping() | ||
public Response getPostInfo(@RequestParam(name="postId") Long postId){ | ||
return success(GET_POST_SUCCESS, postService.getPostInfo(postId)); | ||
} | ||
|
||
@Operation(summary = "게시글 목록 불러오기") | ||
@ResponseStatus(OK) | ||
@GetMapping("/list") | ||
public Response getPostList(@RequestParam(name="category", required = false) Category category, | ||
@RequestParam(name="tag", required = false) com.kimgreen.backend.domain.community.entity.Tag tag, | ||
@RequestParam(name="search", required = false) String search) { | ||
return success(GET_POST_LIST_SUCCESS, postService.getPostlist(category, tag, search)); | ||
} | ||
|
||
@JsonIgnore | ||
@Operation(summary = "게시글 좋아요 상위목록 불러오기") | ||
@ResponseStatus(OK) | ||
@GetMapping("/best") | ||
public Response getBestPostList() { | ||
return Response.success(GET_BEST_POST_LIST_SUCCESS, postService.getBestPostList()); | ||
} | ||
|
||
@Operation(summary = "게시글 삭제하기") | ||
@ResponseStatus(OK) | ||
@DeleteMapping() | ||
public Response deletePost(@RequestParam("postId") Long postId){ | ||
postService.deletePost(postId); | ||
return success(DELETE_POST_SUCCESS); | ||
} | ||
|
||
@Operation(summary = "게시글 수정하기") | ||
@ResponseStatus(OK) | ||
@PutMapping(consumes = MULTIPART_FORM_DATA_VALUE) | ||
public Response editPostInfo(Long postId, | ||
@RequestPart(name = "body(json)") WritePostRequestDto editPostInfoRequestDto, | ||
@RequestPart(name = "files", required = false) MultipartFile multipartFile) throws IOException { | ||
|
||
postService.editPost(postId, editPostInfoRequestDto, multipartFile); | ||
return success(EDIT_POST_SUCCESS); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
src/main/java/com/kimgreen/backend/domain/community/dto/BestPostResponseDto.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.kimgreen.backend.domain.community.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class BestPostResponseDto { | ||
private Long postId; | ||
private String content; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/kimgreen/backend/domain/community/dto/GetPostInfoRequestDto.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.kimgreen.backend.domain.community.dto; | ||
|
||
import com.kimgreen.backend.domain.community.entity.Category; | ||
import com.kimgreen.backend.domain.community.entity.Tag; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Builder | ||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class GetPostInfoRequestDto { | ||
private Category category; | ||
private Tag tag; | ||
private String search; | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/kimgreen/backend/domain/community/dto/GetPostInfoResponseDto.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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.kimgreen.backend.domain.community.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.kimgreen.backend.domain.community.entity.Post; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@JsonInclude | ||
public class GetPostInfoResponseDto { | ||
private String writerNickname; | ||
private String writerBadge; | ||
private String writerProfileImg; | ||
private String imgUrl; | ||
private String content; | ||
private Long postId; | ||
private String category; | ||
private String tag; | ||
private Integer likeCount; | ||
private Integer commentCount; | ||
private Boolean isLiked; | ||
private Boolean isMine; | ||
private String updatedAt; | ||
|
||
public void setImgUrl(String fullUrl) { | ||
this.imgUrl = fullUrl; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/kimgreen/backend/domain/community/dto/WritePostRequestDto.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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.kimgreen.backend.domain.community.dto; | ||
|
||
import com.kimgreen.backend.domain.community.entity.Category; | ||
import com.kimgreen.backend.domain.community.entity.Post; | ||
import com.kimgreen.backend.domain.community.entity.Tag; | ||
import com.kimgreen.backend.domain.member.entity.Member; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class WritePostRequestDto { | ||
private String category; | ||
private String content; | ||
|
||
public Post toCertifyPostEntity(String category, String content, Member member) { | ||
return Post.builder() | ||
.member(member) | ||
.category(Category.valueOf(category)) | ||
.content(content) | ||
.tag(Tag.CERTIFY) | ||
.build(); | ||
} | ||
|
||
public Post toDailyPostEntity(String category, String content, Member member) { | ||
return Post.builder() | ||
.member(member) | ||
.category(Category.valueOf(category)) | ||
.content(content) | ||
.tag(Tag.DAILY) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.