### Setup Basic Dependencies Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Starts the necessary services using Docker Compose. Ensure Docker is installed and running. ```shell docker-compose up ``` -------------------------------- ### Start Environment Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Starts the development environment for the Book Shop project. ```shell $ make start ``` -------------------------------- ### Start Docker Environment Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Starts the Docker environment including MySQL and Nacos. This is a prerequisite for running the payment platform. ```shell # root directory make start ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Start the Docker Compose environment for the project services. Use 'make env-stop' to stop them. ```bash make env-start ``` -------------------------------- ### Run Facade Service Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Starts the facade service for the Book Shop project. ```shell $ make facade ``` -------------------------------- ### Run User Service Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Starts the user service for the Book Shop project. ```shell $ make user ``` -------------------------------- ### Run Order Service Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Starts the order service for the Book Shop project. ```shell $ make order ``` -------------------------------- ### Run Item Service Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Starts the item service for the Book Shop project. ```shell $ make item ``` -------------------------------- ### Build and Run GoMall Cart App Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/app/cart/readme.md Execute these shell commands to build the application and then start the bootstrap process. ```shell sh build.sh sh output/bootstrap.sh ``` -------------------------------- ### Start Minikube Tunnel Source: https://github.com/cloudwego/biz-demo/blob/main/bookinfo/README.md Starts the minikube tunnel to assign LoadBalancer IPs to the Istio ingress. This is required for accessing the application via localhost. ```bash minikube tunnel ``` -------------------------------- ### Install OpenTelemetry Operator Source: https://github.com/cloudwego/biz-demo/blob/main/bookinfo/README.md Installs the OpenTelemetry operator using Helm. Ensure cert-manager is not enabled if not required. ```bash helm install --set admissionWebhooks.certManager.enabled=false \ opentelemetry-operator open-telemetry/opentelemetry-operator ``` -------------------------------- ### Start HTTP Gateway Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Starts the HTTP gateway for the Open Payment Platform. This allows external requests to be routed to the payment services. ```shell # root directory make gateway ``` -------------------------------- ### Query Order Gateway Response Example Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Example response from the payment gateway after querying an order. It includes the order status and relevant identifiers. ```json {"err_code":0,"err_message":"ok","nonce_str":"439FJDF98HUFHSUGNFDIUSHF","order_status":0,"sign":"19944bf5576669fcfc08","sign_type":"SM3"} ``` -------------------------------- ### Payment Gateway Response Example Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Example response from the payment gateway after a successful payment request. Indicates the order status and transaction details. ```json {"err_code":0,"err_message":"ok","merchant_id":"OPP9993338844","nonce_str":"439FJDF98HUFHSUGNFDIUSHF","open_id":"","order_status":0,"out_order_no":"111222333","out_transaction_id":"","pay_way":"111222333","sign":"2cadb64844d0b665faf1","sign_type":"SM3","sub_merchant_id":"","sub_openid":""} ``` -------------------------------- ### Close Order Gateway Response Example Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Example response from the payment gateway after closing an order. Confirms the operation was successful. ```json {"err_code":0,"err_message":"ok","nonce_str":"439FJDF98HUFHSUGNFDIUSHF","sign":"2fa66cf2c59cdcd02f4b","sign_type":"SM3"} ``` -------------------------------- ### Deploy Bookinfo Application Source: https://github.com/cloudwego/biz-demo/blob/main/bookinfo/README.md Deploys the Bookinfo application using Helm. This command installs the application workloads defined in the Helm chart. ```bash helm install bookinfo ./manifest/bookinfo/workloads ``` -------------------------------- ### Check Order Status Gateway Response Example Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Example response showing the order status after it has been closed. The order_status field indicates the final state. ```json {"err_code":0,"err_message":"ok","nonce_str":"439FJDF98HUFHSUGNFDIUSHF","order_status":9,"sign":"36f9ac0a04d7c9d8e093","sign_type":"SM3"} ``` -------------------------------- ### Create Note API Response Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Example responses for note creation, indicating success or parameter errors. ```javascript // successful { "code": 0, "message": "Success", "data": null } // failed { "code": 10002, "message": "Wrong Parameter has been given", "data": null } ``` -------------------------------- ### Run a Specific Service Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Run a specific service using 'air' for hot-reloading. Ensure 'air' is installed and replace 'svcName' with the desired service name. ```bash make run svc=`svcName` ``` -------------------------------- ### Register User API Response Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Example responses for user registration, indicating success or if the user already exists. ```javascript // successful { "code": 0, "message": "Success", "data": null } // failed { "code": 10003, "message": "User already exists", "data": null } ``` -------------------------------- ### Login User API Response Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Example responses for user login, showing a successful login with an expiration token or an authorization failure. ```javascript // successful { "code": 0, "expire": "2022-12-3T01:56:46+08:00", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDI1Mjg2MDYsImlkIjoxLCJvcmlnX2lhdCI6MTY0MjUyNTAwNn0.k7Ah9G4Enap9YiDP_rKr5HSzF-fc3cIxwMZAGeOySqU" } // failed { "code": 10004, "message": "Authorization failed", "data": null } ``` -------------------------------- ### Build and Run Note RPC Server Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Navigates to the note service directory, builds the server, and then runs the bootstrap script. ```shell cd cmd/note sh build.sh sh output/bootstrap.sh ``` -------------------------------- ### Build and Run API Server Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Navigates to the API service directory, builds the server, and then runs the bootstrap script. ```shell cd cmd/api sh build.sh sh output/bootstrap.sh ``` -------------------------------- ### Build and Run User RPC Server Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Navigates to the user service directory, builds the server, and then runs the bootstrap script. ```shell cd cmd/user sh build.sh sh output/bootstrap.sh ``` -------------------------------- ### Download Go Modules Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Download all necessary Go modules for the project. ```bash make tidy ``` -------------------------------- ### Run Make Targets Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Execute the default 'make' targets for the project. ```bash make ``` -------------------------------- ### Initialize Environment Variables Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Initialize the .env file for the project. A SESSION_SECRET random value must be generated and provided. ```bash make init ``` -------------------------------- ### Perform User Registration via API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Executes the main Go program to send a registration request. Ensure you are in the 'api_request' directory. ```shell cd api_request go run main.go -action register ``` -------------------------------- ### Query Note API Response Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Example responses for note querying, showing successful retrieval of notes or parameter errors. ```javascript // successful { "code": 0, "message": "Success", "data": { "notes": [ { "note_id": 1, "user_id": 1, "username": "lorain", "user_avatar": "test", "title": "test title", "content": "test content", "create_time": 1642525063 } ], "total": 1 } } // failed { "code":10002, "message":"Wrong Parameter has been given", "data":null } ``` -------------------------------- ### Expose Bookinfo with Istio Ingress Gateway Source: https://github.com/cloudwego/biz-demo/blob/main/bookinfo/README.md Applies the Istio gateway configuration to expose the Bookinfo application. This step is necessary for external access. ```bash kubectl apply -f bookinfo/manifest/bookinfo/traffic/bookinfo-gateway.yaml ``` -------------------------------- ### Create Note via API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Executes the main Go program to send a create note request. Ensure you are in the 'api_request' directory. ```shell cd api_request go run main.go -action createNote ``` -------------------------------- ### Update Note API Response Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Example responses for note updating, showing success or errors related to note ID parsing. ```javascript // successful { "code": 0, "message": "Success", "data": null } // failed { "code":10001, "message":"strconv.ParseInt: parsing \"$note_id\": invalid syntax", "data":null } ``` -------------------------------- ### Perform User Login via API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Executes the main Go program to send a login request. Ensure you are in the 'api_request' directory. ```shell cd api_request go run main.go -action login ``` -------------------------------- ### Query Note via API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Executes the main Go program to send a query note request. Ensure you are in the 'api_request' directory. ```shell cd api_request go run main.go -action queryNote ``` -------------------------------- ### Open Gomall Website Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Open the Gomall website in the default browser. ```bash make open-gomall ``` -------------------------------- ### Profile Heap Usage Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Uses pprof to profile heap memory usage of the facade service. Access the web UI via the specified port. ```shell $ go tool pprof -http=:1234 http://localhost:8080/debug/pprof/heap ``` -------------------------------- ### Register User Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Registers a new user with the provided username and password. ```APIDOC ## POST /v1/user/register ### Description Registers a new user with the provided username and password. ### Method POST ### Endpoint /v1/user/register ### Parameters #### Request Body - **username** (string) - Required - The username for the new account. - **password** (string) - Required - The password for the new account. ### Request Example ```json { "username":"lorain", "password":"123456" } ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **message** (string) - "Success". - **data** (null) - No data returned on success. #### Failed Response (e.g., 10003) - **code** (integer) - Error code. - **message** (string) - "User already exists". - **data** (null) - No data returned on failure. ``` -------------------------------- ### Clone Gomall Repository Source: https://github.com/cloudwego/biz-demo/blob/main/gomall/README.md Clone the Gomall project from its repository. ```bash git clone ... ``` -------------------------------- ### Stop Environment Source: https://github.com/cloudwego/biz-demo/blob/main/book-shop/README.md Stops the development environment for the Book Shop project. ```shell $ make stop ``` -------------------------------- ### Request Payment via Gateway Source: https://github.com/cloudwego/biz-demo/blob/main/open-payment-platform/README.md Sends a POST request to the gateway to initiate a payment using the qrpay method. Includes details like merchant ID, amount, and authorization code. ```shell curl --location --request POST 'http://127.0.0.1/gateway/payment' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'method=qrpay' \ --data-urlencode 'merchant_id=OPP9993338844' \ --data-urlencode 'sign=DJJDO304GMGMK459GGNGNHNLLD' \ --data-urlencode 'sign_type=SM3' \ --data-urlencode 'biz_params={"out_order_no":"111222333","total_amount":"618","subject":"咖啡一杯","merchant_id":"OPP9993338844","auth_code":"34943985845935459"}' \ --data-urlencode 'nonce_str=439FJDF98HUFHSUGNFDIUSHF' ``` -------------------------------- ### Create Note Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Creates a new note with a specified title and content. Requires authentication. ```APIDOC ## POST /v1/note ### Description Creates a new note with a specified title and content. Requires authentication. ### Method POST ### Endpoint /v1/note ### Parameters #### Request Body - **title** (string) - Required - The title of the note. - **content** (string) - Required - The content of the note. ### Request Example ```json { "title":"test title", "content":"test content" } ``` ### Response #### Success Response (200) - **code** (integer) - 0 for success. - **message** (string) - "Success". - **data** (null) - No data returned on success. #### Failed Response (e.g., 10002) - **code** (integer) - Error code. - **message** (string) - "Wrong Parameter has been given". - **data** (null) - No data returned on failure. ``` -------------------------------- ### Register User API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/api.md Use this cURL command to register a new user with a username and password. ```shell curl --location --request POST '127.0.0.1:8080/v1/user/register' \ --header 'Content-Type: application/json' \ --data-raw '{ "username":"lorain", "password":"123456" }' ``` -------------------------------- ### Request Bookinfo API Source: https://github.com/cloudwego/biz-demo/blob/main/bookinfo/README.md Makes a curl request to the Bookinfo API to verify the deployment. A successful response indicates the application is running correctly. ```bash curl http://localhost/api/v1/products/1 ``` -------------------------------- ### Update Note via API Request Source: https://github.com/cloudwego/biz-demo/blob/main/easy_note/README.md Executes the main Go program to send an update note request. Ensure you are in the 'api_request' directory. ```shell cd api_request go run main.go -action updateNote ```