lims
1.0.0
lims 是圖書館資訊管理系統的縮寫,包含管理現實世界圖書館功能的所有功能。包含4個表用於管理不同的數據
CREATE TABLE Book (
" book_id " varchar ( 1200 ) PRIMARY KEY ,
" isbn " varchar ( 1200 ) NOT NULL ,
" title " varchar ( 1200 ) NOT NULL ,
" subtitle " text ,
" author " varchar ( 1200 ) NOT NULL ,
" published " varchar ( 1200 ) NOT NULL ,
" publisher " varchar ( 1200 ) NOT NULL ,
" pages " int ,
" description " text ,
" image_url " varchar ( 1200 ),
" reviews " int ,
" rating " float
);
CREATE TABLE RegUser (
" user_id " varchar ( 200 ) PRIMARY KEY ,
" first_name " varchar ( 200 ) NOT NULL ,
" last_name " varchar ( 200 ),
" gender " varchar ( 200 ) NOT NULL ,
" email " varchar ( 200 ) UNIQUE NOT NULL ,
" password " varchar ( 200 ) NOT NULL ,
" is_admin " boolean NOT NULL
);
CREATE TABLE Review
(
" review_id " varchar ( 200 ) PRIMARY KEY ,
" user_id " varchar ( 200 ) NOT NULL ,
" book_id " varchar ( 200 ) NOT NULL ,
" comment " text ,
" rating " int ,
" date " varchar ( 200 ),
" edited " boolean
);
CREATE TABLE BookIssue
(
" issue_id " varchar ( 200 ) PRIMARY KEY ,
" user_id " varchar ( 200 ) NOT NULL ,
" book_id " varchar ( 200 ) NOT NULL ,
" issue_date " varchar ( 200 ),
" return_date " varchar ( 200 ),
" returned " boolean
);
ALTER TABLE Review ADD FOREIGN KEY ( " user_id " ) REFERENCES RegUser ( " user_id " );
ALTER TABLE Review ADD FOREIGN KEY ( " book_id " ) REFERENCES Book ( " book_id " );
ALTER TABLE BookIssue ADD FOREIGN KEY ( " user_id " ) REFERENCES RegUser ( " user_id " );
ALTER TABLE BookIssue ADD FOREIGN KEY ( " book_id " ) REFERENCES Book ( " book_id " );
很少有基本功能已經實現,其他功能可以實現或可以在此基礎上建構。所有實現的功能包括
GetBookById
AddBook
DeleteBook
SearchBook
GetReviewsOfBook
IssueBook
GetIssueById
GetBooksIssuedByUser
Connect
AddEditDeleteReview
AddAndDeleteUser
SearchUser
main.go
中呼叫的db/db.go
的Connect()
方法用於連接到本地或雲端資料庫並實例化一個全域變數Lib
外部使用者可以使用該變數根據可用功能與資料庫實例進行互動。
在db
內部,這些檔案包含直接與資料庫互動的程式碼,而資料庫又提供了上述方法。任何新方法和測試都應添加到此處。