aaronangxz / carouhell Goto Github PK
View Code? Open in Web Editor NEWAY21/22 NUS TIC2601 Web App Project
Home Page: https://carouhell-sg.herokuapp.com
AY21/22 NUS TIC2601 Web App Project
Home Page: https://carouhell-sg.herokuapp.com
Might need to add listing_mtime
to store updated time when update_single_listing
is called
ItemPamentInfo
should be ItemPaymentInfo
type GetLatestListingsResponse struct {
ItemID uint32
ItemName string
ItemPrice uint32
ItemQuantity uint32
ItemPurchasedQuantity uint32
ItemDescription string
ItemShippingInfo uint32
ItemPamentInfo uint32
ItemLocation string
ItemStatus uint32
ItemCategory uint32
ItemImage string
SellerID uint32
ListingCtime uint32
}
test
into master
(#50)master
locallySQL query seems to be ok, to investigate
No. | Description | Type | Status | Remarks |
---|---|---|---|---|
No. | API name | Type | Status | Remarks |
---|---|---|---|---|
1 | /get_single_listing_by_itemid | POST | ✅ | |
2 | /update_single_listing | PATCH | ✅ | |
3 | /delete_single_listing | DELETE | ✅ | |
4 | /get_listing_reactions | POST | ✅ | |
5 | /add_listing_likes | POST | ✅ | |
6 | /purchase_single_item | POST | ✅ |
To include validations for these 2 fields
Currently, we are implementing static SQLite for ease of debugging. However, to fully utilize all the SQL features and scalability MySQL is needed.
To assess feasibility:
Plan 1: Integrate into the same docker container.
Plan 2: Deploy a separate MySQL container.
Progess:
Use Case
Request
user_id
Response
type GetUserWalletResponse struct {
WalletID *uint32 `json:"wallet_id"`
UserID *uint32 `json:"user_id"`
WalletBalance *uint32 `json:"wallet_balance"`
WalletStatus *uint32 `json:"wallet_status"`
LastTopUp *int64 `json:"last_topup"`
LastUsed *int64 `json:"last_used"`
}
DB
SELECT * FROM wallet_tab WHERE user_id = ?
Update:
get_user_details
= get_user_listings
+ get_user_ratings
Use Case
Request
user_id
Response
type GetUserListingsResponse struct {
LItemID uint32 `json:"item_id"`
ItemName string `json:"item_name"`
ItemPrice uint32 `json:"item_price"`
ItemQuantity uint32 `json:"item_quantity"`
ItemPurchasedQuantity uint32 `json:"item_purchasedquantity"`
ItemDescription string `json:"item_description"`
ItemLocation uint32 `json:"item_location"`
ItemStatus uint32 `json:"item_status"`
ItemCategory uint32 `json:"item_category"`
ItemImage string `json:"item_image"`
LSellerID uint32 `json:"seller_id"`
SellerName string `json:"seller_name"`
ListingCtime int64 `json:"listing_ctime"`
ListingMtime int64 `json:"listing_mtime"`
ListingLikes uint32 `json:"listing_likes"`
}
type UserReview struct {
RVUserID *uint32 `json:"user_id"`
RVSellerID *uint32 `json:"seller_id"`
Ratings *uint32 `json:"ratings"`
ReviewText *string `json:"review_text"`
Ctime *int64 `json:"ctime"`
}
type GetUserDetailsResponse struct {
AUserID uint32 `json:"user_id"`
UserName string `json:"user_name"`
UserEmail string `json:"user_email"`
UserCtime int64 `json:"user_ctime"`
UserStatus uint32 `json:"user_status"`
UserImage string `json:"user_image"`
UserLastLogin int64 `json:"user_last_login"`
ReviewCount uint32 `json:"review_count"`
UserReviews []UserReview `json:"user_review"`
ListingCount uint32 `json:"listing_count"`
UserListings []GetUserListingsResponse `json:"user_listings"`
}
DB
Find reviews left for user_id
and the reviewer's information
Find listings posted by user_id
//IF EXISTS user_id
//SELECT * FROM listing_tab WHERE seller_id = user_id
//SELECT * FROM user_review_tab WHERE rv_seller_id = user_id
r.GET("/get_latest_listings", listings.GetLatestListings)
No. | Description | Type | Status | Remarks |
---|---|---|---|---|
1 | Display listings | API call | 🛠️ | |
2 | Create listings | API call | 🛠️ |
No. | API name | Type | Status | Remarks |
---|---|---|---|---|
1 | /create_listing | POST | ✅ | |
2 | /get_all_listings | GET | ✅ | |
3 | /get_latest_listings | POST | ✅ | |
4 | /get_listings_using_filters | POST | ✅ |
latest_listing
with expiry time of 60 secsInvalidation: Delete key when there is any write to listing_tab
<API name>:<item_id>
with expiry time of 60 secsInvalidation: Delete key when there is any write to this item_id
API | KEY | Expiry |
---|---|---|
get_single_listing_by_itemid | get_single_listing_by_itemid:<item_id> | 60s |
get_user_wallet_details | get_user_wallet_details:<user_id> | 60s |
Use Case
Request
user_id
Response
//everything from acc_tab
//compute and return listing count?
DB
SELECT * FROM acc_tab WHERE user_id = ?
SELECT COUNT(*) FROM listing_tab WHERE user_id = ?
Use Case
Request
user_id
Response
//listing struct
DB
user_id
item_id
reaction_type // 0 = like, 1 = comment
comment //null if reaction_type = 0
ctime
Find a list of item_id
which is reaction_type = 0
, join listing_tab
to get listing details
SELECT * FROM listing_tab l WHERE l.item_id IN
(SELECT r.item_id FROM reaction_tab r
WHERE r.user_id = ? AND r.reaction_type = 0
ORDER BY r.ctime DESC)
Get the latest listings according to category / status (optional)
{
"item_category":"",
"item_status":"",
"listing_time":"",
"limit":
}
Update Request params to align with current listing_tab schema
Due to params validations not being handled properly.
test
into master
( #72 )master
locallyIssue | Description | Type | Status |
---|---|---|---|
#40 | [FEATURE#5] Add structs and Getters according to DB schema | Core Feature | WIP |
#70 | [API#4] GetListingUsingFilters | API | OK |
#74 | [API#4] GetListingUsingFilters - Adding New Filters | Core Feature | OK |
#77 | [FEATURE#13] UpdateSingleListing BugFix | Bug Fix | OK |
#76 | [FEATURE#14] GetListingsUsingFilters crashes when search_keyword / sort_flag is empty | Bug Fix | OK |
We can decide the different queries needed for each feature, according to those in the Google Sheet.
Currently, all validations are being done in the main function, making the code very long.
TODO: Modularize into smaller sub-functions to improve readability.
test
into master
(#84 )master
locallytest
into master
(#61 )master
locallyFlow:
FE encode into base64 -> Pass via create_voucher -> BE decode into jpg -> store -> generate jpg URL string
Temp Data fix:
Modify all existing jpeg records to jpg
Currently, we are returning seller_id
in our listing object:
type Listing struct {
ItemID *uint32 `json:"item_id" gorm:"primary_key"`
ItemName *string `json:"item_name"`
ItemPrice *uint32 `json:"item_price"`
ItemQuantity *uint32 `json:"item_quantity"`
ItemPurchasedQuantity *uint32 `json:"item_purchasedquantity"`
ItemDescription *string `json:"item_description"`
ItemShippingInfo *uint32 `json:"item_shippinginfo"`
ItemPaymentInfo *uint32 `json:"item_paymentinfo"`
ItemLocation *string `json:"item_location"`
ItemStatus *uint32 `json:"item_status"`
ItemCategory *uint32 `json:"item_category"`
ItemImage *string `json:"item_image"`
SellerID *uint32 `json:"seller_id"`
ListingCtime *int64 `json:"listing_ctime"`
ListingMtime *int64 `json:"listing_mtime"`
ListingLikes *uint32 `json:"listing_likes"`
}
However, this is not helpful when we want to display the seller's name on FE.
We will need a query to join listing_tab
and acc_tab
to retrieve user_name
Affected:
All APIs returning listing
Add request and response struct:
Request:
item_id
user_id
purchase_quantity
Flow:
update listing_tab.quantity -1. If == 0, set status = soldout (use TRIGGER?)
insert row in listing_transaction_tab
insert row in wallet_transaction_tab
Validations:
Check buyer exists
Check listing exists
Check item status, quantity > 0
check wallet status, balance
Use Case
Request
item_id
Response
//array of comments
//count of likes
DB
CREATE TABLE `listing_reactions_tab` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(10) unsigned NOT NULL,
`item_id` int(10) unsigned NOT NULL,
`reaction_type` tinyint(1) unsigned NOT NULL DEFAULT '0',
`comment` varchar(256) DEFAULT NULL,
`ctime` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB;
Find item_id
and return all
SELECT * FROM reaction_tab WHERE item_id = ?
Get the most popular (most likes) listings according to category / status (optional)
{
"item_category":"",
"item_status":"",
"limit":
}
Issue | Description | Type |
---|---|---|
#32 | [BUG#2] Header URL redirects to /index.html | Bug |
#31 | [DATABASE#1] Update Request and Response Structs to uint32 | Enhancement |
#34 | [API#2] Add structs and methods for GetLatestListings | New Feature |
test
into master
(#33)master
locallyTo finalize the DB schema for all DB tables.
No. | Table name | Priority | Status |
---|---|---|---|
1 | User | Very High | |
2 | Listing | Very High | |
3 | Listing_transactions | High | |
4 | Interactions | Low | |
5 | Wallet | Normal | |
6 | Wallet_transactions | Normal |
test
into master
(#44)master
locallyMirror the whole tic2601_db
as tic2601_test_db
for mock data and testing purposes.
Changes when switching between test
and live
:
DB Startup
Live: username:password@tcp(tic2601-db)/tic2601_db
Test: username:password@tcp(tic2601-db)/tic2601_test_db
.env
Add LIVE
credentials
API_SECRET=98hbun98h
DB_HOST=127.0.0.1
DB_DRIVER=mysql
DB_USER=username
DB_PASSWORD=password
DB_NAME=tic2601_db
DB_PORT=3306
SQL Queries
SELECT * FROM tic2601_test_db.listing_tab
SELECT * FROM tic2601_db.listing_tab
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.