module Customer
  class ProductsController < ApplicationController

    def show
      @hardware = Hardware.find_by(sn: params[:id])
      if @hardware
        @hardware_test_logs = @hardware.hardware_test_logs.order("id DESC")
      end
    end

    def search
      @sn = params[:sn].to_s.gsub("\r\n", ",").gsub("，", ",").strip.split(",").collect{|word| word.strip }.reject { |s| s.empty? }
      if !@sn.blank?
        if @sn.size > 100
          @message = "最多可以批量查询100个"
        else
          @hardwares = Hardware.where(sn: @sn).all
        end
      end
    end

  end
end