edit
This commit is contained in:
@@ -8,9 +8,9 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
client_id=""
|
||||
|
||||
check_member= Member.authenticate_session_token(session_token)
|
||||
if !check_member.nil?
|
||||
if !check_member.nil?
|
||||
encrypt_key=""
|
||||
wristband_code=""
|
||||
asset_identity=""
|
||||
|
||||
find_batch = Batch.find_by_id(batch_id)
|
||||
if !find_batch.nil?
|
||||
@@ -21,7 +21,7 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
product_type=find_user.product_type
|
||||
client_id=find_user.id
|
||||
|
||||
if !encrypt_key.nil?
|
||||
if !encrypt_key.nil?
|
||||
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
||||
if check_manufacture.nil?
|
||||
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
||||
@@ -31,20 +31,20 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
digest_data= Digest::MD5.hexdigest(str)
|
||||
hex_data=digest_data.hex
|
||||
hex_str=hex_data.to_s
|
||||
wristband_code=hex_str[0..15]
|
||||
check_wirstband=BatchLineItem.find_by_asset_identity(wristband_code)
|
||||
asset_identity=hex_str[0..15]
|
||||
check_asset=BatchLineItem.find_by_asset_identity(asset_identity)
|
||||
|
||||
if check_wirstband.nil?
|
||||
@out=create_product(wristband_code,serial_no,batch_id,manufacture_uid,card_type)
|
||||
if check_asset.nil?
|
||||
@out=create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||
else
|
||||
@out=false,'Wristband is already registered!'
|
||||
@out=false,'Asset Identity is already registered!'
|
||||
end
|
||||
elsif product_type=="card"
|
||||
@out=create_product(wristband_code,serial_no,batch_id,manufacture_uid,card_type)
|
||||
@out=create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||
end
|
||||
else
|
||||
@out=false,'Wristband is already registered!'
|
||||
end
|
||||
@out=false,'Manufacture UID is already registered!'
|
||||
end
|
||||
else
|
||||
@out=false,'Invalid User!'
|
||||
end
|
||||
@@ -58,9 +58,9 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
@out=false,'Sorry!Unauthorized user!'
|
||||
end
|
||||
end
|
||||
def create_product(wristband_code,serial_no,batch_id,manufacture_uid,card_type)
|
||||
def create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||
batchLineItem=BatchLineItem.new
|
||||
batchLineItem.asset_identity=wristband_code
|
||||
batchLineItem.asset_identity=asset_identity
|
||||
batchLineItem.serial_no=serial_no
|
||||
batchLineItem.batch_id=batch_id
|
||||
batchLineItem.manufacture_uid = manufacture_uid
|
||||
|
||||
Reference in New Issue
Block a user