isbn VARCHAR(14) NOT NULL,
user_id INTEGER NOT NULL,
summary TEXT,
- rank INTEGER,
+ book_rank INTEGER,
create_at DATETIME NOT NULL,
- update_at DATETIME NOT NULL
+ update_at DATETIME NOT NULL,
PRIMARY KEY(isbn, user_id));
CREATE TABLE book_covers (
# @post_param cover_file [Hash] イメージファイル情報
# @post_param cover_base64 [String] イメージ情報(Base64)
# @post_param summary [String] 蔵書概要
- # @post_param rank [Integer] 蔵書評価(0-5)
+ # @post_param book_rank [Integer] 蔵書評価(0-5)
# @raise [WebError] セッションの期限切れ
# @raise [WebError] 蔵書情報編集失敗
post '/book_regist' do
params.each do |key, value|
case key
- when :sammary, :rank, :cover_base64, :cover_file
+ when :sammary, :book_rank, :cover_base64, :cover_file
# 対象キーは書籍情報ではないので飛す
next
end
end
# 蔵書情報の更新
- BookManager.createBookCollect(isbn, id, params[:summary], params[:rank])
+ BookManager.createBookCollect(isbn, id, params[:summary], params[:book_rank])
rescue BookManager::NotFoundInstanceError,
BookManager::AlreadyInstanceError
# @raise [WebError] セッションの期限切れ
# @raise [WebError] 登録済みの蔵書だった。
post '/book_search_isbn' do
+ id = session[:userId]
if (id == nil)
raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
end
# @post_param [Hash] cover_file イメージファイル情報
# @raise [WebError] セッションの期限切れ
post '/book_upload_cover' do
+ id = session[:userId]
if (id == nil)
raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
end
end
goPage :book_regist
end
-
+
+ # 書影の表示
+ get '/book_image/:hash' do
+ image_hash = params[:hash]
+ book_cover = BookManager.getBookCover(image_hash)
+
+ status 200
+ headers \
+ "Content-Type" => "image/jpeg",
+ "Last-Modified" => book_cover.create_at.httpdate
+ body book_cover.cover
+
+ end
+
+ get '/book_info/:isbn' do
+ id = session[:userId]
+ isbn = params[:isbn]
+ if (id == nil)
+ raise WebError.new(status: 408, message: "セッション期限切れです。再ログインをしてください。")
+ end
+
+ begin
+ @book_info = BookManager.getBookCollect(isbn, id)
+ rescue BookManager::NotFoundInstanceError
+ raise WebError.new(status: 404, message: "", refs: "/user_home")
+ end
+ goPage :book_info
+ end
# ログアウトページ
get '/logout' do
# 最終ログイン情報登録
# @param [String] isbn 登録するISBN
# @param [Integer] user_id 登録対象のユーザID
# @param [String] summary ユーザ毎の紹介分
- # @param [Integer] rank ユーザの評価
+ # @param [Integer] book_rank ユーザの評価
# @return [BookCollection] 蔵書情報
- def createBookCollect(isbn, user_id, summary, rank)
+ def createBookCollect(isbn, user_id, summary, book_rank)
if (BookCollection.find_by(isbn: isbn, user_id: user_id) != nil)
raise NotFoundInstanceError
end
book_collect.isbn = isbn
book_collect.user_id = user_id
book_collect.summary = summary
- book_collect.rank = rank
+ book_collect.book_rank = book_rank
book_collect.create_at = DateTime.now
book_collect.update_at = DateTime.now
if (not book_collect.save)
--- /dev/null
+- # encoding: utf-8
+- admin_f = @admin_f
+- id = @id
+- book_info = @book_info
+
+%h2
+ #{book_info[:title]}
+
+ %image{:border => '1', :src => book_info[:cover_uri], :width => '256', :height => '364'}
+
+.book_table
+ %table
+ %tr
+ %th
+ ISBN
+ %td
+ #{book_info[:isbn]}
+ %tr
+ %th
+ 書名
+ %td
+ #{book_info[:title]}
+ - if book_info [:value] != nil
+ : #{book_info[:value]} 巻
+ - if book_info[:series] != nil
+ %tr
+ %th
+ 単行本シリーズ
+ %td
+ #{book_info[:series]}
+ - if book_info[:author] != nil
+ %tr
+ %th
+ 著者
+ %td
+ #{book_info[:author]}
+ - if book_info[:orignal_author] != nil
+ %tr
+ %th
+ 原作者
+ %td
+ #{book_info[:orignal_author]}
+ - if book_info[:illustrator]
+ %tr
+ %th
+ 作画
+ %td
+ #{book_info[:illustrator]}
+ - if book_info[:translator] != nil
+ %tr
+ %th
+ 翻訳
+ %td
+ #{book_info[:translator]}
+ - if book_info[:supervisor] != nil
+ %tr
+ %th
+ 監修
+ %td
+ #{book_info[:supervisor]}
+ - if book_info[:publisher] != nil
+ %tr
+ %th
+ 出版社
+ %td
+ #{book_info[:publisher]}
+ - if book_info[:pubdate] != nil
+ %tr
+ %th
+ 出版日
+ %td
+ #{book_info[:pubdate]}
+ - if book_info[:summary] != nil
+ %tr
+ %th
+ 書籍概要
+ %td
+ %pre
+ #{book_info[:summary]}
+ - if book_info[:book_rank] != nil
+ %tr
+ %th
+ 評価
+ %td
+ - case book_info[:book_rank]
+ - when 0 then
+ .rank
+ ☆ ☆ ☆ ☆ ☆
+ - when 1 then
+ .rank
+ ★ ☆ ☆ ☆ ☆
+ - when 2 then
+ .rank
+ ★ ★ ☆ ☆ ☆
+ - when 3 then
+ .rank
+ ★ ★ ★ ☆ ☆
+ - when 4 then
+ .rank
+ ★ ★ ★ ★ ☆
+ - when 5 then
+ .rank
+ ★ ★ ★ ★ ★
#{book_info[:summary]}
.item
- %label{ :for => 'rank' }
+ %label{ :for => 'book_rank' }
%span
評価:
- %input{:name => 'rank', :type => 'text', :id => 'rank', :value => book_info[:rank], :pattern => '[0-5]'}
+ %input{:name => 'book_rank', :type => 'text', :id => 'book_rank', :value => book_info[:book_rank], :pattern => '[0-5]'}
.buttons
%hr