|
20 | 20 | [:blog :int] |
21 | 21 | [:hash [:maybe :string]] |
22 | 22 | [:content-type-id :int] |
23 | | - [:ts-and-cs [:maybe :int]]]} |
| 23 | + [:ts-and-cs [:maybe :int]] |
| 24 | + [:content-types [:vector |
| 25 | + [:map |
| 26 | + [:id :int] |
| 27 | + [:name :string]]]]]} |
24 | 28 | 401 {:body [:map [:message :string]]} |
25 | 29 | 403 {:body [:map [:message :string]]}}} |
26 | 30 |
|
27 | 31 | [{:keys [ds path-params] :as _request}] |
28 | | - (res/response (services/bundle ds {:id (:id path-params)}))) |
| 32 | + (let [integration (services/bundle ds {:id (:id path-params)}) |
| 33 | + content-types (services/content-types-by-bundle ds {:bundle-id (:id path-params)})] |
| 34 | + (res/response (assoc integration :content-types content-types)))) |
29 | 35 |
|
30 | 36 | (defn post |
31 | 37 | {:summary "update an integration by id" |
32 | 38 | :parameters {:path [:map [:id {:title "id" |
33 | 39 | :description "integration id"} :int]] |
34 | 40 | :body [:map |
35 | 41 | [:name :string] |
36 | | - [:content-type-id :int] |
| 42 | + [:content-types [:vector |
| 43 | + [:map |
| 44 | + [:id :int] |
| 45 | + [:name :string]]]] |
37 | 46 | [:categories [:vector |
38 | 47 | [:map |
39 | 48 | [:id :int] |
|
44 | 53 |
|
45 | 54 | [{:keys [js ds store path-params body] :as _request}] |
46 | 55 | (let [_ (services/update-bundle! ds {:id (:id path-params) |
47 | | - :data (dissoc body :categories)}) |
| 56 | + :data (dissoc body :categories :content-types)}) |
48 | 57 |
|
49 | 58 | bundle-categories (mapv (fn [{:keys [id]}] |
50 | 59 | {:bundle-id (:id path-params) |
51 | 60 | :category-id id}) (:categories body)) |
| 61 | + bundle-content-types (mapv (fn [{:keys [id]}] |
| 62 | + {:bundle-id (:id path-params) |
| 63 | + :content-type-id id}) (:content-types body)) |
| 64 | + |
52 | 65 | job-id (str "bundle_" (:id path-params)) |
53 | 66 |
|
54 | 67 | ; update bundle categories |
55 | 68 | bundle-ds (db.util/conn :bundle (:id path-params)) |
56 | 69 | _ (services/delete-bundle-category! bundle-ds {:where [:= :bundle-id (:id path-params)]}) |
57 | 70 | _ (services/insert-bundle-category! bundle-ds {:data bundle-categories}) |
58 | 71 |
|
| 72 | + ; update bundle content types |
| 73 | + _ (services/delete-bundle-content-types! ds {:where [:= :bundle-id (:id path-params)]}) |
| 74 | + _ (services/insert-bundle-content-types! ds {:data bundle-content-types}) |
| 75 | + |
59 | 76 | category-ids (services/category-id-by-bundle bundle-ds {:bundle-id (:id path-params)}) |
60 | 77 | id-vec (mapv (fn [{:keys [category-id]}] category-id) category-ids) |
61 | 78 | categories-by-bundle (services/categories ds {:where [:in :id id-vec]})] |
|
0 commit comments