16. Product Creation
Contents
We can create products related to a specific merchant type user.
Update product.xml
Copy and paste the following content into ProductMapper.java under the service/src/resources/mapper directory:
|
|
Update UserService
Replace the original content with the following one in the UserService.java file under the service/src/main/java/co.dongchen.shop/service directory:
|
|
Update ProductService
Replace the original content with the following one in the ProductService.java file under the service/src/main/java/co.dongchen.shop/service directory:
|
|
Update ProductController
Replace the original content with the following one in the ProductController.java file under the controller/src/main/java/co.dongchen.shop/controller directory:
|
|
Create Add Product Template
- Right click controller/src/main/resources/templates/product directory: New > File
- Fill in “add.ftl”
- Press Enter key to continue
Copy and paste the following content into add.ftl:
|
|
Create Merchant Product Template
- Right click controller/src/main/resources/templates/product directory: New > File
- Fill in “merchant_product.ftl”
- Press Enter key to continue
Copy and paste the following content into merchant_product.ftl:
|
|
Verify
Run the App
|
|
Choose the correspondent option and press enter.
View Add Product Page in the Browser
|
|
- Fill in the Information:
- Click the “Merchant” dropdown select menu, select the second user:
- Click on “Add” button and it should redirect us to Merchant’s Product page:
Author Dong Chen
LastMod Thu May 9 2019