diff --git a/demo/src/main/java/com/example/demo/controller/AlbumController.java b/demo/src/main/java/com/example/demo/controller/AlbumController.java deleted file mode 100644 index 1550990..0000000 --- a/demo/src/main/java/com/example/demo/controller/AlbumController.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.example.demo.controller; - -import com.example.demo.dto.AlbumDto; -import org.springframework.web.bind.annotation.*; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; - -@RestController -@RequestMapping("/api") -public class AlbumController { - - private final Map albums = new LinkedHashMap<>(); - private final AtomicInteger idCounter = new AtomicInteger(1); - - public AlbumController() { - // Инициализация пустой коллекцией (как в db.json) - } - - @GetMapping("/albums") - public List getAllAlbums() { - return new ArrayList<>(albums.values()); - } - - @GetMapping("/albums/{id}") - public AlbumDto getAlbumById(@PathVariable Integer id) { - return albums.get(id); - } - - @PostMapping("/albums") - public AlbumDto createAlbum(@RequestBody AlbumDto album) { - Integer newId = idCounter.getAndIncrement(); - album.setId(newId); - albums.put(newId, album); - return album; - } - - @PutMapping("/albums/{id}") - public AlbumDto updateAlbum(@PathVariable Integer id, @RequestBody AlbumDto album) { - if (albums.containsKey(id)) { - album.setId(id); - albums.put(id, album); - return album; - } - return null; - } - - @PatchMapping("/albums/{id}") - public AlbumDto patchAlbum(@PathVariable Integer id, @RequestBody Map updates) { - AlbumDto existingAlbum = albums.get(id); - if (existingAlbum != null) { - if (updates.containsKey("artistId")) { - existingAlbum.setArtistId((Integer) updates.get("artistId")); - } - if (updates.containsKey("title")) { - existingAlbum.setTitle((String) updates.get("title")); - } - if (updates.containsKey("year")) { - existingAlbum.setYear((Integer) updates.get("year")); - } - albums.put(id, existingAlbum); - return existingAlbum; - } - return null; - } - - @DeleteMapping("/albums/{id}") - public boolean deleteAlbum(@PathVariable Integer id) { - return albums.remove(id) != null; - } -} diff --git a/demo/src/main/java/com/example/demo/controller/SongController.java b/demo/src/main/java/com/example/demo/controller/SongController.java deleted file mode 100644 index 5bbcba7..0000000 --- a/demo/src/main/java/com/example/demo/controller/SongController.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.example.demo.controller; - -import com.example.demo.dto.SongDto; -import org.springframework.web.bind.annotation.*; -import java.util.*; -import java.util.concurrent.atomic.AtomicInteger; - -@RestController -@RequestMapping("/api") -public class SongController { - - private final Map songs = new LinkedHashMap<>(); - private final AtomicInteger idCounter = new AtomicInteger(1); - - public SongController() { - // Инициализация пустой коллекцией (как в db.json) - } - - @GetMapping("/songs") - public List getAllSongs() { - return new ArrayList<>(songs.values()); - } - - @GetMapping("/songs/{id}") - public SongDto getSongById(@PathVariable Integer id) { - return songs.get(id); - } - - @PostMapping("/songs") - public SongDto createSong(@RequestBody SongDto song) { - Integer newId = idCounter.getAndIncrement(); - song.setId(newId); - songs.put(newId, song); - return song; - } - - @PutMapping("/songs/{id}") - public SongDto updateSong(@PathVariable Integer id, @RequestBody SongDto song) { - if (songs.containsKey(id)) { - song.setId(id); - songs.put(id, song); - return song; - } - return null; - } - - @PatchMapping("/songs/{id}") - public SongDto patchSong(@PathVariable Integer id, @RequestBody Map updates) { - SongDto existingSong = songs.get(id); - if (existingSong != null) { - if (updates.containsKey("albumId")) { - existingSong.setAlbumId((Integer) updates.get("albumId")); - } - if (updates.containsKey("title")) { - existingSong.setTitle((String) updates.get("title")); - } - if (updates.containsKey("duration")) { - existingSong.setDuration((String) updates.get("duration")); - } - songs.put(id, existingSong); - return existingSong; - } - return null; - } - - @DeleteMapping("/songs/{id}") - public boolean deleteSong(@PathVariable Integer id) { - return songs.remove(id) != null; - } -} diff --git a/demo/src/main/java/com/example/demo/dto/AlbumDto.java b/demo/src/main/java/com/example/demo/dto/AlbumDto.java deleted file mode 100644 index 7edcefe..0000000 --- a/demo/src/main/java/com/example/demo/dto/AlbumDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.example.demo.dto; - -public class AlbumDto { - private Integer id; - private Integer artistId; - private String title; - private Integer year; - - public AlbumDto() {} - - public AlbumDto(Integer id, Integer artistId, String title, Integer year) { - this.id = id; - this.artistId = artistId; - this.title = title; - this.year = year; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getArtistId() { - return artistId; - } - - public void setArtistId(Integer artistId) { - this.artistId = artistId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Integer getYear() { - return year; - } - - public void setYear(Integer year) { - this.year = year; - } -} diff --git a/demo/src/main/java/com/example/demo/dto/SongDto.java b/demo/src/main/java/com/example/demo/dto/SongDto.java deleted file mode 100644 index 8c5d82a..0000000 --- a/demo/src/main/java/com/example/demo/dto/SongDto.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.example.demo.dto; - -public class SongDto { - private Integer id; - private Integer albumId; - private String title; - private String duration; - - public SongDto() {} - - public SongDto(Integer id, Integer albumId, String title, String duration) { - this.id = id; - this.albumId = albumId; - this.title = title; - this.duration = duration; - } - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Integer getAlbumId() { - return albumId; - } - - public void setAlbumId(Integer albumId) { - this.albumId = albumId; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDuration() { - return duration; - } - - public void setDuration(String duration) { - this.duration = duration; - } -} diff --git a/punkrock-react/db.json b/punkrock-react/db.json deleted file mode 100644 index aff0fe7..0000000 --- a/punkrock-react/db.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "artists": [ - { - "id": "9daa", - "name": "testlabуцк", - "description": "sadууу", - "epochId": 2, - "countryId": 3 - }, - { - "id": "98ad", - "name": "ыфвфы", - "description": "выфв", - "epochId": 1, - "countryId": 1 - }, - { - "id": "dd28", - "name": "аааа", - "description": "ааа", - "epochId": 2, - "countryId": 3 - }, - { - "id": "b499", - "name": "бб", - "description": "уафв", - "epochId": 1, - "countryId": 3 - }, - { - "id": "0f62", - "name": "Максим", - "description": "2", - "epochId": 2, - "countryId": 1 - } - ], - "countries": [ - { - "id": "1", - "name": "Россия" - }, - { - "id": "2", - "name": "США" - }, - { - "id": "3", - "name": "Тайга" - } - ], - "epochs": [ - { - "id": "1", - "name": "1980-е" - }, - { - "id": "2", - "name": "1990-е" - } - ], - "albums": [], - "songs": [] -} \ No newline at end of file diff --git a/punkrock-react/package.json b/punkrock-react/package.json index a3dc4ac..fe50e61 100644 --- a/punkrock-react/package.json +++ b/punkrock-react/package.json @@ -22,9 +22,7 @@ "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject", - "json-server": "json-server --watch db.json --port 3001", - "dev": "concurrently \"npm start\" \"npm run json-server\"" + "eject": "react-scripts eject" }, "eslintConfig": { "extends": [ @@ -44,8 +42,5 @@ "last 1 safari version" ] }, - "devDependencies": { - "concurrently": "^9.2.1", - "json-server": "^1.0.0-beta.3" - } + "devDependencies": {} } diff --git a/punkrock-react/public/db.json b/punkrock-react/public/db.json deleted file mode 100644 index 1b16c47..0000000 --- a/punkrock-react/public/db.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "artists": [ - { - "id": "1", - "name": "Гражданская Оборона", - "description": "Советская и российская рок-группа, основанная Егором Летовым.", - "year": 1984, - "country": "Россия" - }, - { - "id": "f28f", - "name": "что-то", - "description": "sdad", - "year": 1998, - "country": "Россия" - }, - { - "id": "2134", - "name": "бб", - "description": "ццвыф", - "year": 1999, - "country": "Россия" - } - ], - "albums": [ - { - "id": "1", - "artistId": 1, - "title": "Поганая молодёжь", - "year": 1985 - }, - { - "id": "2", - "artistId": 1, - "title": "Оптимизм", - "year": 1985 - }, - { - "id": "3", - "artistId": 2, - "title": "Камнем по голове", - "year": 1996 - } - ], - "songs": [ - { - "id": "1", - "albumId": 1, - "title": "Я бесполезен", - "duration": "2:30" - }, - { - "id": "2", - "albumId": 3, - "title": "Кукла колдуна", - "duration": "3:15" - } - ] -} \ No newline at end of file