-
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.
Merge pull request #28 from LikelionUniv/feature/mypage
Feature/mypage
- Loading branch information
Showing
92 changed files
with
1,551 additions
and
192 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
25 changes: 25 additions & 0 deletions
25
likelion-client/src/main/java/likelion/univ/alarm/controller/AlarmController.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,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(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
likelion-client/src/main/java/likelion/univ/alarm/dto/request/AlarmRegisterRequestDto.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,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(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
likelion-client/src/main/java/likelion/univ/alarm/usecase/RegisterAlarmUseCase.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,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); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
likelion-client/src/main/java/likelion/univ/auth/dto/response/AccountUserInfoDto.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,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(); | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
likelion-client/src/main/java/likelion/univ/auth/usecase/GetUserInfoUseCase.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,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); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
likelion-client/src/main/java/likelion/univ/follow/controller/FollowController.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,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(); | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
likelion-client/src/main/java/likelion/univ/follow/usecase/CancelFollowUseCase.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,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()); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
likelion-client/src/main/java/likelion/univ/follow/usecase/FollowUserUseCase.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,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 FollowUserUseCase { | ||
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.save(currentUserId, userId); | ||
updateFollowNumRedis(currentUserId, userId); | ||
} | ||
|
||
private void updateFollowNumRedis(Long currentUserId, Long userId){ | ||
Optional<FollowNum> myFollowNum = followNumRedisDao.findById(currentUserId); | ||
if(myFollowNum.isPresent()) followNumRedisService.followingUp(currentUserId, myFollowNum.get()); | ||
Optional<FollowNum> targetFollowNum = followNumRedisDao.findById(userId); | ||
if(targetFollowNum.isPresent()) followNumRedisService.followerUp(userId, targetFollowNum.get()); | ||
} | ||
} |
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
Oops, something went wrong.