Skip to content

Commit

Permalink
refactor: ranking package (#266)
Browse files Browse the repository at this point in the history
* fix: 사용자 닉네임 변경 처리 수정

* refactor: 패키지 구조 리팩토링

* fix: .gitmodules 위치 수정
  • Loading branch information
parksey authored Apr 22, 2024
1 parent 4b67bb8 commit a84265c
Show file tree
Hide file tree
Showing 26 changed files with 2,346 additions and 282 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "src/main/resources/config"]
path = src/main/resources/config
url = https://github.com/team-moabam/config.git
url = https://github.com/team-moabam/config.git
148 changes: 74 additions & 74 deletions infra/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
version: '3.7'

services:
nginx:
image: nginx:latest
container_name: nginx
platform: linux/arm64/v8
restart: always
ports:
- "80:80"
# - "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
# - ./nginx/certbot/conf:/etc/letsencrypt
# - ./nginx/certbot/www:/var/www/certbot
- ../logs/nginx:/var/log/nginx
certbot:
image: certbot/certbot:latest
container_name: certbot
platform: linux/arm64
restart: unless-stopped
volumes:
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
moabam-blue:
image: ${DOCKER_HUB_USERNAME}/${DOCKER_HUB_REPOSITORY}:${DOCKER_HUB_TAG}
container_name: ${BLUE_CONTAINER}
restart: unless-stopped
expose:
- ${SERVER_PORT}
depends_on:
- redis
- mysql
environment:
SPRING_ACTIVE_PROFILES: ${SPRING_ACTIVE_PROFILES}
moabam-green:
image: ${DOCKER_HUB_USERNAME}/${DOCKER_HUB_REPOSITORY}:${DOCKER_HUB_TAG}
container_name: ${GREEN_CONTAINER}
restart: unless-stopped
expose:
- ${SERVER_PORT}
depends_on:
- redis
- mysql
environment:
SPRING_ACTIVE_PROFILES: ${SPRING_ACTIVE_PROFILES}
redis:
image: redis:alpine
container_name: redis
platform: linux/arm64
restart: always
command: redis-server
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
mysql:
image: mysql:8.0.33
container_name: mysql
platform: linux/arm64/v8
restart: always
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${DEV_MYSQL_DATABASE}
MYSQL_USERNAME: ${DEV_MYSQL_USERNAME}
MYSQL_ROOT_PASSWORD: ${DEV_MYSQL_PASSWORD}
TZ: Asia/Seoul
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
volumes:
- ./data/mysql:/var/lib/mysql
- ./mysql/initdb.d:/docker-entrypoint-initdb.d
nginx:
image: nginx:latest
container_name: nginx
platform: linux/arm64/v8
restart: always
ports:
- "80:80"
# - "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
# - ./nginx/certbot/conf:/etc/letsencrypt
# - ./nginx/certbot/www:/var/www/certbot
- ../logs/nginx:/var/log/nginx
certbot:
image: certbot/certbot:latest
container_name: certbot
platform: linux/arm64
restart: unless-stopped
volumes:
- ./nginx/certbot/conf:/etc/letsencrypt
- ./nginx/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
moabam-blue:
image: ${DOCKER_HUB_USERNAME}/${DOCKER_HUB_REPOSITORY}:${DOCKER_HUB_TAG}
container_name: ${BLUE_CONTAINER}
restart: unless-stopped
expose:
- ${SERVER_PORT}
depends_on:
- redis
- mysql
environment:
SPRING_ACTIVE_PROFILES: ${SPRING_ACTIVE_PROFILES}
moabam-green:
image: ${DOCKER_HUB_USERNAME}/${DOCKER_HUB_REPOSITORY}:${DOCKER_HUB_TAG}
container_name: ${GREEN_CONTAINER}
restart: unless-stopped
expose:
- ${SERVER_PORT}
depends_on:
- redis
- mysql
environment:
SPRING_ACTIVE_PROFILES: ${SPRING_ACTIVE_PROFILES}
redis:
image: redis:alpine
container_name: redis
platform: linux/arm64
restart: always
command: redis-server
ports:
- "6379:6379"
volumes:
- ./data/redis:/data
mysql:
image: mysql:8.0.33
container_name: mysql
platform: linux/arm64/v8
restart: always
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: ${DEV_MYSQL_DATABASE}
MYSQL_USERNAME: ${DEV_MYSQL_USERNAME}
MYSQL_ROOT_PASSWORD: ${DEV_MYSQL_PASSWORD}
TZ: Asia/Seoul
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
volumes:
- ./data/mysql:/var/lib/mysql
- ./mysql/initdb.d:/docker-entrypoint-initdb.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.moabam.api.application.member;

import static com.moabam.global.error.model.ErrorMessage.*;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

import org.springframework.stereotype.Service;

import com.moabam.api.domain.member.Member;
import com.moabam.api.domain.member.repository.MemberRepository;
import com.moabam.api.domain.member.repository.MemberSearchRepository;
import com.moabam.api.domain.room.Participant;
import com.moabam.api.domain.room.repository.ParticipantSearchRepository;
import com.moabam.api.dto.member.MemberInfo;
import com.moabam.api.dto.member.MemberInfoSearchResponse;
import com.moabam.global.error.exception.BadRequestException;
import com.moabam.global.error.exception.ConflictException;
import com.moabam.global.error.exception.NotFoundException;

import io.micrometer.common.util.StringUtils;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class MemberReadService {

private final MemberRepository memberRepository;
private final MemberSearchRepository memberSearchRepository;
private final ParticipantSearchRepository participantSearchRepository;

public Member readMember(Long id) {
return memberSearchRepository.findMember(id)
.orElseThrow(() -> new NotFoundException(MEMBER_NOT_FOUND));
}

public Optional<Member> findMember(String socialId) {
return memberRepository.findBySocialId(socialId);
}

public List<Member> getRoomMembers(List<Long> memberIds) {
return memberRepository.findAllById(memberIds);
}

public void validateMemberToDelete(Long memberId) {
List<Participant> participants = memberSearchRepository.findParticipantByMemberId(memberId);

if (!participants.isEmpty()) {
throw new NotFoundException(MEMBER_NOT_FOUND);
}
}

public MemberInfoSearchResponse readMemberInfos(Long searchId, boolean isMe) {
List<MemberInfo> memberInfos = memberSearchRepository.findMemberAndBadges(searchId, isMe);

if (memberInfos.isEmpty()) {
throw new BadRequestException(MEMBER_NOT_FOUND);
}

return MemberMapper.toMemberInfoSearchResponse(memberInfos);
}

public List<Member> findAllMembers() {
return memberSearchRepository.findAllMembers();
}

public void validateParticipants(Long memberId) {
List<Participant> participants = participantSearchRepository.findAllByMemberIdParticipant(memberId);

if (!participants.isEmpty()) {
throw new BadRequestException(NEED_TO_EXIT_ALL_ROOMS);
}
}

public void validateNickname(String myName, String nickname) {
if (Objects.isNull(nickname)) {
return;
}
if (StringUtils.isBlank(nickname)) {
throw new NotFoundException(NICKNAME_NOT_NULL);
}
if (!memberRepository.existsByNickname(nickname)) {
return;
}
if (!myName.equals(nickname)) {
throw new ConflictException(NICKNAME_CONFLICT);
}
}
}
Loading

0 comments on commit a84265c

Please sign in to comment.