Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ranking package #266

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading