Last active
December 14, 2015 18:59
-
-
Save janherich/5133388 to your computer and use it in GitHub Desktop.
Service example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deftype DbUserService [] | |
PEntityService | |
(find-entity [_ id auth] | |
(services-util/authorize-service-call | |
(authorize-find-call user-authorizator id auth) | |
(services-util/get-service-result | |
(validate-find-entity user-validator id) | |
(services-util/get-success-response | |
(handle-find-entity user-handler id))))) | |
(delete-entity [_ id auth] | |
(services-util/authorize-service-call | |
(authorize-delete-call user-authorizator id auth) | |
(services-util/get-service-result | |
(validate-delete-entity user-validator id) | |
(services-util/get-success-delete-response | |
(handle-delete-entity user-handler id))))) | |
(update-entity [_ attributes auth] | |
(services-util/authorize-service-call | |
(authorize-update-call user-authorizator attributes auth) | |
(services-util/get-service-result | |
(validate-update-entity user-validator attributes) | |
(services-util/get-success-response | |
(handle-update-entity user-handler attributes))))) | |
(add-entity [_ attributes auth] | |
(services-util/authorize-service-call | |
(authorize-add-call user-authorizator attributes auth) | |
(services-util/get-service-result | |
(validate-add-entity user-validator attributes) | |
(services-util/get-success-response | |
(handle-add-entity user-handler attributes))))) | |
(list-entities [_ criteria sort-attrs from to auth] | |
(services-util/authorize-service-call | |
(authorize-list-call user-authorizator criteria auth) | |
(services-util/get-service-result | |
(validate-list-entities user-validator criteria from to) | |
(let [criteria (restrict-list-call user-authorizator criteria auth)] | |
(-> (services-util/get-success-response | |
(handle-list-entities user-handler criteria sort-attrs from to)) | |
(services-util/assoc-range-info from to (handle-count-entities user-handler criteria)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment