check duplicate record
This commit is contained in:
@@ -143,7 +143,9 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
barcode = params[:barcode]
|
||||
manufacture_uid = params[:manufacture_uid]
|
||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||
|
||||
if !batch_line_item.nil?
|
||||
if batch_line_item.manufacture_uid.nil?
|
||||
batch_line_item.manufacture_uid = manufacture_uid
|
||||
batch_line_item.barcode = barcode
|
||||
batch_line_item.save
|
||||
@@ -158,6 +160,9 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
batch.save
|
||||
|
||||
@out = true,"success"
|
||||
else
|
||||
@out = false,"Duplicate Record"
|
||||
end
|
||||
else
|
||||
@out = false,"error"
|
||||
end
|
||||
@@ -203,6 +208,24 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update_barcode_and_account_no
|
||||
session_token = params[:session_token]
|
||||
barcode =params[:barcode]
|
||||
user = Member.find_by_session_token(session_token)
|
||||
if !user.nil?
|
||||
user_id = user.user_id
|
||||
find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||
if !find_barcode.nil?
|
||||
@out = true,find_barcode
|
||||
else
|
||||
@out = false,"Invalid"
|
||||
end
|
||||
else
|
||||
@out = false, "Not Authorized"
|
||||
end
|
||||
end
|
||||
|
||||
# def check_ticket
|
||||
# session_token = params[:session_token]
|
||||
# barcode =params[:barcode]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if @out[0] == true
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
else
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
end
|
||||
3
app/views/api/batches/get_ticket_settings.json.jbuilder
Normal file
3
app/views/api/batches/get_ticket_settings.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
json.set! :status, @out[0]
|
||||
json.set! :message, @out[1]
|
||||
@@ -53,6 +53,7 @@ Rails.application.routes.draw do
|
||||
#batch_line_items
|
||||
post "generate_card_account_items" =>"batch_line_items#generate_card_account_items"
|
||||
post "update_manufacture_uid" => "batch_line_items#update_manufacture_uid"
|
||||
post "update_barcode_and_account_no" => "batch_line_items#update_barcode_and_account_no"
|
||||
post "code_activate" => "batch_line_items#code_activate"
|
||||
get "activated_list" => "batch_line_items#activated_list"
|
||||
get "seller_info" => "batch_line_items#seller_info"
|
||||
|
||||
9
db/migrate/20180810041316_create_setting.rb
Normal file
9
db/migrate/20180810041316_create_setting.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class CreateSetting < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :settings do |t|
|
||||
t.string :key
|
||||
t.string :value
|
||||
t.string :name
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user