API login/logout with http header token
This commit is contained in:
@@ -1,28 +1,35 @@
|
||||
class Api::Restaurant::MenuController < Api::ApiController
|
||||
before :authenticate_token
|
||||
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
menu_detail()
|
||||
@menu = menu_detail()
|
||||
end
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - menu_id
|
||||
def show
|
||||
menu_detail(params[:menu_id])
|
||||
@menu = menu_detail(params[:id])
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def menu_detail
|
||||
def menu_detail (menu_id)
|
||||
if (menu_id)
|
||||
#Pull this menu
|
||||
menu = Menu.find_by_id(menu_id)
|
||||
return menu
|
||||
else
|
||||
#Pull Default menu
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def menu_params()
|
||||
params.permit(:id)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
class Api::Restaurant::RoomsController < Api::ApiController
|
||||
before_action :set_room, only: [:show]
|
||||
|
||||
def index
|
||||
render json: Room.active.order("order_by")
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def bill
|
||||
end
|
||||
|
||||
def move
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_room
|
||||
@table = Room.find(params[:id])
|
||||
end
|
||||
end
|
||||
@@ -1,28 +0,0 @@
|
||||
class Api::Restaurant::SeatingsController < Api::ApiController
|
||||
before_action :set_table, only: [:show]
|
||||
|
||||
def index
|
||||
render json: Table.active.order("order_by")
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API full the current status of table and if there is order attached to this table - Order_ID will be return
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def bill
|
||||
end
|
||||
|
||||
def move
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_table
|
||||
@table = Table.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,16 @@
|
||||
class Api::Restaurant::ZonesController < Api::ApiController
|
||||
|
||||
def index
|
||||
render json: Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||
if (params[:filter] && params[:filter] = "all" )
|
||||
@all_tables = Table.active
|
||||
@all_rooms = Room.active
|
||||
else
|
||||
@zones = Zone.includes([:tables, :rooms]).where("is_active = true")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def zones_params
|
||||
params.permit(:filter)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,8 +16,11 @@ module TokenVerification
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
@user = Employee.authenticate_token(token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
belongs_to :zone
|
||||
|
||||
default_scope { order('order_by asc') }
|
||||
|
||||
scope :active, -> {where(is_active: true)}
|
||||
|
||||
def get_current_booking
|
||||
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
||||
|
||||
if booking.count > 0 then
|
||||
return booking[0]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,11 @@ class MenuCategory < ApplicationRecord
|
||||
belongs_to :menu
|
||||
has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id"
|
||||
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
|
||||
|
||||
has_many :menu_items
|
||||
|
||||
validates_presence_of :name
|
||||
|
||||
default_scope { order('order_by asc') }
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
class MenuItem < ApplicationRecord
|
||||
belongs_to :menu_category
|
||||
has_many :menu_item_instances
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user