Skip to content

Commit cbe667f

Browse files
Merge pull request #9 from NYCU-SDC/feat/CORE-47-implement-organization-unit-to-form
[CORE-47] Implement organization unit to form API
2 parents ca6088b + d26f58c commit cbe667f

24 files changed

Lines changed: 298 additions & 22 deletions

service/forms.tsp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ namespace CoreSystem.Forms {
2525
@doc("The description written in the form to show user info.")
2626
description: string;
2727

28+
@doc("The unit this form belongs to.")
29+
unitId: uuid;
30+
2831
@doc("The user who last editted the form.")
29-
lastEdit: uuid;
32+
lastEditor: uuid;
3033

3134
@doc("The creation timestamp of the form.")
3235
createdAt: utcDateTime;
@@ -83,11 +86,6 @@ namespace CoreSystem.Forms {
8386
order: int32;
8487
}
8588

86-
@doc("Create a new form.")
87-
@route("/forms")
88-
@post
89-
op createForm(@body createFormRequest: FormRequest): Form;
90-
9189
@doc("Update an existing form by its unique identifier.")
9290
@route("/forms/{id}")
9391
@put

service/unit.tsp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import "@typespec/http";
2+
import "./forms.tsp";
23

34
using Http;
5+
using CoreSystem.Forms;
46

57
@tag("Unit")
68
namespace CoreSystem.Unit {
@@ -233,4 +235,19 @@ namespace CoreSystem.Unit {
233235
@statusCode statusCode: 404;
234236
@body error: string;
235237
};
238+
239+
// --- Creation and List forms under Unit ---
240+
@doc("Create a new form under a unit.")
241+
@route("/orgs/{slug}/units/{unitId}/forms")
242+
@post
243+
op createUnitForm(
244+
@path slug: string,
245+
@path unitId: uuid,
246+
@body createFormRequest: FormRequest,
247+
): Form;
248+
249+
@doc("List forms under a specific unit.")
250+
@route("/orgs/{slug}/units/{unitId}/forms")
251+
@get
252+
op listFormsByUnit(@path slug: string, @path unitId: uuid): Form[];
236253
}

yaak/yaak.fl_HGyK8hFV8U.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: folder
2+
model: folder
3+
id: fl_HGyK8hFV8U
4+
createdAt: 2025-07-23T20:18:21.923862400
5+
updatedAt: 2025-07-23T20:56:03.390721300
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: fl_icJRbMDxsy
8+
authentication: {}
9+
authenticationType: null
10+
description: ''
11+
headers: []
12+
name: Question
13+
sortPriority: 1000.0

yaak/yaak.fl_icJRbMDxsy.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: folder
2+
model: folder
3+
id: fl_icJRbMDxsy
4+
createdAt: 2025-07-23T16:59:10.208805200
5+
updatedAt: 2025-07-23T17:26:50.610637200
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: null
8+
authentication: {}
9+
authenticationType: null
10+
description: ''
11+
headers: []
12+
name: Form
13+
sortPriority: 1000.0

yaak/yaak.fl_rVcfbAVmZh.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type: folder
2+
model: folder
3+
id: fl_rVcfbAVmZh
4+
createdAt: 2025-07-23T20:18:02.764367800
5+
updatedAt: 2025-07-23T20:56:03.368782800
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: fl_icJRbMDxsy
8+
authentication: {}
9+
authenticationType: null
10+
description: ''
11+
headers: []
12+
name: Form
13+
sortPriority: 0.0

yaak/yaak.rq_7MRwE7BTQJ.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type: http_request
22
model: http_request
33
id: rq_7MRwE7BTQJ
44
createdAt: 2025-06-28T11:59:38.605597968
5-
updatedAt: 2025-06-28T12:05:20.671769079
5+
updatedAt: 2025-07-29T15:50:18.459554300
66
workspaceId: wk_YSMg2nYXEU
77
folderId: fl_hdjW6KQpKD
88
authentication: {}
@@ -13,6 +13,6 @@ description: ''
1313
headers: []
1414
method: GET
1515
name: Me
16-
sortPriority: 1000.0
16+
sortPriority: 2000.0
1717
url: ${[ BASE_URL ]}/api/users/me
1818
urlParameters: []

yaak/yaak.rq_8C6aeTBhDC.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
type: http_request
2+
model: http_request
3+
id: rq_8C6aeTBhDC
4+
createdAt: 2025-07-23T20:54:48.664215200
5+
updatedAt: 2025-07-29T10:53:31.671429900
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: fl_HGyK8hFV8U
8+
authentication: {}
9+
authenticationType: null
10+
body:
11+
text: |-
12+
{
13+
"required":true,
14+
"type":"single_choice",
15+
"label": "Which team you want to join???",
16+
"description":"Pick one of your favorite!!!",
17+
"order":1
18+
}
19+
bodyType: application/json
20+
description: ''
21+
headers:
22+
- enabled: true
23+
name: Content-Type
24+
value: application/json
25+
id: Wv7ItTwWHN
26+
method: PUT
27+
name: Update
28+
sortPriority: 2000.0
29+
url: ${[ BASE_URL ]}/api/forms/${[ formId ]}/questions/${[ questionId ]}
30+
urlParameters: []

yaak/yaak.rq_8wYUu55Hra.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
type: http_request
2+
model: http_request
3+
id: rq_8wYUu55Hra
4+
createdAt: 2025-07-23T20:54:02.476828900
5+
updatedAt: 2025-07-29T10:53:31.657893400
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: fl_HGyK8hFV8U
8+
authentication: {}
9+
authenticationType: null
10+
body: {}
11+
bodyType: null
12+
description: ''
13+
headers: []
14+
method: GET
15+
name: List
16+
sortPriority: 1000.0
17+
url: ${[ BASE_URL ]}/api/forms/${[ formId ]}/questions
18+
urlParameters: []

yaak/yaak.rq_9ifedVPm3L.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
type: http_request
2+
model: http_request
3+
id: rq_9ifedVPm3L
4+
createdAt: 2025-07-23T20:53:11.646483700
5+
updatedAt: 2025-07-29T10:53:31.643556800
6+
workspaceId: wk_YSMg2nYXEU
7+
folderId: fl_HGyK8hFV8U
8+
authentication: {}
9+
authenticationType: null
10+
body:
11+
text: |-
12+
{
13+
"required":true,
14+
"type":"short_text",
15+
"label": "What's your name?",
16+
"description":"Please enter your name",
17+
"order":1
18+
}
19+
bodyType: application/json
20+
description: ''
21+
headers:
22+
- enabled: true
23+
name: Content-Type
24+
value: application/json
25+
id: SWFCTasA2C
26+
method: POST
27+
name: Add
28+
sortPriority: 0.0
29+
url: ${[ BASE_URL ]}/api/forms/${[ formId ]}/questions
30+
urlParameters: []

yaak/yaak.rq_GYiejw5uAA.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ type: http_request
22
model: http_request
33
id: rq_GYiejw5uAA
44
createdAt: 2025-06-28T12:00:37.500841948
5-
updatedAt: 2025-06-28T12:01:01.429112752
5+
updatedAt: 2025-07-29T15:50:18.447868700
66
workspaceId: wk_YSMg2nYXEU
77
folderId: fl_hdjW6KQpKD
88
authentication: {}
@@ -13,6 +13,6 @@ description: ''
1313
headers: []
1414
method: POST
1515
name: Refresh Token
16-
sortPriority: 999.9999
16+
sortPriority: 1000.0
1717
url: ${[ BASE_URL ]}/api/auth/refresh
1818
urlParameters: []

0 commit comments

Comments
 (0)