summaryrefslogtreecommitdiff
path: root/lisp/service
diff options
context:
space:
mode:
authorckonstanski <kostcarl@isu.edu>2026-07-22 22:41:16 -0600
committerckonstanski <kostcarl@isu.edu>2026-07-22 22:41:16 -0600
commit7a902d7dec9e0ea2a35610bebac2e217340deb40 (patch)
tree986111ad86ec227edc7f4b12e542a2ff0c2bcee5 /lisp/service
parent51aa4409c58625687445f3d176e3f6bfa5281153 (diff)
stuff
Diffstat (limited to 'lisp/service')
-rw-r--r--lisp/service/menu-service.lisp1
-rw-r--r--lisp/service/resume-service.lisp345
2 files changed, 311 insertions, 35 deletions
diff --git a/lisp/service/menu-service.lisp b/lisp/service/menu-service.lisp
index aaff72b..7102f44 100644
--- a/lisp/service/menu-service.lisp
+++ b/lisp/service/menu-service.lisp
@@ -8,6 +8,7 @@
(:id "a_menu_resumes_contactinfo" :label "Contact Info" :handler "/resumes/contactinfo" :permissions "resume-view")
(:id "a_menu_resumes_education" :label "Education" :handler "/resumes/education" :permissions "resume-view")
(:id "a_menu_resumes_language" :label "Language" :handler "/resumes/language" :permissions "resume-view")
+ (:id "a_menu_resumes_skills" :label "Skills" :handler "/resumes/skills" :permissions "resume-view")
(:id "a_menu_contact_us" :label "Contact Me" :handler "/contact-us" :permissions "_Public")
(:id "a_menu_messages" :label "Messages" :handler "/messages" :permissions "messages-view")
(:id "a_menu_users" :label "Users" :handler "/users" :permissions "users-view")))
diff --git a/lisp/service/resume-service.lisp b/lisp/service/resume-service.lisp
index a1987d9..68b2c36 100644
--- a/lisp/service/resume-service.lisp
+++ b/lisp/service/resume-service.lisp
@@ -5,7 +5,7 @@
;; shared
-(defclass resumes-service (auth-service)
+(defclass resume-service (auth-service)
((title :initarg :title
:initform nil
:accessor title))
@@ -13,45 +13,45 @@
;; resume
-(defun resumes-json ()
- (with-auth (instance resumes-service "resume-view")
+(defun resume-json ()
+ (with-auth (instance resume-service "resume-view")
(setf (title instance) "Resumes")))
-(defclass resumes/view-service (resumes-service resume)
+(defclass resume/view-service (resume-service resume)
((resumes :initarg :resumes
:initform nil
:accessor resumes)
(location-p :initform nil))
(:documentation ""))
-(defun resumes-view-json ()
- (with-auth (instance resumes/view-service "resume-view")
+(defun resume-view-json ()
+ (with-auth (instance resume/view-service "resume-view")
(with-resume-database
(let ((resume-pkg (make-instance 'resume-pkg))
(user (get-user)))
- (setf (resumes instance) (get-all-resumes resume-pkg user))))
+ (setf (resumes instance) (get-records resume-pkg (make-instance 'resume :user_id (id user)) "name asc"))))
(sanitize-rest-json instance)
(loop for resume in (resumes instance)
do (sanitize-json resume))))
-(defclass resumes/add-service (resumes/view-service)
+(defclass resume/add-service (resume/view-service)
((form :initarg :form
:initform nil
:accessor form))
(:documentation ""))
-(defun resumes-add-json ()
- (with-auth (instance resumes/add-service "resume-modify")
+(defun resume-add-json ()
+ (with-auth (instance resume/add-service "resume-modify")
(setf (title instance) "Resume - Add")
- (setf (form instance) (make-form "resumes-add-form"
+ (setf (form instance) (make-form "resume-add-form"
nil
t
`((:name "name" :label "Name" :field-type "text" :required "required")
- (:label "Add Resume" :field-type "button" :onclick "on_resumes_add_submit_clicked()"))))))
+ (:label "Add Resume" :field-type "button" :onclick "on_resume_add_submit_clicked()"))))))
-(defun resumes-add-submit-json (name)
+(defun resume-add-submit-json (name)
(declare (special name))
- (with-auth (instance resumes/add-service "resume-modify")
+ (with-auth (instance resume/add-service "resume-modify")
(with-resume-database
(handler-case
(let* ((resume-pkg (make-instance 'resume-pkg))
@@ -59,36 +59,36 @@
(resume (make-instance 'resume :user_id (id user))))
(loop for param in (remove-if (lambda (x)
(intersection `(,x) '(id)))
- (sb-introspect:function-lambda-list #'resumes-add-submit-json))
+ (sb-introspect:function-lambda-list #'resume-add-submit-json))
do (setf (slot-value resume param) (symbol-value param)))
(insert-resume resume-pkg resume)
(setf (session-value :message) (format nil "Resume \"~a\" created successfully." (name resume))))
(error (e)
(setf (session-value :errormsg) (format nil "Error creating resume \"~a\". ~a" name e)))))))
-(defclass resumes/modify-service (resumes/add-service)
+(defclass resume/modify-service (resume/add-service)
()
(:documentation ""))
-(defun resumes-modify-json (id)
- (with-auth (instance resumes/modify-service "resume-modify")
+(defun resume-modify-json (id)
+ (with-auth (instance resume/modify-service "resume-modify")
(setf (title instance) "Resume - Modify")
(with-resume-database
(let* ((resume-pkg (make-instance 'resume-pkg))
(user (get-user))
(resume (get-record resume-pkg (make-instance 'resume :id id :user_id (id user)))))
(if resume
- (setf (form instance) (make-form "resumes-modify-form"
+ (setf (form instance) (make-form "resume-modify-form"
nil
t
`((:name "id" :field-type "hidden" :value ,(id resume) :required "required")
(:name "name" :label "Name" :field-type "text" :value ,(name resume) :required "required")
- (:label "Modify Resume" :field-type "button" :onclick "on_resumes_modify_submit_clicked()"))))
+ (:label "Modify Resume" :field-type "button" :onclick "on_resume_modify_submit_clicked()"))))
(setf (session-value :errormsg) "Error: could not modify resume. Not found."))))))
-(defun resumes-modify-submit-json (id name)
+(defun resume-modify-submit-json (id name)
(declare (special id name))
- (with-auth (instance resumes/modify-service "resume-modify")
+ (with-auth (instance resume/modify-service "resume-modify")
(setf (title instance) "Resume - Modify")
(with-resume-database
(handler-case
@@ -97,19 +97,19 @@
(resume (get-record resume-pkg (make-instance 'resume :id id :user_id (id user)))))
(loop for param in (remove-if (lambda (x)
(intersection `(,x) '(id)))
- (sb-introspect:function-lambda-list #'resumes-modify-submit-json))
+ (sb-introspect:function-lambda-list #'resume-modify-submit-json))
do (setf (slot-value resume param) (symbol-value param)))
(update-record resume-pkg resume)
(setf (session-value :message) (format nil "Resume \"~a\" modified successfully." (name resume))))
(error (e)
(setf (session-value :errormsg) (format nil "Error modifying resume \"~a\". ~a" name e)))))))
-(defclass resumes/delete-service (resumes/add-service)
+(defclass resume/delete-service (resume/add-service)
()
(:documentation ""))
-(defun resumes-delete-json (id)
- (with-auth (instance resumes/delete-service "resume-modify")
+(defun resume-delete-json (id)
+ (with-auth (instance resume/delete-service "resume-modify")
(with-resume-database
(let* ((resume-pkg (make-instance 'resume-pkg))
(user (get-user))
@@ -123,10 +123,10 @@
;; contactinfo
(defun contactinfo-json ()
- (with-auth (instance resumes-service "resume-view")
+ (with-auth (instance resume-service "resume-view")
(setf (title instance) "Contact Information")))
-(defclass contactinfo/view-service (resumes-service contactinfo)
+(defclass contactinfo/view-service (resume-service contactinfo)
((contactinfos :initarg :contactinfos
:initform nil
:accessor contactinfos)
@@ -138,7 +138,7 @@
(with-resume-database
(let ((resume-pkg (make-instance 'resume-pkg))
(user (get-user)))
- (setf (contactinfos instance) (get-all-contactinfo resume-pkg user))))
+ (setf (contactinfos instance) (get-records resume-pkg (make-instance 'contactinfo-v :user_id (id user)) "state_name asc, city asc, address asc, email asc, phone asc, visastatus asc"))))
(sanitize-rest-json instance)
(loop for contactinfo-v in (contactinfos instance)
do (sanitize-json contactinfo-v))))
@@ -258,10 +258,10 @@
;; education
(defun education-json ()
- (with-auth (instance resumes-service "resume-view")
+ (with-auth (instance resume-service "resume-view")
(setf (title instance) "Education")))
-(defclass education/view-service (resumes-service education)
+(defclass education/view-service (resume-service education)
((educations :initarg :educations
:initform nil
:accessor educations)
@@ -273,7 +273,7 @@
(with-resume-database
(let ((resume-pkg (make-instance 'resume-pkg))
(user (get-user)))
- (setf (educations instance) (get-all-education resume-pkg user))))
+ (setf (educations instance) (get-records resume-pkg (make-instance 'education :user_id (id user))))))
(sanitize-rest-json instance)
(loop for education in (educations instance)
do (sanitize-json education))))
@@ -378,10 +378,10 @@
;; language
(defun language-json ()
- (with-auth (instance resumes-service "resume-view")
+ (with-auth (instance resume-service "resume-view")
(setf (title instance) "Languages")))
-(defclass language/view-service (resumes-service language)
+(defclass language/view-service (resume-service language)
((languages :initarg :languages
:initform nil
:accessor languages)
@@ -393,7 +393,7 @@
(with-resume-database
(let ((resume-pkg (make-instance 'resume-pkg))
(user (get-user)))
- (setf (languages instance) (get-all-languages resume-pkg user))))
+ (setf (languages instance) (get-records resume-pkg (make-instance 'language :user_id (id user))))))
(sanitize-rest-json instance)
(loop for language in (languages instance)
do (sanitize-json language))))
@@ -500,3 +500,278 @@
(setf (session-value :message) (format nil "Language \"~a\" deleted successfully." (name language))))
(setf (session-value :errormsg) "Error: could not delete Language: not found."))))))
+;; skill
+
+(defun skill-json ()
+ (with-auth (instance resume-service "resume-view")
+ (setf (title instance) "Skills")))
+
+(defclass skill/view-service (resume-service skill)
+ ((skills :initarg :skills
+ :initform nil
+ :accessor skills)
+ (location-p :initform nil))
+ (:documentation ""))
+
+(defun skill-view-json ()
+ (with-auth (instance skill/view-service "resume-view")
+ (with-resume-database
+ (let ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user)))
+ (setf (skills instance) (get-records resume-pkg (make-instance 'skill :user_id (id user))))))
+ (sanitize-rest-json instance)
+ (loop for skill in (skills instance)
+ do (sanitize-json skill))))
+
+(defclass skill/add-service (skill/view-service)
+ ((form :initarg :form
+ :initform nil
+ :accessor form))
+ (:documentation ""))
+
+(defun skill-add-json ()
+ (with-auth (instance skill/add-service "resume-modify")
+ (setf (title instance) "Skill - Add")
+ (setf (form instance) (make-form "skill-add-form"
+ nil
+ t
+ `((:name "skill" :label "Skill" :field-type "text" :required "required")
+ (:label "Add Skill" :field-type "button" :onclick "on_skill_add_submit_clicked()"))))))
+
+(defun skill-add-submit-json (skill)
+ (declare (special skill))
+ (with-auth (instance skill/add-service "resume-modify")
+ (with-resume-database
+ (handler-case
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (skill (make-instance 'skill :user_id (id user))))
+ (loop for param in (remove-if (lambda (x)
+ (intersection `(,x) '(id)))
+ (sb-introspect:function-lambda-list #'skill-add-submit-json))
+ do (setf (slot-value skill param) (symbol-value param)))
+ (insert-skill resume-pkg skill)
+ (setf (session-value :message) (format nil "Skill \"~a\" created successfully." skill)))
+ (error (e)
+ (setf (session-value :errormsg) (format nil "Error creating Skill \"~a\". ~a" skill e)))))))
+
+(defclass skill/modify-service (skill/add-service)
+ ()
+ (:documentation ""))
+
+(defun skill-modify-json (id)
+ (with-auth (instance skill/modify-service "resume-modify")
+ (setf (title instance) "Skill - Modify")
+ (with-resume-database
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (skill (get-record resume-pkg (make-instance 'skill :id id :user_id (id user)))))
+ (if skill
+ (setf (form instance) (make-form "skill-modify-form"
+ nil
+ t
+ `((:name "id" :field-type "hidden" :value ,(id skill) :required "required")
+ (:name "skill" :label "Skill" :field-type "text" :value ,(skill skill) :required "required")
+ (:label "Modify Skill" :field-type "button" :onclick "on_skill_modify_submit_clicked()"))))
+ (setf (session-value :errormsg) "Error: could not modify Skill. Not found."))))))
+
+(defun skill-modify-submit-json (id skill)
+ (declare (special id skill))
+ (with-auth (instance skill/modify-service "resume-modify")
+ (setf (title instance) "Skill - Modify")
+ (with-resume-database
+ (handler-case
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (skill (get-record resume-pkg (make-instance 'skill :id id :user_id (id user)))))
+ (loop for param in (remove-if (lambda (x)
+ (intersection `(,x) '(id)))
+ (sb-introspect:function-lambda-list #'skill-modify-submit-json))
+ do (setf (slot-value skill param) (symbol-value param)))
+ (update-record resume-pkg skill)
+ (setf (session-value :message) (format nil "Skill \"~a\" modified successfully." skill)))
+ (error (e)
+ (setf (session-value :errormsg) (format nil "Error modifying Skill \"~a\". ~a" skill e)))))))
+
+(defclass skill/delete-service (skill/add-service)
+ ()
+ (:documentation ""))
+
+(defun skill-delete-json (id)
+ (with-auth (instance skill/delete-service "resume-modify")
+ (with-resume-database
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (skill (get-record resume-pkg (make-instance 'skill :id id :user_id (id user)))))
+ (if skill
+ (progn
+ (delete-record resume-pkg skill)
+ (setf (session-value :message) (format nil "Skill \"~a\" deleted successfully." (skill skill))))
+ (setf (session-value :errormsg) "Error: could not delete Skill: not found."))))))
+
+;; macro
+
+(defmacro define-resume-component ((component-s rest-args) &body input-form-fields)
+ "`component-s' is a symbol that matches the component's record object
+name, i.e SKILL, JOB, EDUCATION, LANGUAGE, CONTACTINFO. This will be
+used all over the place. The record name equals the component name.
+
+`rest-args' is the list of REST API arguments for the add and modify
+forms. In the form like this example: ((id :parameter-type 'integer))
+
+`input-form-fields' is a list of generic form fields that gets
+inserted into the add and modify forms."
+ (let* ((component (symbol-name component-s))
+ (component-lcase (string-downcase component))
+ (components-s (intern (format nil "~aS" component)))
+ (components-k (intern (format nil "~aS" component) 'keyword))
+ (arg-names (loop for arg in rest-args collect (car arg)))
+ (macro-root-s (intern (format nil ".~a" component)))
+ (macro-view-s (intern (format nil "~.a-VIEW" component)))
+ (macro-add-s (intern (format nil "~.a-ADD" component)))
+ (macro-add-submit-s (intern (format nil ".~a-ADD-SUBMIT" component)))
+ (macro-modify-s (intern (format nil ".~a-MODIFY" component)))
+ (macro-modify-submit-s (intern (format nil ".~a-MODIFY-SUBMIT" component)))
+ (macro-delete-s (intern (format nil ".~a-DELETE" component)))
+ (func-root-s (intern (format nil "~a-JSON" component)))
+ (func-view-s (intern (format nil "~a-VIEW-JSON" component)))
+ (func-add-s (intern (format nil "~a-ADD-JSON" component)))
+ (func-add-submit-s (intern (format nil "~a-ADD-SUBMIT-JSON" component)))
+ (func-modify-s (intern (format nil "~a-MODIFY-JSON" component)))
+ (func-modify-submit-s (intern (format nil "~a-MODIFY-SUBMIT-JSON" component)))
+ (func-delete-s (intern (format nil "~a-DELETE-JSON" component)))
+ (class-view-s (intern (format nil "~a/VIEW-SERVICE" component)))
+ (class-modify-s (intern (format nil "~a/MODIFY-SERVICE" component)))
+ (form-add (intern (format nil "~a-add-form" component-lcase)))
+ (form-modify (format nil "~a-modify-form" component-lcase)))
+ `(progn
+ (defmacro ,macro-root-s ()
+ `(,func-root-s))
+
+ (defmacro ,macro-view-s ()
+ `(,func-view-s))
+
+ (defmacro ,macro-add-s ()
+ `(,func-add-s))
+
+ (defmacro ,macro-add-submit-s ()
+ `(,macro-add-submit-s ,arg-names))
+
+ (defmacro ,macro-modify-s ()
+ `(,func-modify-s id))
+
+ (defmacro ,macro-modify-submit-s ()
+ `(,func-modify-submit-s ,(append '(id) arg-names)))
+
+ (defmacro ,macro-delete-s ()
+ `(,func-delete-s id))
+
+ (define-endpoint (,(format nil ("/resume/~a" component-lcase) :method :get) () ,macro-root-s))
+ (define-endpoint (,(format nil ("/resume/~a/view" component-lcase) :method :get) () ,macro-view-s))
+ (define-endpoint (,(format nil ("/resume/~a/add" component-lcase) :method :post) () ,macro-add-s))
+ (define-endpoint (,(format nil ("/resume/~a/add/submit" component-lcase) :method :post) (&post ,@rest-args) ,macro-add-submit-s))
+ (define-endpoint (,(format nil ("/resume/~a/modify" component-lcase) :method :post) (&post (id :parameter-type 'integer)) ,macro-modify-s))
+ (define-endpoint (,(format nil ("/resume/~a/modify/submit" component-lcase) :method :post) (&post (id :parameter-type 'integer) ,@rest-args) ,macro-modify-submit-s))
+ (define-endpoint (,(format nil ("/resume/~a/delete/:id" component-lcase) :method :delete) (&path (id 'integer)) ,macro-delete-s))
+
+ (defun ,func-root-s ()
+ (with-auth (instance resume-service "resume-view")
+ (setf (title instance) ,component)))
+
+ (defclass ,class-view-s (resume-service)
+ ((,components-s :initarg ,components-k
+ :initform nil
+ :accessor ,components-s)
+ (location-p :initform nil))
+ (:documentation ""))
+
+ (defun ,func-view-s ()
+ (with-auth (instance ,class-view-s "resume-view")
+ (with-resume-database
+ (let ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user)))
+ (setf (,components-s instance) (get-records resume-pkg (make-instance ',component-s :user_id (id user))))))
+ (sanitize-rest-json instance)
+ (loop for ,component-s in (,components-s instance)
+ do (sanitize-json ,component-s))))
+
+ (defclass ,class-modify-s (,class-view-s)
+ ((form :initarg :form
+ :initform nil
+ :accessor form))
+ (:documentation ""))
+
+ (defun ,func-add-s ()
+ (with-auth (instance ,class-modify-s "resume-modify")
+ (setf (title instance) (format nil "~a - Add" ,component))
+ (setf (form instance) (make-form ,form-add
+ nil
+ t
+ `(,,@input-form-fields
+ (:label ,(format nil "Add ~a" ,component) :field-type "button" :onclick ,(format nil "on_~a_add_submit_clicked()" ,component-lcase)))))))
+
+ (defun ,func-add-submit-s (,arg-names)
+ (declare (special ,arg-names))
+ (with-auth (instance ,class-modify-s "resume-modify")
+ (with-resume-database
+ (handler-case
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,component-s (make-instance ',component-s :user_id (id user))))
+ (loop for param in (remove-if (lambda (x)
+ (intersection `(,x) '(id)))
+ (sb-introspect:function-lambda-list #',func-add-submit-s))
+ do (setf (slot-value ,component-s param) (symbol-value param)))
+ (insert-record resume-pkg ,component-s)
+ (setf (session-value :message) (format nil "~a created successfully." ,component)))
+ (error (e)
+ (setf (session-value :errormsg) (format nil "Error creating ~a. ~a" ,component e)))))))
+
+ (defun ,func-modify-s (id)
+ (with-auth (instance ,class-modify-s "resume-modify")
+ (setf (title instance) (format nil "~a - Modify" ,component))
+ (with-resume-database
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,compnent-s (get-record resume-pkg (make-instance ',component-s :id id :user_id (id user)))))
+ (if ,component-s
+ (setf (form instance) (make-form (,form-modify
+ nil
+ t
+ `((:name "id" :field-type "hidden" :value ,(id ,component-s) :required "required")
+ ,@input-form-fields
+ (:label ,(format nil "Modify ~a" ,component) :field-type "button" :onclick ,(format nil "on_~a_add_submit_clicked()" ,component-lcase)))))
+ (setf (session-value :errormsg) (format nil "Error: could not modify ~a. Not found." ,component)))))))
+
+ (defun ,func-modify-submit-s (,(append '(id) arg-names))
+ (declare (special ,(append '(id) arg-names))
+ (with-auth (instance ,class-modify-s "resume-modify")
+ (setf (title instance) (format nil "~a - Modify" ,component))
+ (with-resume-database
+ (handler-case
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,compnent-s (get-record resume-pkg (make-instance ',component-s :id id :user_id (id user)))))
+ (loop for param in (remove-if (lambda (x)
+ (intersection `(,x) '(id)))
+ (sb-introspect:function-lambda-list #',func-modify-submit-s))
+ do (setf (slot-value ,component-s param) (symbol-value param)))
+ (update-record resume-pkg ,component-s)
+ (setf (session-value :message) (format nil "~a modified successfully." ,component)))
+ (error (e)
+ (setf (session-value :errormsg) (format nil "Error modifying ~a. ~a" ,component e))))))))
+
+ (defun ,func-delete-s (id)
+ (with-auth (instance ,class-modify-s "resume-modify")
+ (with-resume-database
+ (let* ((resume-pkg (make-instance 'resume-pkg))
+ (user (get-user))
+ (,compnent-s (get-record resume-pkg (make-instance ',component-s :id id :user_id (id user)))))
+ (if ,component-s
+ (progn
+ (delete-record resume-pkg ,component-s)
+ (setf (session-value :message) (format nil "~a deleted successfully." ,componen)))
+ (setf (session-value :errormsg) (format nil "Error: could not delete ~a: not found." ,component)))))))))))
+
+(define-resume-component ('contactinfo '((address :parameter-type 'string) (city :parameter-type 'string) (state_id :parameter-type 'integer) (phone :parameter-type 'string) (email :parameter-type 'string) (visastatus_id :parameter-type 'integer)))
+ input-form-fields)