add loader service api
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
include ActionController::MimeResponds
|
||||
|
||||
# before_action :lookup_domain
|
||||
helper_method :current_token, :current_login_employee, :get_cashier
|
||||
@@ -23,25 +24,25 @@ class Api::ApiController < ActionController::API
|
||||
@employee = Employee.find_by_token_session(current_token)
|
||||
end
|
||||
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# def lookup_domain
|
||||
# if request.subdomain.present? && request.subdomain != "www"
|
||||
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||
# if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# logger.info "Location - " + @license.dbhost
|
||||
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# # authenticate_session_token
|
||||
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||
# else
|
||||
# # reconnect_default_db
|
||||
# logger.info 'License is nil'
|
||||
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
# def website_connection(license)
|
||||
# def website_connection(license)
|
||||
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||
# :username => license.dbusername, :password => license.dbpassword)
|
||||
# end
|
||||
@@ -55,8 +56,8 @@ class Api::ApiController < ActionController::API
|
||||
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||
# end
|
||||
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
# def cache_license(url, lookup)
|
||||
# @license = License.new(url, lookup)
|
||||
|
||||
# if (@license.detail_with_local_cache(lookup) == true)
|
||||
# return @license
|
||||
|
||||
@@ -40,7 +40,7 @@ class Api::AuthenticateController < Api::ApiController
|
||||
@status = false
|
||||
@error_message = "This employee is not active!"
|
||||
# render json: JSON.generate({:status => false, :error_message => "This employee is not active!"})
|
||||
end
|
||||
end
|
||||
else
|
||||
@status = false
|
||||
@error_message = "Bad Emp_ID or Password!"
|
||||
|
||||
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
90
app/controllers/api/loader_service/load_data_controller.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
require "net/http"
|
||||
class Api::LoaderService::LoadDataController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def get_sale_data_rage
|
||||
load_time_start = params[:load_time]
|
||||
load_time_end = params[:load_time_end]
|
||||
unless load_time_start.nil? || load_time_end.nil?
|
||||
@sale_data = Sale.get_load_sale_range(load_time_start.to_datetime,load_time_end.to_datetime)
|
||||
if !@sale_data.empty?
|
||||
@out = {general_status: true, data: @sale_data}
|
||||
else
|
||||
@out = {general_status: false, data: "Data is empty."}
|
||||
end
|
||||
else
|
||||
@out = {general_status: false, data: "load_time is missing."}
|
||||
end
|
||||
render :json => @out
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk Start
|
||||
|
||||
# Detail Sale
|
||||
def get_detail_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data[:transaction_date].to_s
|
||||
detail_sale_data = SaleItem.get_detail_sale_data(transaction_date)
|
||||
json = detail_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless detail_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => detail_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json {render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Tender sale
|
||||
def get_tender_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
tender_sale_data = Sale.get_tender_sale_data(transaction_date)
|
||||
json = tender_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless tender_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => tender_sale_data }
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty" }
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Daily_Sale summary
|
||||
def get_daily_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
daily_sale_data = Sale.get_daily_sale_data(transaction_date)
|
||||
unless daily_sale_data.empty?
|
||||
out = { :status => "success", :data => daily_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# Check Sale Data
|
||||
def get_check_sale_data
|
||||
data = params['data']
|
||||
transaction_date = data['transaction_date'].to_s
|
||||
check_sale_data = Sale.get_check_sale_data(transaction_date)
|
||||
json = check_sale_data.to_json
|
||||
trans_count = JSON.parse(json).count
|
||||
unless check_sale_data.empty?
|
||||
out = { :status => "success", :transaction_count => trans_count, :data => check_sale_data}
|
||||
else
|
||||
out = { :status => "fail", :data => "Data is empty"}
|
||||
end
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
# SFTP for BreadTalk End
|
||||
end
|
||||
Reference in New Issue
Block a user