Skip to content

Commit

Permalink
Pull From main
Browse files Browse the repository at this point in the history
  • Loading branch information
Gahyun-Lee authored Oct 9, 2023
2 parents 7d6cd99 + ff6a821 commit 602083e
Show file tree
Hide file tree
Showing 124 changed files with 2,013 additions and 1,117 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/stag-client-api-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: stag-client-api-deploy

on:
push:
branches: [ "stag/client" ]
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'

- name: app clean
run: ./gradlew clean

- name: client api build
run: ./gradlew :likelion-client:build -x test

- name: Docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_EMAIL }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./likelion-client
push: true
tags: ${{ secrets.DOCKER_CLIENT_API_STAG_IMAGE }}
build-args: PROFILE=stag

- name: client-api-deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
sudo docker rm -f ${{ secrets.DOCKER_CLIENT_API_STAG_CONTAINER }}
sudo docker rmi ${{ secrets.DOCKER_CLIENT_API_STAG_IMAGE }}
docker-compose -f ${{ secrets.DOCKER_COMPOSE_DIRECTORY }} up -d
docker image prune -f
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ out/
### env file ###
.env.dev
.env.*

### .DS_Store ignore ###
.DS_Store
46 changes: 26 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
plugins {
id 'java'
id 'java-library'
id 'org.springframework.boot' version '2.7.13'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}

group = 'likelion.univ'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}
allprojects {
group = 'likelion.univ'
version = '0.0.1-SNAPSHOT'

configurations {
compileOnly {
extendsFrom annotationProcessor
java {
sourceCompatibility = 17
targetCompatibility = 17
}
repositories {
mavenCentral()
}
dependencies {
// implementation 'org.springframework.boot:spring-boot-starter'
// annotationProcessor('org.springframework.boot:spring-boot-configuration-processor:3.0.4')
}
}

Expand All @@ -30,21 +34,23 @@ subprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

sourceCompatibility = 17
targetCompatibility = 17

group = 'likelion.univ'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
}
}
test {
useJUnitPlatform()
}
}
bootJar {
enabled = false
}

5 changes: 2 additions & 3 deletions likelion-admin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8090

ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=${PROFILE}","/app.jar"]
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=${PROFILE}","/app.jar"]
23 changes: 1 addition & 22 deletions likelion-admin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
plugins {
id 'java'
}

group = 'likelion.univ'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {

implementation 'org.springframework.boot:spring-boot-starter-validation'
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand All @@ -28,14 +18,3 @@ dependencies {
implementation project(':likelion-infrastructure')
}

test {
useJUnitPlatform()
}

bootJar {
enabled = true
}

jar {
enabled = true
}
2 changes: 1 addition & 1 deletion likelion-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ spring:
spring:
config:
activate:
on-profile: prod
on-profile: prod
5 changes: 2 additions & 3 deletions likelion-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
COPY ./build/libs/*.jar app.jar

ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=${PROFILE}","/app.jar"]
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul","-Dspring.profiles.active=${PROFILE}","/app.jar"]
24 changes: 2 additions & 22 deletions likelion-client/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
plugins {
id 'java'
}

group = 'likelion.univ'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'

Expand All @@ -22,6 +11,8 @@ dependencies {
testImplementation platform('org.junit:junit-bom:5.9.1')
testImplementation 'org.junit.jupiter:junit-jupiter'



/* core 모듈 추가 */
implementation project(':likelion-core')
/* redis 모듈 추가 */
Expand All @@ -34,14 +25,3 @@ dependencies {
implementation project(':likelion-infrastructure')
}

test {
useJUnitPlatform()
}

bootJar {
enabled = true
}

jar {
enabled = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import likelion.univ.auth.usecase.SignUpUseCase;
import likelion.univ.auth.dto.request.SignUpRequestDto;
import likelion.univ.response.SuccessResponse;
import likelion.univ.utils.AuthentiatedUserUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

Expand All @@ -23,6 +24,7 @@ public class AuthController {
private final RequestIdTokenUseCase requestIdTokenUseCase;
private final SignUpUseCase signUpUseCase;
private final RefreshTokenUseCase refreshTokenUseCase;
private final AuthentiatedUserUtils userUtils;

@Operation(summary = "id token 발급", description = "인가 코드로 id token을 발급받습니다.")
@GetMapping("/{logintype}/idtoken")
Expand All @@ -49,7 +51,6 @@ public SuccessResponse<Object> signUp(
@RequestParam("idtoken") String idToken,
@PathVariable("logintype") String loginType,
@RequestBody SignUpRequestDto signUpRequestDto){

AccountTokenDto accountTokenDto = signUpUseCase.execute(loginType,idToken,signUpRequestDto);
return SuccessResponse.of(accountTokenDto);
}
Expand All @@ -61,4 +62,10 @@ public SuccessResponse<Object> refreshToken(
AccountTokenDto accountTokenDto = refreshTokenUseCase.execute(refreshToken);
return SuccessResponse.of(accountTokenDto);
}

@Operation(summary = "로그인 유저 Id 반환", description = "(for client only) 로그인 중인 유저의 Id를 얻습니다.")
@GetMapping("/loginuserid")
public SuccessResponse<?> getLoginUserId() {
return SuccessResponse.of(userUtils.getCurrentUserId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public AccountTokenDto execute(String loginType,
SignUpRequestDto signUpRequestDto){
UserInfoFromIdToken userInfo = loginByIdTokenProcessor.execute(loginType, idToken);
if (!userAdaptor.checkEmail(userInfo.getEmail())){
Profile profile = Profile.profileForSignUp(userInfo.getNickname(),
userInfo.getProfileImage());
Profile profile = Profile.fromName(signUpRequestDto.getName());

University university = universityAdaptor.findByName(signUpRequestDto.getUniversityName());
UniversityInfo universityInfo = UniversityInfo.universityInfoForSignUp(university,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package likelion.univ.comment.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.comment.dto.CommentCreateChildRequestDto;
import likelion.univ.comment.dto.CommentCreateParentRequestDto;
import likelion.univ.comment.dto.CommentUpdateRequestDto;
import likelion.univ.comment.repository.CommentReadRepository;
import likelion.univ.comment.usecase.*;
import likelion.univ.domain.comment.dto.CommentDetailResponseDto;
import likelion.univ.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/comments")
@Tag(name = "댓글", description = "댓글 API")
public class CommentController {
private final CreateParentCommentUseCase createParentCommentUseCase;
private final CreateChildCommentUseCase createChildCommentUseCase;
private final UpdateCommentUseCase updateCommentUseCase;
private final SoftDeleteCommentUseCase softDeleteCommentUseCase;
private final HardDeleteCommentUseCase hardDeleteCommentUseCase;
private final CommentReadRepository commentReadRepository;

/* read */
@Operation(summary = "댓글 조회", description = "게시글에 대한 댓글을 최신순으로 조회합니다.")
@GetMapping("/of/{postId}")
public SuccessResponse<?> getComments(@PathVariable Long postId) {
List<CommentDetailResponseDto> response = commentReadRepository.findAll(postId);
return SuccessResponse.of(response);
}


/* command */
@Operation(summary = "댓글 작성", description = "부모 댓글을 생성합니다.")
@PostMapping("/parent")
public SuccessResponse<?> createParentComment(@RequestBody CommentCreateParentRequestDto request) {
return createParentCommentUseCase.execute(request);
}

@Operation(summary = "대댓글 작성", description = "자식 댓글을 생성합니다.")
@PostMapping("/child")
public SuccessResponse<?> createChildComment(@RequestBody CommentCreateChildRequestDto request) {
return createChildCommentUseCase.execute(request);
}

@Operation(summary = "댓글 내용 수정", description = "댓글의 내용(body only)을 수정합니다.")
@PatchMapping("/{commentId}")
public SuccessResponse<?> updateComment(@PathVariable Long commentId, @RequestBody CommentUpdateRequestDto request) {
return updateCommentUseCase.execute(commentId, request);
}

@Operation(summary = "댓글 삭제", description = "댓글을 soft delete 합니다.")
@PatchMapping("/disable/{commentId}")
public SuccessResponse<?> deleteCommentSoft(@PathVariable Long commentId) {
return softDeleteCommentUseCase.execute(commentId);// soft delete
}

@Operation(summary = "댓글 완전 삭제", description = "댓글을 hard delete 합니다.")
@DeleteMapping("/{commentId}")
public SuccessResponse<?> deleteCommentHard(@PathVariable Long commentId) {
return hardDeleteCommentUseCase.execute(commentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package likelion.univ.comment.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@Builder
@AllArgsConstructor
public class CommentCreateChildRequestDto {
@NotNull
@Schema(description = "게시글 id")
private Long postId;
@NotNull
@Schema(description = "대댓글을 다는 댓글 id")
private Long parentCommentId;
@NotBlank
@Schema(description = "대댓글 내용", example = "대댓글 내용입니다.")
private String body;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package likelion.univ.comment.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
@Builder
@AllArgsConstructor
public class CommentCreateParentRequestDto {
@NotNull
@Schema(description = "댓글을 다는 게시글 id")
private Long postId;
@NotBlank
@Schema(description = "댓글 내용", example = "댓글 내용입니다.")
private String body;
}
Loading

0 comments on commit 602083e

Please sign in to comment.