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

[Feat] remove event #53

Merged
merged 7 commits into from
Nov 21, 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
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.12.3'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.3'

// AWS
implementation platform('io.awspring.cloud:spring-cloud-aws-dependencies:3.0.0')
implementation 'io.awspring.cloud:spring-cloud-aws-starter-s3'

// Database
runtimeOnly 'com.h2database:h2:2.2.224'
implementation 'mysql:mysql-connector-java:8.0.32'
Expand Down
9 changes: 4 additions & 5 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ services:
GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET}
GMAIL_USERNAME: ${GMAIL_USERNAME}
GMAIL_APP_PASSWORD: ${GMAIL_APP_PASSWORD}
AWS_ACCESS_KEY: ${AWS_ACCESS_KEY}
AWS_SECRET_KEY: ${AWS_SECRET_KEY}
AWS_REGION: ${AWS_REGION}
AWS_S3_BUCKET: ${AWS_S3_BUCKET}
DISCORD_WEBHOOK_URL: ${DISCORD_WEBHOOK_URL}
JWT_SECRET: ${JWT_SECRET}
JWT_EXPIRATION: ${JWT_EXPIRATION}
Expand Down Expand Up @@ -112,11 +108,14 @@ services:
awslogs-group: ${AWS_LOG_GROUP}
awslogs-stream: certbot
awslogs-multiline-pattern: "^Saving debug log to"
depends_on:
nginx:
condition: service_healthy
volumes:
- ./certbot/data:/var/www/certbot/:rw
- ./certbot/conf:/etc/letsencrypt/:rw
# If your nginx server has not yet been issued an SSL certificate, run the command below
# docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d gdsc-konkuk.dev
# docker compose run --rm certbot certonly --webroot --webroot-path /var/www/certbot/ -d api.gdsc-konkuk.dev
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12d & wait $${!}; done;'"

autoheal:
Expand Down
4 changes: 2 additions & 2 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ http {
listen 443 default_server ssl;
listen [::]:443 ssl;

ssl_certificate /etc/letsencrypt/live/gdsc-konkuk.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gdsc-konkuk.dev/privkey.pem;
ssl_certificate /etc/letsencrypt/live/api.gdsc-konkuk.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.gdsc-konkuk.dev/privkey.pem;

location / {
proxy_pass http://spring:8080;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
import static gdsc.konkuk.platformcore.application.attendance.AttendanceServiceHelper.findAttendanceById;

import gdsc.konkuk.platformcore.application.attendance.dtos.AttendanceStatus;
import gdsc.konkuk.platformcore.application.attendance.exceptions.AttendanceAlreadyExistException;
import gdsc.konkuk.platformcore.application.attendance.exceptions.AttendanceErrorCode;
import gdsc.konkuk.platformcore.application.event.exceptions.EventErrorCode;
import gdsc.konkuk.platformcore.application.event.exceptions.EventNotFoundException;
import gdsc.konkuk.platformcore.application.member.exceptions.MemberErrorCode;
import gdsc.konkuk.platformcore.application.member.exceptions.UserNotFoundException;
import gdsc.konkuk.platformcore.controller.attendance.dtos.AttendanceRegisterRequest;
import gdsc.konkuk.platformcore.domain.attendance.entity.Attendance;
import gdsc.konkuk.platformcore.domain.attendance.entity.Participant;
import gdsc.konkuk.platformcore.domain.attendance.repository.AttendanceRepository;
import gdsc.konkuk.platformcore.domain.attendance.repository.ParticipantRepository;
import gdsc.konkuk.platformcore.domain.event.entity.Event;
import gdsc.konkuk.platformcore.domain.event.repository.EventRepository;
import gdsc.konkuk.platformcore.domain.member.entity.Member;
import gdsc.konkuk.platformcore.domain.member.repository.MemberRepository;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
Expand All @@ -29,7 +24,6 @@
@Transactional(readOnly = true)
public class AttendanceService {
private final ParticipantRepository participantRepository;
private final EventRepository eventRepository;
private final MemberRepository memberRepository;
private final AttendanceRepository attendanceRepository;
private final ParticipantService participantService;
Expand All @@ -45,14 +39,17 @@ public Participant attend(Long memberId, Long attendanceId, String qrUuid) {
return participantService.attend(member.getId(), attendanceId);
}

public List<Attendance> getAllByPeriod(LocalDate month) {
return attendanceRepository.findAllByPeriod(month.atStartOfDay(), month.atStartOfDay().plusMonths(1));
}

@Transactional
public Attendance registerAttendance(AttendanceRegisterRequest registerRequest) {
checkAttendanceAlreadyExist(registerRequest.getEventId());
Attendance newAttendance = AttendanceRegisterRequest.toEntity(registerRequest);
public Attendance registerAttendance(String title, String batch) {
Attendance newAttendance = Attendance.builder().title(title).attendanceTime(LocalDateTime.now()).build();
newAttendance.generateQr();
attendanceRepository.saveAndFlush(newAttendance);

List<Member> members = memberRepository.findAllByBatch(registerRequest.getBatch());
List<Member> members = memberRepository.findAllByBatch(batch);
registerParticipants(newAttendance, members);
return newAttendance;
}
Expand Down Expand Up @@ -82,21 +79,6 @@ public void expireQr(Long attendanceId) {
attendance.expireQr();
}

private void checkAttendanceAlreadyExist(Long eventId) {
Event event =
eventRepository
.findById(eventId)
.orElseThrow(() -> EventNotFoundException.of(EventErrorCode.EVENT_NOT_FOUND));

attendanceRepository
.findByEventId(event.getId())
.ifPresent(
attendance -> {
throw AttendanceAlreadyExistException.of(
AttendanceErrorCode.ATTENDANCE_ALREADY_EXIST);
});
}

private void registerParticipants(Attendance attendance, List<Member> members){
List<Participant> participants = new ArrayList<>();
for(Member member : members) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@Builder
@AllArgsConstructor
public class MemberAttendanceQueryDto {
private Long eventId;
private Long memberId;
private String memberName;
private MemberRole memberRole;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ private static MemberAttendanceInfo createMemberAttendanceInfo(MemberAttendanceQ
.attendanceDate(attendanceInfo.getAttendanceDate())
.participantId(attendanceInfo.getParticipantId())
.attendanceId(attendanceInfo.getAttendanceId())
.eventId(attendanceInfo.getEventId())
.isAttended(attendanceInfo.isAttended())
.build();
}
Expand Down

This file was deleted.

Loading