diff options
| author | ckonstanski <carlos.konstanski@olo.com> | 2024-05-27 14:52:07 -0600 |
|---|---|---|
| committer | ckonstanski <carlos.konstanski@olo.com> | 2024-05-27 14:52:07 -0600 |
| commit | e30ee019294e2abbbd3644b73e4327ae17df4392 (patch) | |
| tree | 44d03581f96d81e0990f0664c01e725de542e9c2 /lisp/sql | |
| parent | 42e351bb04d38b01a1d5b251cdbc0caaa4be3712 (diff) | |
gallery
Diffstat (limited to 'lisp/sql')
| -rw-r--r-- | lisp/sql/gallery.lisp | 30 | ||||
| -rw-r--r-- | lisp/sql/general-pkg.lisp | 32 | ||||
| -rw-r--r-- | lisp/sql/generics.lisp | 12 |
3 files changed, 72 insertions, 2 deletions
diff --git a/lisp/sql/gallery.lisp b/lisp/sql/gallery.lisp new file mode 100644 index 0000000..2f4231d --- /dev/null +++ b/lisp/sql/gallery.lisp @@ -0,0 +1,30 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package :woodriverlessons) + +(defclass gallery (postgres-record) + ((id :initarg :id + :initform nil + :accessor id) + (description :initarg :description + :initform nil + :accessor description) + (filename :initarg :filename + :initform nil + :accessor filename) + (mime_type :initarg :mime_type + :initform nil + :accessor mime_type) + (content :initarg :content + :initform nil + :accessor content) + (created :initarg :created + :initform nil + :accessor created) + (modified :initarg :modified + :initform nil + :accessor modified) + (*table :initform "general.gallery") + (*where-expression :initform "id = ~a")) + (:documentation "Holds the data for a general.gallery type.")) diff --git a/lisp/sql/general-pkg.lisp b/lisp/sql/general-pkg.lisp index 162d60b..5a92ed4 100644 --- a/lisp/sql/general-pkg.lisp +++ b/lisp/sql/general-pkg.lisp @@ -8,7 +8,35 @@ (:documentation "")) (defmethod get-about-us ((general-pkg general-pkg)) - (car (get-records general-pkg (make-instance 'about-us) nil))) + (get-record general-pkg (make-instance 'about-us))) (defmethod get-testimonials ((general-pkg general-pkg)) - (car (get-records general-pkg (make-instance 'testimonials) nil))) + (get-record general-pkg (make-instance 'testimonials))) + +(defmethod get-gallery ((general-pkg general-pkg) id) + (let ((gallery (make-instance 'gallery :*table (format nil "general.get_gallery(~a)" id)))) + (get-record general-pkg gallery))) + +(defmethod get-galleries ((general-pkg general-pkg)) + (let ((gallery (make-instance 'gallery :*table (format nil "general.get_galleries()")))) + (get-records general-pkg gallery nil))) + +(defmethod insert-gallery ((general-pkg general-pkg) (gallery gallery)) + (setf (*table gallery) (format nil + "general.insert_gallery('~a', '~a', '~a', '~a')" + (description gallery) + (filename gallery) + (mime_type gallery) + (content gallery))) + (setf (id gallery) (caar (call-pg-function general-pkg gallery))) + (id gallery)) + +(defmethod update-gallery ((general-pkg general-pkg) (gallery gallery)) + (setf (*table gallery) (format nil + "general.update_gallery(~a, '~a', '~a', '~a', '~a')" + (id gallery) + (description gallery) + (filename gallery) + (mime_type gallery) + (content gallery))) + (caar (call-pg-function general-pkg gallery))) diff --git a/lisp/sql/generics.lisp b/lisp/sql/generics.lisp index 708856a..e45327c 100644 --- a/lisp/sql/generics.lisp +++ b/lisp/sql/generics.lisp @@ -94,6 +94,18 @@ sessionid.")) (defgeneric get-testimonials (record-pkg) (:documentation "Gets the one and only general.testimonials record.")) +(defgeneric get-gallery (general-pkg id) + (:documentation "Gets a general.gellery record by id.")) + +(defgeneric get-galleries (general-pkg) + (:documentation "Gets all general.gallery records sorted by modified desc.")) + +(defgeneric insert-gallery (general-pkg gallery) + (:documentation "Inserta a new general.gallery record.")) + +(defgeneric update-gallery (general-pkg gallery) + (:documentation "Updates an existing general.gallery record.")) + (defgeneric get-contact-us-posts (record-pkg user-id read-p) (:documentation "Gets contact.contact_us_posts records.")) |
