Compare commits
13 Commits
d1dfb1d262
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e7034374d | ||
|
|
48d37dd550 | ||
|
|
2a5f63331b | ||
|
|
1b619e8dc1 | ||
|
|
019902872b | ||
|
|
d2b9a9e61f | ||
|
|
ad312c15a5 | ||
|
|
2f34bb5aa8 | ||
|
|
087c4d92d3 | ||
|
|
9951351f2c | ||
|
|
5a13870b66 | ||
|
|
f211940225 | ||
|
|
323dd43dd2 |
42
Dockerfile
Normal file
42
Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
FROM ruby:2.6.10-slim-bullseye
|
||||||
|
|
||||||
|
RUN apt-get update -qq && \
|
||||||
|
apt-get install -y --no-install-recommends \
|
||||||
|
build-essential libpq-dev nodejs git curl libv8-dev && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN gem install bundler:1.17.2
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY Gemfile Gemfile.lock ./
|
||||||
|
RUN bundle install --without development test --jobs 4 --retry 3
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Create gitignored config files
|
||||||
|
RUN cat <<'DBEOF' > config/database.yml
|
||||||
|
production:
|
||||||
|
adapter: postgresql
|
||||||
|
encoding: utf8
|
||||||
|
pool: 5
|
||||||
|
database: <%= ENV.fetch('DATABASE_NAME', 'nemo_encoder') %>
|
||||||
|
username: <%= ENV.fetch('DATABASE_USER', 'nemo') %>
|
||||||
|
password: <%= ENV.fetch('DATABASE_PASSWORD', '') %>
|
||||||
|
host: <%= ENV.fetch('DATABASE_HOST', 'localhost') %>
|
||||||
|
port: <%= ENV.fetch('DATABASE_PORT', '5432') %>
|
||||||
|
DBEOF
|
||||||
|
|
||||||
|
RUN cat <<'SECEOF' > config/secrets.yml
|
||||||
|
production:
|
||||||
|
secret_key_base: <%= ENV.fetch('SECRET_KEY_BASE', '14f1c43bf96e14022f9e517b6b4909070398497c26fd062cb280dedcc44f25c5146444bdf49ff8bbbb98869e9d7bfeaea5b5c12128bdb6660aec9169963a4429') %>
|
||||||
|
SECEOF
|
||||||
|
|
||||||
|
RUN mkdir -p tmp/pids tmp/puma tmp/cache tmp/sockets log storage
|
||||||
|
|
||||||
|
RUN RAILS_ENV=production SECRET_KEY_BASE=dummy DATABASE_HOST=localhost \
|
||||||
|
bundle exec rake assets:precompile 2>/dev/null || true
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["bundle", "exec", "puma", "-C", "config/puma.rb", "-p", "3000"]
|
||||||
@@ -52,7 +52,7 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if check_manufacture.asset_identity !=card_account_no
|
if check_manufacture.asset_identity != card_account_no
|
||||||
@out=true,check_manufacture.serial_no,check_manufacture.asset_identity
|
@out=true,check_manufacture.serial_no,check_manufacture.asset_identity
|
||||||
else
|
else
|
||||||
@out=false,'Manufacture UID is already registered!'
|
@out=false,'Manufacture UID is already registered!'
|
||||||
@@ -142,27 +142,45 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
account_no = params[:account_no]
|
account_no = params[:account_no]
|
||||||
barcode = params[:barcode]
|
barcode = params[:barcode]
|
||||||
manufacture_uid = params[:manufacture_uid]
|
manufacture_uid = params[:manufacture_uid]
|
||||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
session_token = params[:session_token]
|
||||||
if !batch_line_item.nil?
|
|
||||||
batch_line_item.manufacture_uid = manufacture_uid
|
|
||||||
batch_line_item.barcode = barcode
|
|
||||||
batch_line_item.save
|
|
||||||
|
|
||||||
# update batch
|
find_user = Member.find_by_session_token(session_token)
|
||||||
batch = Batch.find_by_id(batch_line_item.batch_id)
|
if !find_user.nil?
|
||||||
card_qty=batch.qty_processing.to_i
|
if barcode.present?
|
||||||
success_qty=batch.qty_success
|
batch_line_item = BatchLineItem.find_by_barcode(barcode)
|
||||||
|
elsif account_no.present?
|
||||||
|
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||||
|
end
|
||||||
|
|
||||||
batch.qty_processing=card_qty+1
|
if !batch_line_item.nil?
|
||||||
batch.qty_success=success_qty+1
|
if batch_line_item.manufacture_uid.empty?
|
||||||
batch.save
|
issue_count = BatchLineItem.where("manufacture_uid LIKE ?", "#{manufacture_uid}%").count
|
||||||
|
batch_line_item.manufacture_uid = "#{manufacture_uid}#{issue_count > 0 ? "-#{issue_count}" : ""}"
|
||||||
|
batch_line_item.save
|
||||||
|
|
||||||
@out = true,"success"
|
# update batch
|
||||||
|
batch = Batch.find_by_id(batch_line_item.batch_id)
|
||||||
|
card_qty=batch.qty_processing.to_i
|
||||||
|
success_qty=batch.qty_success
|
||||||
|
|
||||||
|
batch.qty_processing=card_qty+1
|
||||||
|
batch.qty_success=success_qty+1
|
||||||
|
batch.save
|
||||||
|
|
||||||
|
@out = true,batch_line_item.asset_identity
|
||||||
|
else
|
||||||
|
@out = false,"Duplicate Manufacture UID"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@out = false,"Invalid Record"
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@out = false,"error"
|
@out = false,"Not Authorized"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_item_by_batch
|
def get_item_by_batch
|
||||||
batch_id = params[:batch_id]
|
batch_id = params[:batch_id]
|
||||||
session_token = params[:session_token]
|
session_token = params[:session_token]
|
||||||
@@ -203,6 +221,25 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
end
|
end
|
||||||
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
|
# def check_ticket
|
||||||
# session_token = params[:session_token]
|
# session_token = params[:session_token]
|
||||||
# barcode =params[:barcode]
|
# barcode =params[:barcode]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class BatchesController < ApplicationController
|
|||||||
adult_or_child=params[:adult_or_child]
|
adult_or_child=params[:adult_or_child]
|
||||||
client_id=params[:client_id]
|
client_id=params[:client_id]
|
||||||
product_category_id=params[:product_category_id]
|
product_category_id=params[:product_category_id]
|
||||||
@batch = Batch.create_batch(date,order_ref,2,"adult_or_child",client_id,product_category_id)
|
@batch = Batch.create_batch(date,order_ref,current_member.id,"adult_or_child",client_id,product_category_id)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @batch.save
|
if @batch.save
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ class ClientsController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
@client = Client.new(client_params)
|
@client = Client.new(client_params)
|
||||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||||
key=cipher.random_key
|
secrect_key = cipher.random_key
|
||||||
secrect_key= Base64.encode64(key)
|
@client.secrect_key = secrect_key
|
||||||
@client.secrect_key=secrect_key
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @client.save
|
if @client.save
|
||||||
|
|||||||
@@ -140,14 +140,11 @@ 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-128-cbc")
|
cipher = OpenSSL::Cipher.new("aes-256-cbc")
|
||||||
cipher.encrypt
|
cipher.encrypt
|
||||||
|
|
||||||
key = Digest::SHA1.hexdigest(encrypt_key)
|
|
||||||
iv =encrypt_key
|
|
||||||
|
|
||||||
cipher.key = encrypt_key
|
cipher.key = encrypt_key
|
||||||
cipher.iv = encrypt_key
|
cipher.iv = encrypt_key[0,16]
|
||||||
|
|
||||||
encrypted = cipher.update(message)
|
encrypted = cipher.update(message)
|
||||||
encrypted << cipher.final
|
encrypted << cipher.final
|
||||||
|
|||||||
@@ -3,4 +3,12 @@ class Client < ApplicationRecord
|
|||||||
validates :name, :uniqueness => {:message =>"This client name is already taken." } ,on: :create
|
validates :name, :uniqueness => {:message =>"This client name is already taken." } ,on: :create
|
||||||
validates :location_code ,presence: { message: "Please enter client location code." }
|
validates :location_code ,presence: { message: "Please enter client location code." }
|
||||||
validates :location_code, :uniqueness => {:message =>"This location code is already taken." } ,on: :create
|
validates :location_code, :uniqueness => {:message =>"This location code is already taken." } ,on: :create
|
||||||
|
|
||||||
|
def secrect_key
|
||||||
|
Base64.decode64(super)
|
||||||
|
end
|
||||||
|
|
||||||
|
def secrect_key=(value)
|
||||||
|
super(Base64.encode64(value))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
#batch_line_items
|
||||||
post "generate_card_account_items" =>"batch_line_items#generate_card_account_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_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"
|
post "code_activate" => "batch_line_items#code_activate"
|
||||||
get "activated_list" => "batch_line_items#activated_list"
|
get "activated_list" => "batch_line_items#activated_list"
|
||||||
get "seller_info" => "batch_line_items#seller_info"
|
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