@@ -35,104 +35,7 @@ ClassMethod RunSQLQuery() As %Status
35
35
return 1
36
36
}
37
37
38
- /// Retreive all the records of Sample.Person
39
- ClassMethod GetAllPersons () As %Status
40
- {
41
-
42
- #dim tSC As %Status = $$$OK
43
-
44
- Set rset = ##class (Sample.Person ).ExtentFunc ()
45
-
46
- Set %response .ContentType = ..#CONTENTTYPEJSON
47
- Write " ["
48
- if rset .%Next () {
49
- Set person = ##class (Sample.Person ).%OpenId (rset .ID )
50
- Do person .%JSONExport ()
51
- }
52
- While rset .%Next () {
53
- Write " ,"
54
- Set person = ##class (Sample.Person ).%OpenId (rset .ID )
55
- Do person .%JSONExport ()
56
- }
57
- Write " ]"
58
- Quit tSC
59
- }
60
-
61
- /// Return one record fo Sample.Person
62
- ClassMethod GetPerson (id As %Integer ) As %Status
63
- {
64
- #dim tSC As %Status = $$$OK
65
- #dim e As %Exception.AbstractException
66
-
67
-
68
- #; Set the response header to plain text
69
- Set %response .ContentType = ..#CONTENTTYPEJSON
70
-
71
- Set person = ##class (Sample.Person ).%OpenId (id )
72
-
73
- If '$IsObject (person ) Quit ..Http404 ()
74
-
75
- Do person .%JSONExport ()
76
-
77
- Quit tSC
78
- }
79
-
80
- /// Creates a new Sample.Person record
81
- ClassMethod CreatePerson () As %Status
82
- {
83
- #dim tSC As %Status = $$$OK
84
- #dim e As %Exception.AbstractException
85
- Set person = ##class (Sample.Person ).%New ()
86
- Set data =%request .Content
87
-
88
38
89
- $$$TOE(tSC ,person .%JSONImport (data ))
90
- $$$TOE(tSC ,person .%Save ())
91
-
92
- Set %response .Status = 204
93
- Set %response .ContentType = ..#CONTENTTYPEJSON
94
- //d data.%ToJSON()
95
- Do person .%JSONExport ()
96
-
97
- Quit tSC
98
- }
99
-
100
- /// Update a record in Sample.Person with id
101
- ClassMethod UpdatePerson (id As %Integer ) As %Status
102
- {
103
- #dim tSC As %Status = $$$OK
104
- #dim e As %Exception.AbstractException
105
- Set person = ##class (Sample.Person ).%OpenId (id )
106
- If '$IsObject (person ) Return ..Http404 ()
107
- Set data =%request .Content
108
-
109
- $$$TOE(tSC ,person .%JSONImport (data ))
110
- $$$TOE(tSC ,person .%Save ())
111
-
112
- Set %response .Status = 200
113
-
114
- Set %response .ContentType = ..#CONTENTTYPEJSON
115
- Do person .%JSONExport ()
116
-
117
- Quit tSC
118
- }
119
-
120
- /// Delete a record with id in Sample.Person
121
- ClassMethod DeletePerson (id As %Integer ) As %Status
122
- {
123
- #dim tSC As %Status = $$$OK
124
- #dim e As %Exception.AbstractException
125
- Set person = ##class (Sample.Person ).%OpenId (id )
126
- If '$IsObject (person ) Return ..Http404 ()
127
-
128
- $$$TOE(tSC ,person .%DeleteId (id ))
129
-
130
- Set %response .Status = 200
131
-
132
- Set %response .ContentType = ..#CONTENTTYPEJSON
133
-
134
- Quit tSC
135
- }
136
39
137
40
ClassMethod SwaggerSpec () As %Status
138
41
{
0 commit comments