Skip to content

Commit

Permalink
Merge pull request #29 from LikelionUniv/main
Browse files Browse the repository at this point in the history
release : stag 11/14
  • Loading branch information
seulgi99 authored Nov 14, 2023
2 parents cf50dae + 5149750 commit 03777bb
Show file tree
Hide file tree
Showing 114 changed files with 1,694 additions and 260 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
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"]
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"]
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableCaching
@EnableJpaAuditing
@EnableScheduling
@EnableAsync
@SpringBootApplication
public class LikelionClientApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package likelion.univ.alarm.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.alarm.dto.request.AlarmRegisterRequestDto;
import likelion.univ.alarm.usecase.RegisterAlarmUseCase;
import likelion.univ.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/v1/alarm")
@Tag(name = "알람", description = "알람 API")
public class AlarmController {
private final RegisterAlarmUseCase registerAlarmUseCase;

@Operation(summary = "알람 등록", description = "이메일과 알람 타입을 입력받아 해당 기수의 알람을 등록합니다.")
@PostMapping("/{ordinal}/register")
public SuccessResponse registerAlarm(@PathVariable Long ordinal,
@RequestBody AlarmRegisterRequestDto alarmRegisterRequestDto){
registerAlarmUseCase.execute(ordinal, alarmRegisterRequestDto);
return SuccessResponse.empty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package likelion.univ.alarm.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import likelion.univ.domain.alarm.entity.Alarm;
import likelion.univ.domain.alarm.entity.AlarmType;
import likelion.univ.domain.alarm.entity.SendStatus;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

import static likelion.univ.domain.alarm.entity.SendStatus.NOT_SENT;

@Getter
@NoArgsConstructor
public class AlarmRegisterRequestDto {
@NotNull
@Schema(description = "이메일", example = "tmfrk0426@gmail.com", required = true)
private String email;

@NotNull
@Schema(description = "알람 타입", example = "NEW_UNIVERSITY_RECRUITING", required = true, enumAsRef = true)
private AlarmType alarmType;

public static Alarm toEntity(Long ordinal, AlarmRegisterRequestDto alarmRegisterRequestDto){
return Alarm.builder()
.ordinal(ordinal)
.email(alarmRegisterRequestDto.getEmail())
.alarmType(alarmRegisterRequestDto.getAlarmType())
.sendStatus(NOT_SENT)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package likelion.univ.alarm.usecase;

import likelion.univ.alarm.dto.request.AlarmRegisterRequestDto;
import likelion.univ.annotation.UseCase;
import likelion.univ.domain.alarm.adaptor.AlarmAdaptor;
import likelion.univ.domain.alarm.entity.Alarm;
import likelion.univ.domain.alarm.service.AlarmDomainService;
import lombok.RequiredArgsConstructor;

@UseCase
@RequiredArgsConstructor
public class RegisterAlarmUseCase {
private final AlarmAdaptor alarmAdaptor;
private final AlarmDomainService alarmDomainService;

public void execute(Long ordinal, AlarmRegisterRequestDto alarmRegisterRequestDto){
alarmAdaptor.existsByOrdinalAndEmailAndAlarmType(ordinal,
alarmRegisterRequestDto.getEmail(), alarmRegisterRequestDto.getAlarmType());
Alarm newAlarm = AlarmRegisterRequestDto.toEntity(ordinal, alarmRegisterRequestDto);
alarmDomainService.createAlarm(newAlarm);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.auth.dto.response.AccountTokenDto;
import likelion.univ.auth.dto.response.AccountUserInfoDto;
import likelion.univ.auth.dto.response.IdTokenDto;
import likelion.univ.auth.usecase.LoginUseCase;
import likelion.univ.auth.usecase.RefreshTokenUseCase;
import likelion.univ.auth.usecase.RequestIdTokenUseCase;
import likelion.univ.auth.usecase.SignUpUseCase;
import likelion.univ.auth.usecase.*;
import likelion.univ.auth.dto.request.SignUpRequestDto;
import likelion.univ.response.SuccessResponse;
import likelion.univ.utils.AuthentiatedUserUtils;
Expand All @@ -24,7 +22,7 @@ public class AuthController {
private final RequestIdTokenUseCase requestIdTokenUseCase;
private final SignUpUseCase signUpUseCase;
private final RefreshTokenUseCase refreshTokenUseCase;
private final AuthentiatedUserUtils userUtils;
private final GetUserInfoUseCase getUserInfoUsecase;

@Operation(summary = "id token 발급", description = "인가 코드로 id token을 발급받습니다.")
@GetMapping("/{logintype}/idtoken")
Expand Down Expand Up @@ -55,17 +53,18 @@ public SuccessResponse<Object> signUp(
return SuccessResponse.of(accountTokenDto);
}

@Operation(summary = "유저 정보 조회", description = "간단한 유저정보를 조회합니다.")
@GetMapping("/userinfo")
public SuccessResponse<Object> getUserInfo(){
AccountUserInfoDto accountUserInfoDto = getUserInfoUsecase.execute();
return SuccessResponse.of(accountUserInfoDto);
}

@Operation(summary = "토큰 재발급", description = "refresh token으로 access token을 재발급합니다.")
@PostMapping("/refresh")
public SuccessResponse<Object> refreshToken(
@RequestParam("token") String 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
@@ -0,0 +1,22 @@
package likelion.univ.auth.dto.response;

import likelion.univ.domain.user.entity.User;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class AccountUserInfoDto {
private Long userId;
private String profileImage;
private String name;

public static AccountUserInfoDto of(User user){
return AccountUserInfoDto.builder()
.userId(user.getId())
.profileImage(user.getProfile().getProfileImage())
.name(user.getProfile().getName())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package likelion.univ.auth.usecase.processor;
package likelion.univ.auth.processor;

import likelion.univ.annotation.Processor;
import likelion.univ.auth.dto.response.AccountTokenDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package likelion.univ.auth.usecase.processor;
package likelion.univ.auth.processor;

import likelion.univ.annotation.Processor;
import likelion.univ.feign.oauth.oidc.PublicKeyDto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package likelion.univ.auth.usecase.processor;
package likelion.univ.auth.processor;

import likelion.univ.annotation.Processor;
import likelion.univ.feign.oauth.google.RequestGooglePublicKeysClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package likelion.univ.auth.usecase;

import likelion.univ.annotation.UseCase;
import likelion.univ.auth.dto.response.AccountUserInfoDto;
import likelion.univ.domain.user.entity.User;
import likelion.univ.utils.AuthentiatedUserUtils;
import lombok.RequiredArgsConstructor;

@UseCase
@RequiredArgsConstructor
public class GetUserInfoUseCase {

private final AuthentiatedUserUtils authentiatedUserUtils;

public AccountUserInfoDto execute(){
User user = authentiatedUserUtils.getCurrentUser();
return AccountUserInfoDto.of(user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import likelion.univ.annotation.UseCase;
import likelion.univ.auth.dto.response.AccountTokenDto;
import likelion.univ.auth.usecase.processor.GenerateAccountTokenProcessor;
import likelion.univ.auth.usecase.processor.LoginByIdTokenProcessor;
import likelion.univ.auth.processor.GenerateAccountTokenProcessor;
import likelion.univ.auth.processor.LoginByIdTokenProcessor;
import likelion.univ.domain.user.adaptor.UserAdaptor;
import likelion.univ.domain.user.entity.LoginType;
import likelion.univ.domain.user.entity.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import likelion.univ.annotation.UseCase;
import likelion.univ.auth.dto.response.AccountTokenDto;
import likelion.univ.auth.usecase.processor.GenerateAccountTokenProcessor;
import likelion.univ.auth.processor.GenerateAccountTokenProcessor;
import likelion.univ.domain.user.adaptor.UserAdaptor;
import likelion.univ.domain.user.entity.User;
import likelion.univ.exception.InvalidTokenException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import likelion.univ.annotation.UseCase;
import likelion.univ.auth.dto.request.SignUpRequestDto;
import likelion.univ.auth.dto.response.AccountTokenDto;
import likelion.univ.auth.usecase.processor.GenerateAccountTokenProcessor;
import likelion.univ.auth.usecase.processor.LoginByIdTokenProcessor;
import likelion.univ.auth.processor.GenerateAccountTokenProcessor;
import likelion.univ.auth.processor.LoginByIdTokenProcessor;
import likelion.univ.domain.university.adaptor.UniversityAdaptor;
import likelion.univ.domain.university.entity.University;
import likelion.univ.domain.user.adaptor.UserAdaptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/community/comments")
@Tag(name = "댓글", description = "댓글 API")
@Tag(name = "댓글", description = "커뮤니티 APIs")
public class CommentController {
private final CreateParentCommentUseCase createParentCommentUseCase;
private final CreateChildCommentUseCase createChildCommentUseCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package likelion.univ.follow.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import likelion.univ.follow.usecase.CancelFollowUseCase;
import likelion.univ.follow.usecase.FollowUserUseCase;
import likelion.univ.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/v1/follow")
@Tag(name = "팔로우", description = "팔로우 관련 API입니다.")
public class FollowController {
private final FollowUserUseCase followUserUseCase;
private final CancelFollowUseCase cancelFollowUseCase;

@Operation(summary = "팔로우 ", description = "해당 유저를 팔로우 합니다.")
@PostMapping("/{userId}")
public SuccessResponse<Object> follow(@PathVariable("userId") Long userId){
followUserUseCase.execute(userId);
return SuccessResponse.empty();
}

@Operation(summary = "팔로우 취소", description = "해당 유저를 팔로우 취소 합니다.")
@DeleteMapping("/{userId}")
public SuccessResponse<Object> deleteFollow(@PathVariable("userId") Long userId) {
cancelFollowUseCase.execute(userId);
return SuccessResponse.empty();
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package likelion.univ.follow.usecase;

import likelion.univ.annotation.UseCase;
import likelion.univ.domain.follow.adaptor.FollowAdaptor;
import likelion.univ.follow.dao.FollowNumRedisDao;
import likelion.univ.follow.entity.FollowNum;
import likelion.univ.follow.service.FollowNumRedisService;
import likelion.univ.utils.AuthentiatedUserUtils;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

@UseCase
@RequiredArgsConstructor
public class CancelFollowUseCase {
private final AuthentiatedUserUtils authentiatedUserUtils;
private final FollowAdaptor followAdaptor;
private final FollowNumRedisDao followNumRedisDao;
private final FollowNumRedisService followNumRedisService;

public void execute(Long userId){
Long currentUserId = authentiatedUserUtils.getCurrentUserId();
followAdaptor.delete(currentUserId, userId);
updateFollowNumRedis(currentUserId, userId);
}

private void updateFollowNumRedis(Long currentUserId, Long userId){
Optional<FollowNum> myFollowNum = followNumRedisDao.findById(currentUserId);
if(myFollowNum.isPresent()) followNumRedisService.followingDown(currentUserId, myFollowNum.get());
Optional<FollowNum> targetFollowNum = followNumRedisDao.findById(userId);
if(targetFollowNum.isPresent()) followNumRedisService.followerDown(userId, targetFollowNum.get());
}
}
Loading

0 comments on commit 03777bb

Please sign in to comment.