nothing to commit

This commit is contained in:
nandar
2017-01-25 18:12:53 +06:30
5 changed files with 18 additions and 11 deletions

View File

@@ -49,8 +49,12 @@ class Api::BatchesController < ApplicationController
check_member= Member.authenticate_session_token(session_token) check_member= Member.authenticate_session_token(session_token)
if !check_member.nil? if !check_member.nil?
batch=Batch.find_by_id(batch_id) batch=Batch.find_by_id(batch_id)
batch_line_items=batch.batch_line_item.count batch_line_count=0
@out=true,batch_line_items batch_line_items= BatchLineItem.limit(1)
if !batch_line_items.empty?
batch_line_count=batch.batch_line_item.count
end
@out=true,batch_line_count
else else
@out = false, "Sorry!Unauthorized user!" @out = false, "Sorry!Unauthorized user!"
end end
@@ -59,6 +63,7 @@ class Api::BatchesController < ApplicationController
session_token=params[:session_token] session_token=params[:session_token]
created_by=params[:created_by] created_by=params[:created_by]
check_member= Member.authenticate_session_token(session_token) check_member= Member.authenticate_session_token(session_token)
if !check_member.nil? if !check_member.nil?
if !created_by.nil? if !created_by.nil?

View File

@@ -6,9 +6,10 @@ class BatchLineItemsController < ApplicationController
@batches=Batch.all @batches=Batch.all
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id').select('batch_line_items.*,batches.order_ref as batch_name').page(params[:page]).per(2) @batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id').select('batch_line_items.*,batches.order_ref as batch_name').page(params[:page]).per(2)
end end
def create def export
batch_list=params[:batch] batch_list=params[:batch]
if ! batch_list.nil? user_id=current_member.user_id
if !batch_list.nil?
batch_list.each do |batch| batch_list.each do |batch|
find_batch=Batch.find_by_id(batch) find_batch=Batch.find_by_id(batch)
if !find_batch.nil? if !find_batch.nil?
@@ -19,7 +20,6 @@ class BatchLineItemsController < ApplicationController
end end
@batchLineItems = BatchLineItem.where('batch_id in (?) ',batch_list).select('*') @batchLineItems = BatchLineItem.where('batch_id in (?) ',batch_list).select('*')
else else
user_id=current_member.user_id
batches=Batch.all batches=Batch.all
batches.each do |batch| batches.each do |batch|
export_count=batch.export_count export_count=batch.export_count

View File

@@ -44,6 +44,7 @@ class BatchLineItem < ApplicationRecord
encrypt_key="" encrypt_key=""
find_user=User.find_by_id(user_id) find_user=User.find_by_id(user_id)
if !find_user.nil? if !find_user.nil?
encrypt_key=find_user.secrect_key encrypt_key=find_user.secrect_key
end end
@@ -52,6 +53,7 @@ class BatchLineItem < ApplicationRecord
csv << attributes csv << attributes
all.each do |encoder| all.each do |encoder|
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
encryptd_data=BatchLineItem.encrypted(str,encrypt_key) encryptd_data=BatchLineItem.encrypted(str,encrypt_key)
encoder.wristband_token=encryptd_data encoder.wristband_token=encryptd_data
@@ -60,7 +62,7 @@ class BatchLineItem < ApplicationRecord
end end
end end
def self.encrypted(message,encrypt_key) def self.encrypted(message,encrypt_key)
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc")
cipher.encrypt cipher.encrypt
key = Digest::SHA1.hexdigest(encrypt_key) key = Digest::SHA1.hexdigest(encrypt_key)

View File

@@ -13,7 +13,7 @@ Rails.application.routes.draw do
#users #users
get 'check_registered_email' => "users#check_registered_email" get 'check_registered_email' => "users#check_registered_email"
#Encoder #Encoder
match 'batch_line_items/export' => 'batch_line_items#create', :as => 'export', :via => :post match 'batch_line_items/export' => 'batch_line_items#export', :as => 'export', :via => :post
namespace :api, defaults: {format: :json} do namespace :api, defaults: {format: :json} do
#login #login