例外の修正および、テーブル設計の記述追加
authorOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sat, 13 Apr 2019 13:32:02 +0000 (22:32 +0900)
committerOHASHI, Norikazu <katz@neko-mori.sakura.ne.jp>
Sat, 13 Apr 2019 13:32:02 +0000 (22:32 +0900)
.gitignore [new file with mode: 0644]
readme.md
sinatra/app/controllers/web_gui.rb
sinatra/app/models/users_db.rb

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..47b948f
--- /dev/null
@@ -0,0 +1,3 @@
+/.yardoc/
+/doc/
+.markdown-preview.html
index d28c8e5..c0d9691 100644 (file)
--- a/readme.md
+++ b/readme.md
         database.yml       # dtabase config
         users_db.rb        # access to users table
         books_db.rb        # access to book table
-      views/
-        layout.erb         # layout of html view
-        main.erb           # start up view
-        signup.erb         # sign up user view
-        login.erb          # user login view
-        logout.erb         # user logout view
-        user_home.erb      # user default home view
-        account.erb        # setup account view
-        list.erb           # list of books view
-        search.erb         # search books view
-        detail.erb         # detail of book parameter view
-        find_isbn.erb      # search books parameter with isbn view
-        setup.erb          # setup book parameter view
+      views/               # views
+        layout.haml        # layout of html view
+        main.haml          # start up view
+        signup.haml        # sign up user view
+        login.haml         # user login view
+        logout.haml        # user logout view
+        user_home.haml     # user default home view
+        account.haml       # setup account view
+        list.haml          # list of books view
+        search.haml        # search books view
+        detail.haml        # detail of book parameter view
+        find_isbn.haml     # search books parameter with isbn view
+        setup.haml         # setup book parameter view
 ```
 
+## テーブル設計
+
+### ユーザ管理テーブル (users)
+
+| 項番 | カラム名 | 型 | 属性 | 概要 |
+| --: | --- | --- | --- | --- |
+| 1 | user_id | INTEGER | NOT NULL, AUTO_INCREMENT, PRIMARY KEY | ユーザID |
+| 2 | user_name | VARCHAR(10) | NOT NULL, UNIQUE | ユーザ名  |
+| 3 | full_name | VARCHAR(127) | | ユーザフルネーム |
+| 4 | passwd_hash | VARCHA(60) | NOT NULL | パスワードハッシュ |
+| 5 | passwd_salt | VARCHA(60) | NOT NULL | パスワードSALT |
+| 6 | email | VARCHAR(127) | NOT NULL | Eメールアドレス |
+| 7 | role | INTEGER | NOT NULL | 権限 |
+| 8 | create_at | DATETIME | NOT NULL | 登録日時 |
+| 9 | update_at | DATETIME | NOT NULL | 更新日時 |
+
+### 書籍管理テーブル (books)
+
+| 項番 | カラム名 | 型 | 属性 | 概要 |
+| --: | --- | --- | --- | --- |
+|  1 | isbn | VARCHAR(14) | NOT NULL | ISBNコード |
+|  2 | title | VARCHAR(255) | NOT NULL | 書名 |
+|  3 | volume | INTEGER | | 巻数 | 
+|  4 | author | VARCHAR(127) | | 著者名 |
+|  5 | orignal_author | VARCHAR(127) | | 原著者 |
+|  6 | translator | VARCHAR(127) | | 翻訳者 |
+|  7 | publisher | VARCHAR(127) | | 出版社 |
+|  8 | summary | VARCHAR(511) | | 概要 |
+|  9 | book_shadow | BLOB | | 書影 |
+| 10 | user_id | INTEGER | NOT NULL | ユーザID |
+| 11 | rank | INTEGER | | 評価
+| 12 | creat_at | DATETIME | NOT NULL | 登録日時 |
+| 13 | update_at | DATETIME | NOT NULL | 更新日時 |
+
+注: isdn + user_id で複合キーとする。
index fadc6a3..f170ec9 100644 (file)
@@ -92,7 +92,7 @@ class WebGui < Sinatra::Base
       id = UserAccount.checkPasswd(name, passwd);
       session[:userId] = id;
       redirect "/user_home"
-    rescue UserAccount::NotfondInstanceError,
+    rescue UserAccount::NotfoundInstanceError,
            UserAccount::AuthenticationError
       raise WebError.new(401),
             "認証に失敗しました アカウント、 パスワードを確認してください。"
index 784116e..0a997ed 100644 (file)
@@ -19,19 +19,19 @@ end
 class UserAccount
 
   # ユーザロール
-  ROLE_AUTH = 0    #管理者権限
+  ROLE_ADMIN  = 0  #管理者権限
   ROLE_NORMAL = 8  #一般権限
   
-  # 認証エラー
+  # ユーザ認証エラー
   class AuthenticationError < SecurityError
   end
 
-  # すでに存在している
+  # 対象のユーザがすでに存在している
   class AlreadyInstanceError < StandardError
   end
 
-  # 存在していない
-  class NotfondInstanceError < StandardError
+  # å¯¾è±¡ã\81®ã\83¦ã\83¼ã\82¶ã\81\8cå­\98å\9c¨ã\81\97ã\81¦ã\81\84ã\81ªã\81\84
+  class NotFoundInstanceError < StandardError
   end
 
   # DBアクセス失敗
@@ -78,14 +78,14 @@ class UserAccount
   # @param [String] name ユーザ名
   # @param [String] passwd パスワード
   # @return [Integer] 認証されたユーザID
-  # @raise [NotfoundInstanceError] ユーザ情報の取得に失敗
-  # @raise [AutenticationError] 認証失敗
+  # @raise [NotFoundInstanceError] ユーザ情報の取得に失敗
+  # @raise [AuthenticationError] 認証失敗
   def self.checkPasswd(name, passwd)
     user = User.find_by(user_name: name)
 
     # ユーザの有無をチェック
     if (user == nil)
-      raise NotfondInstanceError
+      raise NotFoundInstanceError
     end
 
     # パスワードハッシュを取得
@@ -102,11 +102,11 @@ class UserAccount
   # ユーザ情報取得
   # @param [Integer] id 対象ユーザID
   # @return [User] ユーザ情報
-  # @raise [NotfoundInstanceError] ユーザ情報の取得に失敗
+  # @raise [NotFoundInstanceError] ユーザ情報の取得に失敗
   def self.getUser(id)
     user = User.find_by(user_id: id)
     if (user == nil)
-      raise NotfondInstanceError
+      raise NotFoundInstanceError
     end
     return user
   end