Skip to content

Commit

Permalink
refactor: 패키지 분리
Browse files Browse the repository at this point in the history
Co-authored-by: sosow0212 <[email protected]>
Co-authored-by: be-student <[email protected]>
Co-authored-by: kiarakim <[email protected]>

[#171]
  • Loading branch information
drunkenhw committed Jul 25, 2023
1 parent 62b10cb commit 438bb70
Show file tree
Hide file tree
Showing 94 changed files with 893 additions and 898 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.carffeine.carffeine.common.exception;

public record ExceptionResponse(

int exceptionCode,
String message
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.carffeine.carffeine.common.exception;

public enum Status {
SERVER_ERROR, INVALID, NOT_FOUND

SERVER_ERROR,
INVALID,
NOT_FOUND,
;
}

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
@@ -1,5 +1,9 @@
package com.carffeine.carffeine.common.exception;
package com.carffeine.carffeine.exception;

import com.carffeine.carffeine.common.exception.BaseException;
import com.carffeine.carffeine.common.exception.ExceptionResponse;
import com.carffeine.carffeine.common.exception.ExceptionStatus;
import com.carffeine.carffeine.common.exception.ExceptionType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

public class SlackAppender extends AppenderBase<ILoggingEvent> {

private static final String WBHOOK_URL = System.getenv("SLACK_WEBHOOK_URL");
private static final String WEBHOOK_URL = System.getenv("SLACK_WEBHOOK_URL");

@Override
protected void append(ILoggingEvent eventObject) {
RestTemplate restTemplate = new RestTemplate();
Map<String, Object> body = createSlackErrorBody(eventObject);
restTemplate.postForEntity(WBHOOK_URL, body, String.class);
restTemplate.postForEntity(WEBHOOK_URL, body, String.class);
}

private Map<String, Object> createSlackErrorBody(ILoggingEvent eventObject) {
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
@@ -1,6 +1,6 @@
package com.carffeine.carffeine.config;
package com.carffeine.carffeine.station.config;

import com.carffeine.carffeine.service.chargerstation.ScrapperService;
import com.carffeine.carffeine.station.service.station.ScrapperService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
Expand All @@ -10,7 +10,7 @@
@RequiredArgsConstructor
@Configuration
@ConditionalOnProperty(name = "initialize-charge.enabled", havingValue = "true")
public class InitialChargeStationLoader implements ApplicationRunner {
public class InitialStationLoader implements ApplicationRunner {

private final ScrapperService scrapperService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.carffeine.carffeine.controller.congestion;
package com.carffeine.carffeine.station.controller.congestion;

import com.carffeine.carffeine.controller.chargerStation.dto.StatisticsResponse;
import com.carffeine.carffeine.service.chargerstation.CongestionService;
import com.carffeine.carffeine.service.chargerstation.dto.StatisticsRequest;
import com.carffeine.carffeine.station.controller.congestion.dto.StatisticsResponse;
import com.carffeine.carffeine.station.service.congestion.CongestionService;
import com.carffeine.carffeine.station.service.congestion.dto.StatisticsRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.carffeine.carffeine.station.controller.congestion.dto;

public record CongestionInfoResponse(int hour, double ratio) {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.carffeine.carffeine.controller.chargerStation.dto;
package com.carffeine.carffeine.station.controller.congestion.dto;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.carffeine.carffeine.controller.chargerStation.dto;
package com.carffeine.carffeine.station.controller.congestion.dto;

public record StatisticsResponse(
String stationId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.carffeine.carffeine.station.controller.station;

import com.carffeine.carffeine.station.controller.station.dto.StationSpecificResponse;
import com.carffeine.carffeine.station.controller.station.dto.StationsSimpleResponse;
import com.carffeine.carffeine.station.domain.station.Station;
import com.carffeine.carffeine.station.service.station.StationService;
import com.carffeine.carffeine.station.service.station.dto.CoordinateRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RequestMapping("/api")
@RestController
public class StationController {

private final StationService stationService;

@GetMapping("/stations")
public ResponseEntity<StationsSimpleResponse> getStations(CoordinateRequest request) {
List<Station> stations = stationService.findByCoordinate(request);
StationsSimpleResponse chargerStationsSimpleResponse = StationsSimpleResponse.from(stations);
return ResponseEntity.ok(chargerStationsSimpleResponse);
}

@GetMapping("/stations/{stationId}")
public ResponseEntity<StationSpecificResponse> getStationById(@PathVariable String stationId) {
Station station = stationService.findStationById(stationId);
return ResponseEntity.ok(StationSpecificResponse.from(station));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.carffeine.carffeine.controller.chargerStation.dto;
package com.carffeine.carffeine.station.controller.station.dto;

import com.carffeine.carffeine.domain.chargestation.ChargeStation;
import com.carffeine.carffeine.domain.chargestation.charger.Charger;
import com.carffeine.carffeine.station.domain.charger.Charger;
import com.carffeine.carffeine.station.domain.station.Station;

import java.math.BigDecimal;
import java.util.List;
Expand All @@ -12,7 +12,7 @@ public record ChargerSimpleResponse(
BigDecimal capacity
) {

public static List<ChargerSimpleResponse> from(ChargeStation station) {
public static List<ChargerSimpleResponse> from(Station station) {
return station.getChargers().stream()
.map(ChargerSimpleResponse::from)
.toList();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.carffeine.carffeine.controller.chargerStation.dto;
package com.carffeine.carffeine.station.controller.station.dto;

import com.carffeine.carffeine.domain.chargestation.ChargeStation;
import com.carffeine.carffeine.station.domain.station.Station;

import java.math.BigDecimal;
import java.time.LocalDateTime;
Expand All @@ -15,14 +15,14 @@ public record ChargerSpecificResponse(
String method
) {

public static List<ChargerSpecificResponse> from(ChargeStation station) {
public static List<ChargerSpecificResponse> from(Station station) {
return station.getChargers().stream()
.map(it -> new ChargerSpecificResponse(
it.getType().name(),
it.getPrice(),
it.getCapacity(),
it.getChargerStatus().getLatestUpdateTime(),
it.getChargerStatus().getChargerState().isStandBy(),
it.getChargerStatus().getChargerCondition().isStandBy(),
it.getMethod())
).toList();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.carffeine.carffeine.controller.chargerStation.dto;
package com.carffeine.carffeine.station.controller.station.dto;

import java.math.BigDecimal;
import java.util.List;

public record ChargeStationSimpleResponse(
public record StationSimpleResponse(
String stationId,
String stationName,
String companyName,
Expand Down
Loading

0 comments on commit 438bb70

Please sign in to comment.