Доделал
This commit is contained in:
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
9
.idea/PIbd-22_BuslaevRoman_InternetProgramming.iml
generated
Normal file
9
.idea/PIbd-22_BuslaevRoman_InternetProgramming.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
8
.idea/compiler.xml
generated
Normal file
8
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel>
|
||||
<module name="movie-api" target="21" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
15
.idea/gradle.xml
generated
Normal file
15
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$/backend" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$/backend" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/PIbd-22_BuslaevRoman_InternetProgramming.iml" filepath="$PROJECT_DIR$/.idea/PIbd-22_BuslaevRoman_InternetProgramming.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,6 +3,8 @@ package ru.ulstu.is.server.api;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import ru.ulstu.is.server.dto.DirectorDto;
|
||||
import ru.ulstu.is.server.dto.GenreDto;
|
||||
import ru.ulstu.is.server.dto.MovieDto;
|
||||
|
||||
import java.util.*;
|
||||
@@ -15,16 +17,20 @@ public class MoviesController {
|
||||
private final Map<String, MovieDto> storage = new ConcurrentHashMap<>();
|
||||
|
||||
public MoviesController() {
|
||||
GenreDto g1 = new GenreDto(); g1.setId("1"); g1.setName("Фантастика");
|
||||
GenreDto g2 = new GenreDto(); g2.setId("2"); g2.setName("Драма");
|
||||
DirectorDto d1 = new DirectorDto(); d1.setId("1"); d1.setName("Кристофер Нолан");
|
||||
DirectorDto d2 = new DirectorDto(); d2.setId("2"); d2.setName("Лана Вачовски");
|
||||
MovieDto m1 = new MovieDto();
|
||||
m1.setId("1"); m1.setTitle("Начало"); m1.setGenreId("1"); m1.setDirectorId("1");
|
||||
m1.setId("1"); m1.setTitle("Начало"); m1.setGenre(g1); m1.setDirector(d1);
|
||||
storage.put(m1.getId(), m1);
|
||||
|
||||
MovieDto m2 = new MovieDto();
|
||||
m2.setId("2"); m2.setTitle("Интерстеллар"); m2.setGenreId("1"); m2.setDirectorId("1");
|
||||
m2.setId("2"); m2.setTitle("Интерстеллар"); m2.setGenre(g2); m2.setDirector(d1);
|
||||
storage.put(m2.getId(), m2);
|
||||
|
||||
MovieDto m3 = new MovieDto();
|
||||
m3.setId("3"); m3.setTitle("Матрица"); m3.setGenreId("1"); m3.setDirectorId("2");
|
||||
m3.setId("3"); m3.setTitle("Матрица"); m3.setGenre(g1); m3.setDirector(d2);
|
||||
storage.put(m3.getId(), m3);
|
||||
}
|
||||
|
||||
@@ -67,8 +73,6 @@ public class MoviesController {
|
||||
if (existing == null) return ResponseEntity.notFound().build();
|
||||
|
||||
if (patch.containsKey("title")) existing.setTitle((String) patch.get("title"));
|
||||
if (patch.containsKey("genreId")) existing.setGenreId((String) patch.get("genreId"));
|
||||
if (patch.containsKey("directorId")) existing.setDirectorId((String) patch.get("directorId"));
|
||||
if (patch.containsKey("image")) existing.setImage((String) patch.get("image"));
|
||||
|
||||
storage.put(id, existing);
|
||||
|
||||
@@ -8,19 +8,19 @@ public class MovieDto {
|
||||
@NotBlank
|
||||
private String title;
|
||||
@NotBlank
|
||||
private String genreId;
|
||||
private GenreDto genre;
|
||||
@NotBlank
|
||||
private String directorId;
|
||||
private DirectorDto director;
|
||||
private String image;
|
||||
|
||||
public String getId() { return id; }
|
||||
public void setId(String id) { this.id = id; }
|
||||
public String getTitle() { return title; }
|
||||
public void setTitle(String title) { this.title = title; }
|
||||
public String getGenreId() { return genreId; }
|
||||
public void setGenreId(String genreId) { this.genreId = genreId; }
|
||||
public String getDirectorId() { return directorId; }
|
||||
public void setDirectorId(String directorId) { this.directorId = directorId; }
|
||||
public GenreDto getGenre() { return genre; }
|
||||
public void setGenre(GenreDto genre) { this.genre = genre; }
|
||||
public DirectorDto getDirector() { return director; }
|
||||
public void setDirector(DirectorDto director) { this.director = director; }
|
||||
public String getImage() { return image; }
|
||||
public void setImage(String image) { this.image = image; }
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
node_modules
|
||||
dist
|
||||
backend
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": ["airbnb-base", "prettier"],
|
||||
"plugins": ["prettier", "html"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"no-console": "off",
|
||||
"prettier/prettier": [
|
||||
"error",
|
||||
{ "endOfLine": "auto" }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import axios from "axios";
|
||||
|
||||
const api = axios.create({ baseURL: "http://localhost:3000" });
|
||||
const api = axios.create({ baseURL: "http://localhost:8080/api/1.0" });
|
||||
export default api;
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import axios from "axios";
|
||||
|
||||
const AuthCtx = createContext(null);
|
||||
const API = axios.create({ baseURL: "http://localhost:3000" });
|
||||
const API = axios.create({ baseURL: "http://localhost:8080/api/1.0" });
|
||||
|
||||
export function AuthProvider({ children }) {
|
||||
const [user, setUser] = useState(null);
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function useMovies() {
|
||||
const [error, setError] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
axios.get("/movies")
|
||||
axios.get("http://localhost:8080/api/1.0/movies")
|
||||
.then(res => setMovies(res.data))
|
||||
.catch(setError)
|
||||
.finally(() => setLoading(false));
|
||||
@@ -15,7 +15,7 @@ export default function useMovies() {
|
||||
|
||||
const remove = async (id) => {
|
||||
try {
|
||||
await axios.delete(`/movies/${id}`);
|
||||
await axios.delete(`http://localhost:8080/api/1.0/movies/${id}`);
|
||||
setMovies(prev => prev.filter(m => m.id !== id));
|
||||
} catch (err) {
|
||||
console.error("Ошибка при удалении:", err);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import MovieForm from "../components/MovieForm";
|
||||
|
||||
const api = axios.create({ baseURL: "http://localhost:3000" });
|
||||
const api = axios.create({ baseURL: "http://localhost:8080/api/1.0" });
|
||||
|
||||
export default function MovieEditor({ mode }) {
|
||||
const { id } = useParams();
|
||||
|
||||
Reference in New Issue
Block a user