Skip to content

Commit

Permalink
Merge pull request #525 from woowacourse-teams/dev
Browse files Browse the repository at this point in the history
main v1.0.1 배포한다.
  • Loading branch information
xrabcde authored Sep 9, 2021
2 parents 35c08dd + f56a31f commit 44551cf
Show file tree
Hide file tree
Showing 72 changed files with 859 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PostConstruct;
import java.util.TimeZone;

@SpringBootApplication
public class ZzimkkongApplication {
@PostConstruct
private void setTimeZone(){
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
}

public static void main(String[] args) {
SpringApplication.run(ZzimkkongApplication.class, args);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.zzimkkong;
package com.woowacourse.zzimkkong.config;

import com.woowacourse.zzimkkong.infrastructure.AuthenticationPrincipalArgumentResolver;
import com.woowacourse.zzimkkong.infrastructure.LoginInterceptor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.zzimkkong;
package com.woowacourse.zzimkkong.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.zzimkkong;
package com.woowacourse.zzimkkong.config;

import com.woowacourse.zzimkkong.domain.SlackUrl;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.zzimkkong;
package com.woowacourse.zzimkkong.config;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
Expand All @@ -15,7 +15,7 @@
@PropertySource("classpath:config/awsS3.properties")
public class StorageConfig {
@Bean
@Profile("prod")
@Profile({"prod", "dev"})
public AmazonS3 amazonS3() {
return AmazonS3ClientBuilder
.standard()
Expand All @@ -24,7 +24,7 @@ public AmazonS3 amazonS3() {
}

@Bean(name = "amazonS3")
@Profile("!prod")
@Profile({"local", "test"})
public AmazonS3 amazonS3Local(
@Value("${aws.access-key}") String accessKey,
@Value("${aws.secret-key}") String secretKey) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.woowacourse.zzimkkong;
package com.woowacourse.zzimkkong.config;

import org.apache.http.HttpHeaders;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class MemberController {
public MemberController(final MemberService memberService, final PresetService presetService) {
this.memberService = memberService;
this.presetService = presetService;

}

@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ private ValidatorMessage() {
public static final String RESERVATION_PW_MESSAGE = "비밀번호는 숫자 4자리만 입력 가능합니다.";
public static final String ORGANIZATION_MESSAGE = "조직명은 특수문자 없이 20자 이내로 작성 가능합니다.";
public static final String NAME_MESSAGE = "이름은 특수문자(-_!?.,)를 포함하여 20자 이내로 작성 가능합니다.";
public static final String PRESET_NAME_MESSAGE = "프리셋 이름은 공백과 특수문자(-_!?.,)를 포함하여 20자 이내로 작성 가능합니다.";
public static final String DESCRIPTION_MESSAGE = "예약 내용은 100자 이내로 작성 가능합니다.";
public static final String FORMAT_MESSAGE = "날짜 및 시간 데이터 형식이 올바르지 않습니다.";
public static final String DAY_OF_WEEK_MESSAGE = "올바른 요일 형식이 아닙니다.";
Expand All @@ -23,4 +24,6 @@ private ValidatorMessage() {
public static final String RESERVATION_PW_FORMAT = "^[0-9]{4}$";
public static final String ORGANIZATION_FORMAT = "^[ a-zA-Z0-9ㄱ-힣]{1,20}$";
public static final String NAMING_FORMAT = "^[-_!?.,a-zA-Z0-9ㄱ-힣]{1,20}$";
public static final String PRESET_NAME_FORMAT = "^[-_!?., a-zA-Z0-9ㄱ-힣]{1,20}$";

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@NoArgsConstructor
public class PresetCreateRequest {
@NotNull(message = EMPTY_MESSAGE)
@Pattern(regexp = NAMING_FORMAT, message = NAME_MESSAGE)
@Pattern(regexp = PRESET_NAME_FORMAT, message = PRESET_NAME_MESSAGE)
private String name;

@Valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
@Getter
@NoArgsConstructor
public class PresetFindResponse extends SettingResponse {
private Long id;
private String name;

private PresetFindResponse(
final Long id,
final LocalTime availableStartTime,
final LocalTime availableEndTime,
final Integer reservationTimeUnit,
Expand All @@ -23,13 +25,15 @@ private PresetFindResponse(
final String enabledDayOfWeek,
final String name) {
super(availableStartTime, availableEndTime, reservationTimeUnit, reservationMinimumTimeUnit, reservationMaximumTimeUnit, reservationEnable, enabledDayOfWeek);
this.id = id;
this.name = name;
}

public static PresetFindResponse from(final Preset preset) {
Setting setting = preset.getSetting();

return new PresetFindResponse(
preset.getId(),
setting.getAvailableStartTime(),
setting.getAvailableEndTime(),
setting.getReservationTimeUnit(),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.springframework.data.jpa.repository.JpaRepository;

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

public interface MapRepository extends JpaRepository<Map, Long> {
List<Map> findAllByMember(final Member member);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.woowacourse.zzimkkong.repository;

import com.woowacourse.zzimkkong.domain.Member;
import com.woowacourse.zzimkkong.domain.Preset;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface PresetRepository extends JpaRepository<Preset, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
import com.woowacourse.zzimkkong.domain.Space;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface SpaceRepository extends JpaRepository<Space, Long> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import com.woowacourse.zzimkkong.exception.space.ReservationExistOnSpaceException;
import com.woowacourse.zzimkkong.infrastructure.SharingIdGenerator;
import com.woowacourse.zzimkkong.infrastructure.ThumbnailManager;
import com.woowacourse.zzimkkong.infrastructure.TimeConverter;
import com.woowacourse.zzimkkong.repository.MapRepository;
import com.woowacourse.zzimkkong.repository.ReservationRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

import static java.util.stream.Collectors.collectingAndThen;
Expand All @@ -28,19 +28,16 @@
public class MapService {
private final MapRepository maps;
private final ReservationRepository reservations;
private final TimeConverter timeConverter;
private final ThumbnailManager thumbnailManager;
private final SharingIdGenerator sharingIdGenerator;

public MapService(
final MapRepository maps,
final ReservationRepository reservations,
final TimeConverter timeConverter,
final ThumbnailManager thumbnailManager,
final SharingIdGenerator sharingIdGenerator) {
this.maps = maps;
this.reservations = reservations;
this.timeConverter = timeConverter;
this.thumbnailManager = thumbnailManager;
this.sharingIdGenerator = sharingIdGenerator;
}
Expand Down Expand Up @@ -103,7 +100,7 @@ private void validateExistReservations(final Map map) {
List<Space> findSpaces = map.getSpaces();

boolean isExistReservationInAnySpace = findSpaces.stream()
.anyMatch(space -> reservations.existsBySpaceIdAndEndTimeAfter(space.getId(), timeConverter.getNow()));
.anyMatch(space -> reservations.existsBySpaceIdAndEndTimeAfter(space.getId(), LocalDateTime.now()));

if (isExistReservationInAnySpace) {
throw new ReservationExistOnSpaceException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.woowacourse.zzimkkong.exception.map.NoSuchMapException;
import com.woowacourse.zzimkkong.exception.reservation.*;
import com.woowacourse.zzimkkong.exception.space.NoSuchSpaceException;
import com.woowacourse.zzimkkong.infrastructure.TimeConverter;
import com.woowacourse.zzimkkong.repository.MapRepository;
import com.woowacourse.zzimkkong.repository.ReservationRepository;
import com.woowacourse.zzimkkong.service.strategy.ReservationStrategy;
Expand All @@ -34,15 +33,12 @@ public class ReservationService {

private final MapRepository maps;
private final ReservationRepository reservations;
private final TimeConverter timeConverter;

public ReservationService(
final MapRepository maps,
final ReservationRepository reservations,
final TimeConverter timeConverter) {
final ReservationRepository reservations) {
this.maps = maps;
this.reservations = reservations;
this.timeConverter = timeConverter;
}

public ReservationCreateResponse saveReservation(
Expand Down Expand Up @@ -87,9 +83,9 @@ public ReservationFindAllResponse findAllReservations(

List<Space> findSpaces = map.getSpaces();
LocalDate date = reservationFindAllDto.getDate();
List<Reservation> reservations = getReservations(findSpaces, date);
List<Reservation> findReservations = getReservations(findSpaces, date);

return ReservationFindAllResponse.of(findSpaces, reservations);
return ReservationFindAllResponse.of(findSpaces, findReservations);
}

@Transactional(readOnly = true)
Expand All @@ -106,9 +102,9 @@ public ReservationFindResponse findReservations(
LocalDate date = reservationFindDto.getDate();
Space space = map.findSpaceById(spaceId)
.orElseThrow(NoSuchSpaceException::new);
List<Reservation> reservations = getReservations(Collections.singletonList(space), date);
List<Reservation> findReservations = getReservations(Collections.singletonList(space), date);

return ReservationFindResponse.from(reservations);
return ReservationFindResponse.from(findReservations);
}

@Transactional(readOnly = true)
Expand Down Expand Up @@ -198,7 +194,7 @@ private void validateTime(final ReservationCreateDto reservationCreateDto) {
LocalDateTime startDateTime = reservationCreateDto.getStartDateTime().withSecond(0).withNano(0);
LocalDateTime endDateTime = reservationCreateDto.getEndDateTime().withSecond(0).withNano(0);

if (startDateTime.isBefore(timeConverter.getNow())) {
if (startDateTime.isBefore(LocalDateTime.now())) {
throw new ImpossibleStartTimeException();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import com.woowacourse.zzimkkong.exception.space.NoSuchSpaceException;
import com.woowacourse.zzimkkong.exception.space.ReservationExistOnSpaceException;
import com.woowacourse.zzimkkong.infrastructure.ThumbnailManager;
import com.woowacourse.zzimkkong.infrastructure.TimeConverter;
import com.woowacourse.zzimkkong.repository.MapRepository;
import com.woowacourse.zzimkkong.repository.ReservationRepository;
import com.woowacourse.zzimkkong.repository.SpaceRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

import static com.woowacourse.zzimkkong.service.MapService.validateManagerOfMap;
Expand All @@ -26,19 +26,16 @@ public class SpaceService {
private final MapRepository maps;
private final SpaceRepository spaces;
private final ReservationRepository reservations;
private final TimeConverter timeConverter;
private final ThumbnailManager thumbnailManager;

public SpaceService(
final MapRepository maps,
final SpaceRepository spaces,
final ReservationRepository reservations,
final TimeConverter timeConverter,
final ThumbnailManager thumbnailManager) {
this.maps = maps;
this.spaces = spaces;
this.reservations = reservations;
this.timeConverter = timeConverter;
this.thumbnailManager = thumbnailManager;
}

Expand Down Expand Up @@ -159,7 +156,7 @@ private Setting getSetting(final SpaceCreateUpdateRequest spaceCreateUpdateReque
}

private void validateReservationExistence(final Long spaceId) {
if (reservations.existsBySpaceIdAndEndTimeAfter(spaceId, timeConverter.getNow())) {
if (reservations.existsBySpaceIdAndEndTimeAfter(spaceId, LocalDateTime.now())) {
throw new ReservationExistOnSpaceException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
public class ExcludeReservationCreateStrategy implements ExcludeReservationStrategy {
@Override
public void apply(final Space space, final List<Reservation> reservationsOnDate) {
// 예약 생성 시는 검증 전 예약을 제외하지 않아도 되므로 생략합니다
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
public class GuestReservationStrategy implements ReservationStrategy {
@Override
public void validateManagerOfMap(final Map map, final Member manager) {
// guest는 맵의 관리자 확인과정 생략
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public void validateManagerOfMap(final Map map, final Member manager) {

@Override
public void checkCorrectPassword(final Reservation reservation, final String password) {
// manager는 비밀번호 확인과정이 없으므로 생략
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions backend/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/zzimkkong?characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.hikari.maximum-pool-size=45
spring.datasource.hikari.connection-timeout=50000

# flyway
spring.flyway.enabled=true
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/config
12 changes: 12 additions & 0 deletions backend/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
</root>
</springProfile>

<springProfile name="dev">
<include resource="appenders/console-appender.xml"/>
<include resource="appenders/file-appender-error.xml"/>
<include resource="appenders/file-appender-warn.xml"/>

<root level="INFO">
<appender-ref ref="CONSOLE_APPENDER"/>
<appender-ref ref="FILE_APPENDER_ERROR"/>
<appender-ref ref="FILE_APPENDER_WARN"/>
</root>
</springProfile>

<springProfile name="prod">
<include resource="appenders/console-appender.xml"/>
<include resource="appenders/file-appender-error.xml"/>
Expand Down
Loading

0 comments on commit 44551cf

Please sign in to comment.