🔥Creating API of Getting all posts of category | get all posts of user | Backend API Course

  Рет қаралды 27,407

Learn Code With Durgesh

Learn Code With Durgesh

Күн бұрын

Пікірлер: 57
@nilesh_rode_96k
@nilesh_rode_96k 2 жыл бұрын
Sir please make video on angular 12 Spring boot rest API MySQL database. Get multiple images from database through rest API and display angular.
@maheshchandane7197
@maheshchandane7197 11 ай бұрын
Durgesh bhai aap genius ho❤ India me Spring ke badshah
@rahul-sinha
@rahul-sinha 2 жыл бұрын
Durgesh Sir, please do include proper THUMBNAIL for each videos as well. Thanks 👍
@dnyaneshwarbandgar5338
@dnyaneshwarbandgar5338 2 жыл бұрын
Great sir 👌👌
@AbhishekKumar-hy7fb
@AbhishekKumar-hy7fb 2 жыл бұрын
Sir plz implement all services in Microservice manners
@sunnysingh7854
@sunnysingh7854 2 жыл бұрын
The assignments which you gave are done
@Vithal_Nivargi
@Vithal_Nivargi 2 жыл бұрын
6:34 I have created for the User....
@pradeepsharma5711
@pradeepsharma5711 2 жыл бұрын
As you said to complete the suggested method without your help. So i did. Name: Pradeep Sharma Method completed from my end.
@vishalgoel7661
@vishalgoel7661 Жыл бұрын
Sir in postman your url starts with http .What should we do so that I can use https ? I have a very little idea of https like "we need a certificate and write code for it's validation ." Sir please make video on this topic as well .
@himanshugoyal9581
@himanshugoyal9581 2 жыл бұрын
Hello Sir, Thanx for helping all students like me with all these types of contents. Further, i have completed APIs of getOnePost(postId) and getAllPost(). Please keep supporting us with your content.
@abbasmastan7793
@abbasmastan7793 11 ай бұрын
Sir thank you for this course but please sir implements multilangual work in this app like urdu and english this will be my final year project
@lordgreat6051
@lordgreat6051 2 жыл бұрын
coding can already be so annoying sometimes like forgetting to add autowired annotation and wondering for an hour why im getting null on request and then these youtube ads mess with my brain ugh
@mohammadsaddanhussain7342
@mohammadsaddanhussain7342 2 жыл бұрын
Hello Sir, I am getting null value while retrieving data from database using getPostByUser or getPostCategory. { "postTitle": null, "postContent": null, "postImageName": null, "postAddedDate": null, "category": null, "user": null }
@hashmisaddam7078
@hashmisaddam7078 2 жыл бұрын
Same question
@vatsalvasoya566
@vatsalvasoya566 2 жыл бұрын
@@hashmisaddam7078 same question did u got solution to it?!
@sujayjeppu2320
@sujayjeppu2320 2 жыл бұрын
public List getAllPostsByCategory(Long categoryId) { Category category = this.categoryRepo.findById(categoryId).orElseThrow(() -> new ResourceNotFoundException("Category", "Id", categoryId)); List allPostsByCategory = this.postRepo.findByCategory(category); return extractAllPostDTOs(allPostsByCategory); } public List getAllPostsByUser(Long userId) { User user = this.userRepo.findById(userId).orElseThrow(() -> new ResourceNotFoundException("User", "Id", userId)); List allPostsByUser = this.postRepo.findByUser(user); return extractAllPostDTOs(allPostsByUser); } private List extractAllPostDTOs(List allPostsByCategory) { List allPostDTOByCategory = allPostsByCategory .stream() .map( post -> { UserDTO postUserDTO = this.modelMapper.map(post.getUser(), UserDTO.class); CategoryDTO postCategoryDTO = this.modelMapper.map(post.getCategory(), CategoryDTO.class); PostDTO postDTO = this.modelMapper.map(post, PostDTO.class); postDTO.setUserDTO(postUserDTO); postDTO.setCategoryDTO(postCategoryDTO); return postDTO; }) .collect(Collectors.toList()); return allPostDTOByCategory; }
@gauravvashistha8383
@gauravvashistha8383 2 жыл бұрын
You get any solution of this
@chander10980
@chander10980 Жыл бұрын
@@gauravvashistha8383 Wrong one----posts. stream. map( (post) -> this. modelmapper.map(posts, PostDto. Class)). tolitst (Collectors.toList()) ; Correct one -- posts. stream. map( (x) -> this. modelmapper.map(x, PostDto. Class)). tolitst (Collectors.toList()) ;
@jigarpatel3614
@jigarpatel3614 Жыл бұрын
Nice explanation. thanks a lot for sharing this knowledge with us without any cost.
@sarveshm-rd6zp
@sarveshm-rd6zp Жыл бұрын
Hi sir when i am run postman i am getting output like this please replay me what happend "title": null, "content": null, "imageName": null, "addedDate": null, "category": null, "user": null
@SachinSavita-dv7yj
@SachinSavita-dv7yj Жыл бұрын
me too, what to do now?
@Javed_Khan_.
@Javed_Khan_. Жыл бұрын
@@SachinSavita-dv7yj watch at 15:30
@KashyapSharma0
@KashyapSharma0 11 ай бұрын
@@Javed_Khan_. Thanks
@gauravbansalkec
@gauravbansalkec 2 жыл бұрын
Can't I fetch the list of posts from category object obtained directly rather than calling post repo for it as we have stored all posts of a category in the category model also ???
@shameersharif7680
@shameersharif7680 2 жыл бұрын
Bro you look like a music director in south his name is S.S.Thaman….you look exact😳
@sheetalrai3325
@sheetalrai3325 2 жыл бұрын
I'm getting null for the category and user details while printing all the posts Any help is much appreciated
@travelwithannus
@travelwithannus Жыл бұрын
Same error.... Have you find any solution ?
@s.prabin
@s.prabin Жыл бұрын
@@travelwithannus copy this code @Override public List getAllPostByCategory(Integer cid) { Category cat = this.categoryRepo.findById(cid) .orElseThrow(() -> new ResourceNotFoundException("Category", "Category id", cid)); List posts = this.postRepo.findByCategory(cat); List tempDto = posts.stream().map((post) -> this.modelMapper.map(post, PostDto.class)) .collect(Collectors.toList()); return tempDto; } a small typo leads to that error(i.e. in lambda expression while modelmapping, we have to write lambda expression post instead of List posts)
@vijayrajsingh2348
@vijayrajsingh2348 2 жыл бұрын
Hi Sir, I am getting null values for users and category when I am trying to create Post. public PostDto createPost(PostDto postDto,Integer uid, Integer cid) { Post post = toPost(postDto); // reading remaining data post.setImageName("default.png"); post.setDate(new Date()); // set users User userById = userRepo.findById(uid).orElseThrow(()-> new ResourceNotFoundException("user","id",uid)); post.setUserss(userById); // set category Category categoryById = catRepos.findById(cid).orElseThrow(()->new ResourceNotFoundException("category","id",cid)); post.setCategoryy(categoryById); Post savedPost = repos.save(post); System.out.println("user is====" +savedPost.getUserss().toString()); System.out.println("category is ==>"+ savedPost.getCategoryy().toString()); System.out.println("post is:"+ savedPost); return toPostDto(savedPost); } // conversion of post dto to post entity public Post toPost(PostDto postDto) { Post post = modelMapper.map(postDto, Post.class); return post; } // conversion of post entity to post dto public PostDto toPostDto(Post post) { PostDto postDto = modelMapper.map(post, PostDto.class); return postDto; }
@travelwithannus
@travelwithannus Жыл бұрын
Same error... Have you found any solution ?
@challengefitness-gz9bo
@challengefitness-gz9bo Жыл бұрын
@@travelwithannus hello same problem hvae you find any solution
@s.prabin
@s.prabin Жыл бұрын
@@challengefitness-gz9bo @Override public List getAllPostByCategory(Integer cid) { Category cat = this.categoryRepo.findById(cid) .orElseThrow(() -> new ResourceNotFoundException("Category", "Category id", cid)); List posts = this.postRepo.findByCategory(cat); List tempDto = posts.stream().map((post) -> this.modelMapper.map(post, PostDto.class)) .collect(Collectors.toList()); return tempDto; } copy this code a small typo leads to that problem
@samartajshaikh2601
@samartajshaikh2601 2 жыл бұрын
great practice tutorial
@ManishKumar-zb2qx
@ManishKumar-zb2qx 11 ай бұрын
i did
@vatsalvasoya566
@vatsalvasoya566 2 жыл бұрын
"title": null, "content": null, "imageName": null, "addedDate": null, "category": null, "user": null }, when i created get all posts by user i get these can anyone help......
@s.prabin
@s.prabin Жыл бұрын
@Override public List getAllPostByCategory(Integer cid) { Category cat = this.categoryRepo.findById(cid) .orElseThrow(() -> new ResourceNotFoundException("Category", "Category id", cid)); List posts = this.postRepo.findByCategory(cat); List tempDto = posts.stream().map((post) -> this.modelMapper.map(post, PostDto.class)) .collect(Collectors.toList()); return tempDto; } copy this code
@mrrishiraj88
@mrrishiraj88 2 жыл бұрын
🙏👍
@rahul-sinha
@rahul-sinha 2 жыл бұрын
💥Sir Please *upload this project source-code on your website* -Thanks 🤗💖💞💥
@TheHimanshuSharmaYT
@TheHimanshuSharmaYT 7 ай бұрын
Katakuri
@yashgupta-qn6qg
@yashgupta-qn6qg 2 жыл бұрын
bhai source code bhi do n
@artworkbysomrita2062
@artworkbysomrita2062 Жыл бұрын
After defining these 2 extra methods inside PostsRepositories public interface PostRepositories extends JpaRepository{ List findAllPostsByUser(Users users); List findAllPostsByCategory(Category category); } getting this error: Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2023-05-03T11:24:55.605+05:30 ERROR 17836 --- [ restartedMain] o.s.boot.SpringApplication  : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'postController': Unsatisfied dependency expressed through field 'postServ': Error creating bean with name 'postsServiceImpl': Unsatisfied dependency expressed through field 'postRepo': Error creating bean with name 'postRepositories' defined in com.somrita.blog.repositories.PostRepositories defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract java.util.List com.somrita.blog.repositories.PostRepositories.findAllPostsByUser(com.somrita.blog.models.Users); Reason: Failed to create query for method public abstract java.util.List com.somrita.blog.repositories.PostRepositories.findAllPostsByUser(com.somrita.blog.models.Users); No property 'user' found for type 'Posts' Did you mean ''users'' at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:713) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:693) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:133) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:482) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1416) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:597) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) ~[spring-beans-6.0.8.jar:6.0.8] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917) ~[spring-context-6.0.8.jar:6.
@dhavalhatzade6292
@dhavalhatzade6292 2 жыл бұрын
while creating "findByCategory" method in PostRepo, I'm getting org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'postServiceImpl': Unsatisfied dependency expressed through field 'postRepo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'postRepo' error Can someone help me fix this.
@vijik2988
@vijik2988 2 жыл бұрын
please autowire all services and repository
@sunnysingh7854
@sunnysingh7854 2 жыл бұрын
In the repo Interface, check whether you are giving the correct names for the methods. Hope it helps. List findByUser(User user); List findByCategory(Category category);
@vasuaggarwal9883
@vasuaggarwal9883 11 ай бұрын
in your PostServiceImpl add the service annotation@@sunnysingh7854
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Vite Crash Course | Faster Alternative To CRA
16:24
Traversy Media
Рет қаралды 222 М.
🔥Creating Complete Category API in one video | Backend Course [Hindi]
33:42
Learn Code With Durgesh
Рет қаралды 39 М.
Learn Coding & Get a Job (in 2025) 🔥
16:54
CodeWithHarry
Рет қаралды 662 М.
What is an API ? Simply Explained
5:21
Apna College
Рет қаралды 2,2 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН