-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added endpoint for interaction with traffic package
Added unit tests for traffic services Some refactoring and optimizing
- Loading branch information
Showing
35 changed files
with
313 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,13 +27,14 @@ | |
|
||
## Запуск | ||
1. Скомпилировать проект (включить Annotation Processor для Lombok и поставить Lombok Plugin для IDEA) | ||
2. Запустить из IDE или с помощью java -jar app.jar | ||
2. Запустить из IDE через MobileServicesApplication#main или после сборки из target с помощью java -jar mobile-services-1.0.jar | ||
|
||
## Использование | ||
1. WebUI для встроенной базы данных: http://localhost:8080/h2-console/ | ||
1.1 JDBC Url: jdbc:h2:mem:test | ||
1.2. User: sa | ||
1.3. Password: | ||
JDBC Url: jdbc:h2:mem:test | ||
User: sa | ||
Password: | ||
|
||
2. API доступно на порту 8080 | ||
|
||
| Метод | Тело запроса | Адрес | Описание | | ||
|
@@ -42,12 +43,19 @@ | |
| GET | пусто |`localhost:8080/api/v1/sim-card/${номер_телефона}/status` | Статус сим-карты | | ||
| PUT | {"value": <true/false>} |`localhost:8080/api/v1/sim-card/${номер_телефона}/status` | Обновить статус сим-карты | | ||
| GET | пусто |`localhost:8080/api/v1/sim-card/${номер_телефона}/minutes/total` | Количество активных минут | | ||
| GET | пусто |`localhost:8080/api/v1/sim-card/${номер_телефона}/traffic/total` | Количество активных гигабайт | | ||
| GET | пусто |`localhost:8080/api/v1/sim-card/${номер_телефона}/minutes/packages`| Количество активных пакетов минут | | ||
| POST |{"basePackageId": "<id нужного пакета>","addition": <Количество минут>,"daysToLive": "<Время жизни (дней)>"}|`localhost:8080/api/v1/sim-card/${номер_телефона}/minutes` | Добавить пакет минут к сим-карте | | ||
| GET | пусто |`localhost:8080/api/v1/sim-card/${номер_телефона}/traffic/packages`| Количество активных пакетов гигабайт | | ||
| POST |{"basePackageId": "<id базового пакета>","addition": <Количество минут>,"daysToLive": "<Время жизни (дней)>"}|`localhost:8080/api/v1/sim-card/${номер_телефона}/minutes` | Добавить пакет минут к сим-карте | | ||
| POST |{"basePackageId": "<id базового пакета>","addition": <Количество гигабайт>,"daysToLive": "<Время жизни (дней)>"}|`localhost:8080/api/v1/sim-card/${номер_телефона}/traffic` | Добавить пакет гигабайт к сим-карте | | ||
| GET | пусто |`localhost:8080/api/v1/packages-of-minutes/${id_пакета}` | Получить базовый пакет минут (обьект) | | ||
| GET | пусто |`localhost:8080/api/v1/packages-of-minutes/` | Получить все базовые пакеты минут (обьект) | | ||
| GET | пусто |`localhost:8080/api/v1/traffic-packages/${id_пакета}` | Получить базовый пакет траффика (обьект) | | ||
| GET | пусто |`localhost:8080/api/v1/packages-of-minutes/` | Получить все базовые пакеты минут (список) | | ||
| GET | пусто |`localhost:8080/api/v1/traffic-packages/` | Получить все базовые пакеты траффика (список) | | ||
| POST |{"name":"<имя_пакета>","type":"<FREE_ROAMING \ FAVORITE_NUMBER>"} | `localhost:8080/api/v1/packages-of-minutes/` | Сохранить в базу базовый пакет минут | | ||
| PUT |{"value": <количество минут (отр или пол)>} |`localhost:8080/api/v1/packages-of-minutes/details/${details_id}` | Сохранить в базу базовый пакет минут | | ||
| POST |{"name":"<имя_пакета>","type":"<YOUTUBE \ FREE_MESSENGER>"} | `localhost:8080/api/v1/traffic-packages/` | Сохранить в базу базовый пакет траффика | | ||
| PUT |{"value": <количество минут (отр или пол)>} |`localhost:8080/api/v1/packages-of-minutes/details/${details_id}` | Расходовать или добавлять минуты в пакет минут | | ||
| PUT |{"value": <количество гигабайт (отр или пол)>} |`localhost:8080/api/v1/traffic-packages/details/${details_id}` | Расходовать или добавлять гигабайты в пакет траффика | | ||
|
||
## Контакты | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,22 @@ | |
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
import ru.muchnik.yota.mobileservices.model.entity.minutes.MinutesPackageCatalog; | ||
import ru.muchnik.yota.mobileservices.model.entity.minutes.MinutesDetails; | ||
import ru.muchnik.yota.mobileservices.model.entity.SimCard; | ||
import ru.muchnik.yota.mobileservices.model.entity.minutes.MinutesDetails; | ||
import ru.muchnik.yota.mobileservices.model.entity.minutes.MinutesPackageCatalog; | ||
import ru.muchnik.yota.mobileservices.model.entity.traffic.TrafficDetails; | ||
import ru.muchnik.yota.mobileservices.model.entity.traffic.TrafficPackageCatalog; | ||
import ru.muchnik.yota.mobileservices.repository.minutes.MinutesPackageCatalogRepository; | ||
import ru.muchnik.yota.mobileservices.repository.SimCardRepository; | ||
import ru.muchnik.yota.mobileservices.repository.minutes.MinutesPackageCatalogRepository; | ||
import ru.muchnik.yota.mobileservices.repository.traffic.TrafficPackageCatalogRepository; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Application entry point | ||
* Application for "YOTA" test task, see readme.md for more information | ||
* | ||
* @author Muchnik Andrey <b>[email protected]</b> | ||
* @since 01.09.2019 | ||
*/ | ||
@SpringBootApplication | ||
public class MobileServicesApplication { | ||
|
@@ -34,12 +37,12 @@ public CommandLineRunner runner(SimCardRepository simCardRepository, MinutesPack | |
return args -> { | ||
MinutesPackageCatalog freeRoaming = MinutesPackageCatalog.builder() | ||
.name("FreeRoaming") | ||
.type(MinutesPackageCatalog.MinutesPackageType.FREE_ROAMING) | ||
.type(MinutesPackageCatalog.Type.FREE_ROAMING) | ||
.build(); | ||
|
||
MinutesPackageCatalog favoriteNumber = MinutesPackageCatalog.builder() | ||
.name("FavoriteNumber") | ||
.type(MinutesPackageCatalog.MinutesPackageType.FAVORITE_NUMBER) | ||
.type(MinutesPackageCatalog.Type.FAVORITE_NUMBER) | ||
.build(); | ||
|
||
MinutesDetails packageDetails = new MinutesDetails(freeRoaming, 300, 30); | ||
|
@@ -48,7 +51,7 @@ public CommandLineRunner runner(SimCardRepository simCardRepository, MinutesPack | |
|
||
TrafficPackageCatalog trafficYoutube = TrafficPackageCatalog.builder() | ||
.name("Youtube") | ||
.type(TrafficPackageCatalog.TrafficPackageType.YOUTUBE) | ||
.type(TrafficPackageCatalog.Type.YOUTUBE) | ||
.build(); | ||
|
||
TrafficDetails trafficDetails = new TrafficDetails(trafficYoutube, 4, 2); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
src/main/java/ru/muchnik/yota/mobileservices/model/dto/CreatePackageDTO.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/ru/muchnik/yota/mobileservices/model/entity/IPackageCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.