Setting up initial company setup.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
(ns auto-ap.db.companies)
|
||||
(ns auto-ap.db.companies
|
||||
(:require [clojure.java.jdbc :as j]
|
||||
[auto-ap.db.utils :refer [clj->db db->clj get-conn]]
|
||||
[clojure.edn :as edn]))
|
||||
|
||||
(defn get-all []
|
||||
[{:name "Campbell Brewing Company"
|
||||
:matches ["campbell brewing company" "campbell brewery company" "campbell brewing"]}
|
||||
{:name "Brown Chicken Brown Cow"
|
||||
:matches ["brown chicken brown cow"]}
|
||||
{:name "Naschmarkt Restaurant"
|
||||
:matches ["naschmarkt" "naschmarkt restaurant"]}])
|
||||
(->> (j/query (get-conn) "SELECT * FROM companies")
|
||||
(map db->clj )
|
||||
(map (fn [{:keys [data] :as x}]
|
||||
(merge x (edn/read-string data))))))
|
||||
|
||||
@@ -79,6 +79,11 @@
|
||||
(routes (ANY "*" [] (response/resource-response "index.html" {:root "public"}))))
|
||||
|
||||
(defroutes api-routes
|
||||
|
||||
(GET "/api/companies" []
|
||||
{:status 200
|
||||
:body (pr-str (companies/get-all))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
|
||||
(GET "/api/invoices" []
|
||||
{:status 200
|
||||
@@ -119,6 +124,7 @@
|
||||
(let [{:keys [filename tempfile]} files
|
||||
existing-invoices (invoices/get-all)
|
||||
companies (companies/get-all)]
|
||||
(println companies)
|
||||
(invoices/insert-multi!
|
||||
(for [{:keys [total date invoice-number customer-identifier vendor] :as row}
|
||||
(parse/parse-file (.getPath tempfile) filename)]
|
||||
|
||||
Reference in New Issue
Block a user