From 0e637791ef20e73eec151308a8548ec94854bb58 Mon Sep 17 00:00:00 2001 From: Ismailov_Rovshan Date: Wed, 24 May 2023 17:19:18 +0400 Subject: [PATCH] =?UTF-8?q?5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20(=D0=B3=D0=BE=D1=80=D0=BE=D0=B4=20=D0=B1=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D1=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 16 ++- data.mv.db | Bin 57344 -> 131072 bytes .../src/components/catalogs/CatalogUsers.jsx | 120 +++++++++++------- .../ru/ulstu/is/sbapp/WebConfiguration.java | 16 +++ .../controller/CommunityController.java | 5 +- .../controller/MusicController.java | 8 +- .../controller/UserController.java | 38 +++++- .../is/sbapp/socialNetwork/dto/UserDTO.java | 45 +++++-- .../sbapp/socialNetwork/models/UserModel.java | 4 + .../repository/UserRepository.java | 3 + .../services/CommunityService.java | 5 +- .../socialNetwork/services/UserService.java | 46 ++++++- .../ru/ulstu/is/sbapp/JpaCommunityTest.java | 18 +-- 13 files changed, 244 insertions(+), 80 deletions(-) diff --git a/build.gradle b/build.gradle index 482c489..b2eff23 100644 --- a/build.gradle +++ b/build.gradle @@ -14,12 +14,22 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-devtools' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect' + + implementation 'org.webjars:bootstrap:5.1.3' + implementation 'org.webjars:jquery:3.6.0' + implementation 'org.webjars:font-awesome:6.1.0' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.h2database:h2:2.1.210' - implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.5' - implementation 'org.hibernate.validator:hibernate-validator:7.0.1.Final' + implementation 'org.hibernate.validator:hibernate-validator' + + implementation 'org.springdoc:springdoc-openapi-ui:1.6.5' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' } tasks.named('test') { diff --git a/data.mv.db b/data.mv.db index cb6c6d519d6cc206cdf4c0ac41499548a9b3b8eb..b42c008b36872a2e8c4b1afa09c93fb348e2b315 100644 GIT binary patch literal 131072 zcmeHwTZ|pqbzR+NH@k+9;XE`0NtQBKJr52gPP@)I^=u>Z^mBNJ-Azt+lS3*B+VwbR zh8RvaK{jWGwh-$>0TSrP@t18VfDt>k6Zyk-?AS2!p`ZMZg4l^c)o?eo}Y@4fbg8G1gtxgEbZ6Uq1W8$Zuyh-F#l z<9F|Fy*EPyJs;oZ;SNt`i0@k>4tT`k^J4q<`{53L{Q{Kdqdn8w6kOuV`NZus-z``8=Y`H+9e4dY3E=AZP8&lyi-H#kia zR&3eDR#0q(#a2{o#l==qZ1G}Cs4Z?4Tcp^c#a3}$UR;+u#kX#;nqYy*S^W-MOlwLAYJ208phWz&KCN zZ^!Z7Tj5rGZ$=1<{9ysyR=`=VfqMhj^wO{CrIX@@Uivz4LP(+m&-7H@hz{J-fZMt5 zG7Y!I{-{75sAl75sL^`%6gTl>CGN0>+O;#(wn%u{npkLY9W|ur4~shqG}J+cnlQ(1 zfgLK?;XYvd3U*wF?Mv8k1$GHD(-J!j+y>a820N6nZ7XPjorfsRP^sLbNxOi}>##HB zw(P*sq^-fsU^|2=W!H2hi8Rb1b; z3bq`|_6ggrOIzwT6GVqy!j!OMr>RMD4K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Ex0IXnmgg zyUzXz9lUr#Z>%{UoP9B#5n0;*;k`DFh4oclGhWk4`~Rq)z&LF-b(81RANb9v#nfTB z{124&e;TGPsy?a6)I}RhJVH;ez1eBhSJvD8_R65sukW_|54ycOx3I1+&M(T;Mcv+@ z-iv~+j0KqtT_i&n4M#V*-lZ}zm11HjuJ=2G$+9y6ES)@CCk+PnC6rY${PynQHb+A zB&-@QZ9@r+=9JCCL1JVRhrW@>o-YT-SjZ-Ucr&D|pGPSXZwx>G@%;Y- D3Yys8 diff --git a/front/src/components/catalogs/CatalogUsers.jsx b/front/src/components/catalogs/CatalogUsers.jsx index 2fc4a7b..1e2c5a2 100644 --- a/front/src/components/catalogs/CatalogUsers.jsx +++ b/front/src/components/catalogs/CatalogUsers.jsx @@ -6,7 +6,8 @@ import DataService from "../../services/DataService" let headers = [ {label: "name", text: "Имя"}, {label: "music", text: "Музыка"}, - {label: "fullNames", text: "Группы"} + {label: "community", text: "Группы"}, + { label: "city", text: "Город" } ] export default function CatalogUsers() { const url = "/users"; @@ -14,7 +15,8 @@ export default function CatalogUsers() { const [data, setData] = useState({ name: "", music: [], - fullNames: [] + community: [], + city: "" }); const [selectedData, setSelectedData] = useState({ @@ -58,12 +60,12 @@ export default function CatalogUsers() { } function addCommunity() { - for(let a of data.fullNames) { + for(let a of data.community) { if(a == selectedData.community) return; } - let temp = data.fullNames.slice(0); + let temp = data.community.slice(0); temp.push(selectedData.community); - setData({...data, fullNames: temp}); + setData({...data, community: temp}); } function deleteMusic(e) { @@ -74,12 +76,12 @@ export default function CatalogUsers() { function deleteCommunity(e) { let communityName = e.target.previousSibling.textContent; - let temp = data.fullNames.filter(x => (x != communityName)); - setData({...data, fullNames: temp}) + let temp = data.community.filter(x => (x != communityName)); + setData({...data, community: temp}) } function onAdd() { - setData({name: "", music: [], fullNames: []}); + setData({name: "", music: [], community: []}); } @@ -96,50 +98,72 @@ export default function CatalogUsers() {
- - + +
- +
+ - { - data.music.map(value => ( -
- {value} - -
- )) - } -

- + {data.music.map(value => ( +
+ {value} + +
+ ))} - - { - data.fullNames.map(value => ( -
- {value} - -
- )) - }

- - + + + + {data.community.map(value => ( +
+ {value} + +
+ ))} +

+ +
) } \ No newline at end of file diff --git a/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java b/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java index 64d729a..1155aa3 100644 --- a/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java +++ b/src/main/java/ru/ulstu/is/sbapp/WebConfiguration.java @@ -2,6 +2,8 @@ package ru.ulstu.is.sbapp; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration @@ -10,4 +12,18 @@ public class WebConfiguration implements WebMvcConfigurer { public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("*"); } + public static final String REST_API = "/api"; + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + WebMvcConfigurer.super.addViewControllers(registry); + registry.addViewController("users"); + registry.addViewController("contacts"); + registry.addViewController("catalogs"); + } + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/static/css/**").addResourceLocations("/static/css/"); + } + } \ No newline at end of file diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/CommunityController.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/CommunityController.java index caaf422..38dee1a 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/CommunityController.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/CommunityController.java @@ -1,6 +1,7 @@ package ru.ulstu.is.sbapp.socialNetwork.controller; import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.sbapp.WebConfiguration; import ru.ulstu.is.sbapp.socialNetwork.dto.CommunityDTO; import ru.ulstu.is.sbapp.socialNetwork.services.CommunityService; @@ -8,7 +9,7 @@ import javax.validation.Valid; import java.util.List; @RestController -@RequestMapping("/communities") +@RequestMapping(WebConfiguration.REST_API + "/communities") public class CommunityController { private final CommunityService communityService; @@ -23,7 +24,7 @@ public class CommunityController { @GetMapping("") public List getCommunities() { - return communityService.findAllCommunitys().stream().map(CommunityDTO::new).toList(); + return communityService.findAllCommunities().stream().map(CommunityDTO::new).toList(); } @PostMapping("") diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/MusicController.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/MusicController.java index 5f7ec61..21e68dc 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/MusicController.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/MusicController.java @@ -2,24 +2,30 @@ package ru.ulstu.is.sbapp.socialNetwork.controller; import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.sbapp.WebConfiguration; import ru.ulstu.is.sbapp.socialNetwork.dto.MusicDTO; import ru.ulstu.is.sbapp.socialNetwork.models.Music; import ru.ulstu.is.sbapp.socialNetwork.services.MusicService; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; @RestController -@RequestMapping("/musics") +@RequestMapping(WebConfiguration.REST_API + "/musics") public class MusicController { + private final MusicService musicService; + public MusicController(MusicService musicService){ this.musicService = musicService; } + @GetMapping("/{id}") public MusicDTO getMusic(@PathVariable Long id){ return new MusicDTO(musicService.findMusic(id)); } + @GetMapping("") public List getMusics() { return musicService.findAllMusics().stream().map(MusicDTO::new).toList(); diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/UserController.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/UserController.java index f741075..a56a3fb 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/UserController.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/controller/UserController.java @@ -1,15 +1,18 @@ package ru.ulstu.is.sbapp.socialNetwork.controller; import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.sbapp.WebConfiguration; import ru.ulstu.is.sbapp.socialNetwork.dto.UserDTO; import ru.ulstu.is.sbapp.socialNetwork.models.UserModel; import ru.ulstu.is.sbapp.socialNetwork.services.UserService; + import javax.validation.Valid; import java.util.List; + @RestController -@RequestMapping("/users") +@RequestMapping(WebConfiguration.REST_API + "/users") public class UserController { private final UserService userService; @@ -27,6 +30,39 @@ public class UserController { return userService.findAllUsers().stream().map(UserDTO::new).toList(); } + @PostMapping("") + public UserDTO createUser(@RequestBody @Valid UserDTO user) { + UserModel result = userService.addUser(user.getName(), user.getCity()); + userService.updateCommunities(result.getId(), user.getCommunity()); + return new UserDTO(userService.updateMusics(result.getId(), user.getMusic())); + } + @PatchMapping("/{id}") + public UserDTO updateUser(@PathVariable Long id, + @RequestBody @Valid UserDTO user) { + UserModel result = userService.updateUser(id, user.getName()); + userService.updateCommunities(result.getId(), user.getCommunity()); + return new UserDTO(userService.updateMusics(result.getId(), user.getMusic())); + } + + @PatchMapping("/add_music/{id}") + public UserDTO addMusic(@PathVariable Long id, @RequestParam Long music_id) { + return new UserDTO(userService.addMusic(id, music_id)); + } + + @PatchMapping("/add_community/{id}") + public UserDTO addCommunity(@PathVariable Long id, @RequestParam Long community_id) { + return new UserDTO(userService.addCommunity(id, community_id)); + } + @GetMapping("/search") + public List searchUsers(@RequestParam("city") String city) { + List users = userService.findUserByCity(city); + return users.stream().map(UserDTO::new).toList(); + } + + @DeleteMapping("/{id}") + public UserDTO deleteUser(@PathVariable Long id) { + return new UserDTO(userService.deleteUser(id)); + } } diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/dto/UserDTO.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/dto/UserDTO.java index aa24f2e..001a166 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/dto/UserDTO.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/dto/UserDTO.java @@ -14,39 +14,61 @@ public class UserDTO { public UserDTO(){} public UserDTO(UserModel user){ + this.id = user.getId(); this.name = user.getName(); this.city = user.getCity(); + if(user.getMusics() != null) { + this.music = user.getMusics().stream().map(Music::getName).toList(); + } + if(user.getGroups() != null) { + this.community = user.getGroups().stream().map(Community::getName).toList(); + } } - private List musics; - private List communities; + public UserDTO(Long id, String name) { + this.id = id; + this.name = name; + } + private List music; + private List community; public Long getId(){return id;} public String getName(){return name;} public void setName(String firstName){this.name = firstName;} - public void addMusic(Music g) { - musics.add(g); - } - public List getMusics() { - return musics; + public List getMusic() { + return music; } - public void addCommunity(Community g) { - communities.add(g); + public List getCommunity() { + return community; } - public List getGroups() { - return communities; + + public void setCommunities(List communities) { + this.community = communities; + } + + public void setMusics(List musics) { + this.music = musics; } public void setCity(String city){ this.city = city; } + public String getCity(){ return city; } + public void setMusic(List music) { + this.music = music; + } + + public void setCommunity(List community) { + this.community = community; + } + @Override public String toString() { return "User{" + @@ -55,4 +77,5 @@ public class UserDTO { ", city='" + city + '\'' + '}'; } + } diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/models/UserModel.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/models/UserModel.java index 33c96d6..4cd934a 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/models/UserModel.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/models/UserModel.java @@ -3,6 +3,7 @@ import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import javax.persistence.*; +import java.util.ArrayList; import java.util.List; @Entity @@ -35,6 +36,7 @@ public class UserModel { } public UserModel(String name){ this.name = name; + this.city = "Mosscow"; } public UserModel(String name, String city){ this.name = name; @@ -53,6 +55,7 @@ public class UserModel { public void setName(String firstName){this.name = firstName;} public void addMusic(Music g) { + if(musics == null) musics = new ArrayList<>(); musics.add(g); } public List getMusics() { @@ -60,6 +63,7 @@ public class UserModel { } public void addCommunity(Community g) { + if(communities == null) communities = new ArrayList<>(); communities.add(g); } public List getGroups() { diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/repository/UserRepository.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/repository/UserRepository.java index bcc3cc9..af1876a 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/repository/UserRepository.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/repository/UserRepository.java @@ -3,5 +3,8 @@ package ru.ulstu.is.sbapp.socialNetwork.repository; import org.springframework.data.jpa.repository.JpaRepository; import ru.ulstu.is.sbapp.socialNetwork.models.UserModel; +import java.util.List; + public interface UserRepository extends JpaRepository { + List findByCity(String city); } diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/CommunityService.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/CommunityService.java index 1f00286..9a5b5fe 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/CommunityService.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/CommunityService.java @@ -40,10 +40,11 @@ public class CommunityService { } @Transactional(readOnly = true) - public List findAllCommunitys() { + public List findAllCommunities() { return repo.findAll(); } + @Transactional public Community updateCommunity(Long id, String name) { if (!StringUtils.hasText(name)) { @@ -79,7 +80,7 @@ public class CommunityService { } @Transactional - public void deleteAllCommunitys() { + public void deleteAllCommunities() { repo.deleteAll(); } diff --git a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/UserService.java b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/UserService.java index 6609800..a3facc9 100644 --- a/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/UserService.java +++ b/src/main/java/ru/ulstu/is/sbapp/socialNetwork/services/UserService.java @@ -9,6 +9,7 @@ import ru.ulstu.is.sbapp.socialNetwork.models.UserModel; import ru.ulstu.is.sbapp.socialNetwork.repository.UserRepository; import javax.persistence.EntityNotFoundException; +import javax.persistence.Query; import java.util.List; import java.util.Optional; @@ -34,12 +35,26 @@ public class UserService { UserModel user = new UserModel(name, city); return repo.save(user); } + @Transactional + public UserModel addUser(String name, String city, List musics, List communities) { + + if (!StringUtils.hasText(name)) { + throw new IllegalArgumentException("Name is null or empty"); + } + + UserModel user = new UserModel(name, city); + UserModel result = repo.save(user); + + updateMusics(result.getId(), musics); + return updateCommunities(user.getId(), communities); + } + @Transactional public UserModel addMusic(Long userId, Long musicId) { final Optional userOpt= repo.findById(userId); if (userOpt.isEmpty()) { - throw new EntityNotFoundException(String.format("Film with id [%s] is not found", musicId)); + throw new EntityNotFoundException(String.format("User with id [%s] is not found", musicId)); } UserModel user = userOpt.get(); @@ -83,11 +98,16 @@ public class UserService { // @Transactional(readOnly = true) // public List findUserByCity(String city){ -// Query query = em.createQuery("select u from UserModel u where u.city = :city", +// Query query = repo.createQuery("select u from UserModel u where u.city = :city", // UserModel.class).setParameter("city", city); // List result = query.getResultList(); -// return result; +// return result; // } + @Transactional(readOnly = true) + public List findUserByCity(String city){ + List result = repo.findByCity(city); + return result; + } @Transactional(readOnly = true) public List findAllUsers() { @@ -112,7 +132,27 @@ public class UserService { return repo.save(currentUser); } //update community, musics + @Transactional + public UserModel updateUser(Long id, String name,String city, List musics, List Communities) { + if (!StringUtils.hasText(name)) { + throw new IllegalArgumentException("User name is null or empty"); + } + final Optional currentUserOpt = repo.findById(id); + if(currentUserOpt.isEmpty()) { + return null; + } + + final UserModel currentUser = currentUserOpt.get(); + + currentUser.setName(name); + currentUser.setCity(city); + repo.save(currentUser); + + updateMusics(id, musics); + return updateCommunities(id, Communities); + } + @Transactional public UserModel updateCommunities(Long userId , List communities) { final Optional userOpt = repo.findById(userId); diff --git a/src/test/java/ru/ulstu/is/sbapp/JpaCommunityTest.java b/src/test/java/ru/ulstu/is/sbapp/JpaCommunityTest.java index b5d1d27..b5e3e4e 100644 --- a/src/test/java/ru/ulstu/is/sbapp/JpaCommunityTest.java +++ b/src/test/java/ru/ulstu/is/sbapp/JpaCommunityTest.java @@ -26,7 +26,7 @@ public class JpaCommunityTest { @Test void testUserCreate() { - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); final Community community = communityService.addCommunity("CodeGPT"); log.info(community.toString()); Assertions.assertNotNull(community.getId()); @@ -34,13 +34,13 @@ public class JpaCommunityTest { @Test void testUserReadNotFound() { - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); Assertions.assertThrows(EntityNotFoundException.class, () -> communityService.findCommunity(-1L)); } @Test void findUser() { - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); final Community community = communityService.addCommunity("CodeGPT"); log.info(community.toString()); final Community findCommunity = communityService.findCommunity(community.getId()); @@ -50,18 +50,18 @@ public class JpaCommunityTest { @Test void testReadAll() { - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); userService.deleteAllUsers(); final Community community = communityService.addCommunity("CodeGPT"); log.info(community.toString()); - final List communitys = communityService.findAllCommunitys(); - Assertions.assertEquals(communitys.size(), 1); + final List communities = communityService.findAllCommunities(); + Assertions.assertEquals(communities.size(), 1); } @Test void updateCommunity() { userService.deleteAllUsers(); - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); final Community community = communityService.addCommunity("CodeGPT 2"); communityService.updateCommunity(community.getId(), "CodeGPT 3"); final Community findCommunity = communityService.findCommunity(community.getId()); @@ -72,7 +72,7 @@ public class JpaCommunityTest { @Test void deleteCommunity() { userService.deleteAllUsers(); - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); final Community community = communityService.addCommunity("CodeGPT"); log.info(community.toString()); communityService.deleteCommunity(community.getId()); @@ -83,7 +83,7 @@ public class JpaCommunityTest { @Test void addUser() { userService.deleteAllUsers(); - communityService.deleteAllCommunitys(); + communityService.deleteAllCommunities(); userService.findAllUsers(); final Community community = communityService.addCommunity("CodeGPT"); final UserModel user = userService.addUser("its_mailov", "Moscow");