spring-ecommerce-tutorial icon indicating copy to clipboard operation
spring-ecommerce-tutorial copied to clipboard

Some questions so far

Open edwardzjl opened this issue 6 years ago • 2 comments

  1. CategoryService#addNewCategoryInMysql use @RequestParam annotation, creates a new CategoryEntity using the params and then save it to db, while CategoryService#addNewCategoryInMongoDB use @RequestBody annotation, call save on the param Category, is there any difference?

  2. SellerService#addNewSellerInMongoDB and SellerService#addNewSellerInMysql also use @RequestBody annotation, but they create and save a new Seller(or SellerEntity) instance, what's the difference compared to just call save on the param Seller(or SellerEntity)?

  3. in SellerService#updateSellerInMongoDB, you retrieve the sellerInDatabase after it's updated successfully

if (updateResult.getModifiedCount() == 1)
        {
            sellerInDatabase = _sellerMongoRepository.findById(seller.getId()).orElseThrow(EntityNotFoundException::new);
            // ...
        }

I think it should be same as before it's updated(the first line in try block)?

Again, thanks for the great tutorial!

edwardzjl avatar Jun 27 '19 07:06 edwardzjl

Hi Zunlin, I'm happy you've found it helpful. Thank you for the comments. I'll revise it.

Best, Leila

On Thu, Jun 27, 2019 at 12:25 AM Junlin Zhou [email protected] wrote:

CategoryService#addNewCategoryInMysql use @RequestParam annotation, creates a new CategoryEntity using the params and then save it to db, while CategoryService#addNewCategoryInMongoDB use @requestbody https://github.com/requestbody annotation, call save on the param Category, is there any difference? 2.

SellerService#addNewSellerInMongoDB and SellerService#addNewSellerInMysql also use @requestbody https://github.com/requestbody annotation, but they create and save a new Seller(or SellerEntity) instance, what's the difference compared to just call save on the param Seller(or SellerEntity)? 3.

in SellerService#updateSellerInMongoDB, you retrieve the sellerInDatabase after it's updated successfully

if (updateResult.getModifiedCount() == 1) { sellerInDatabase = _sellerMongoRepository.findById(seller.getId()).orElseThrow(EntityNotFoundException::new); // ... }

I think it should be same as before it's updated(the first line in try block)?

Again, thanks for the great tutorial!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lmirzaei/spring-ecommerce-tutorial/issues/2?email_source=notifications&email_token=AKAHOZS6K543HH2QFBCOZOTP4RTN7A5CNFSM4H3Y7GY2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G372SGQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AKAHOZUXTJXRKR67O3HC7ULP4RTN7ANCNFSM4H3Y7GYQ .

-- Best Regards, Leila Mirzaei

lmirzaei avatar Jun 27 '19 16:06 lmirzaei

Hi Zunlin, I'm happy you've found it helpful. Thank you for the comments. I'll revise it. Best, Leila On Thu, Jun 27, 2019 at 12:25 AM Junlin Zhou @.***> wrote: 1. CategoryService#addNewCategoryInMysql use @RequestParam annotation, creates a new CategoryEntity using the params and then save it to db, while CategoryService#addNewCategoryInMongoDB use @requestbody https://github.com/requestbody annotation, call save on the param Category, is there any difference? 2. SellerService#addNewSellerInMongoDB and SellerService#addNewSellerInMysql also use @requestbody https://github.com/requestbody annotation, but they create and save a new Seller(or SellerEntity) instance, what's the difference compared to just call save on the param Seller(or SellerEntity)? 3. in SellerService#updateSellerInMongoDB, you retrieve the sellerInDatabase after it's updated successfully if (updateResult.getModifiedCount() == 1) { sellerInDatabase = _sellerMongoRepository.findById(seller.getId()).orElseThrow(EntityNotFoundException::new); // ... } I think it should be same as before it's updated(the first line in try block)? Again, thanks for the great tutorial! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#2?email_source=notifications&email_token=AKAHOZS6K543HH2QFBCOZOTP4RTN7A5CNFSM4H3Y7GY2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G372SGQ>, or mute the thread https://github.com/notifications/unsubscribe-auth/AKAHOZUXTJXRKR67O3HC7ULP4RTN7ANCNFSM4H3Y7GYQ . -- Best Regards, Leila Mirzaei

I figured out the third question :D

edwardzjl avatar Jun 28 '19 06:06 edwardzjl