@@ -45,7 +45,40 @@ pub async fn create(
45
45
46
46
debug ! ( "New Agreement: {:?}" , agreement) ;
47
47
48
- Ok ( Json ( ApiResponse :: new ( StatusCode :: CREATED . into ( ) , agreement) ) )
48
+ Ok ( Json ( ApiResponse :: new (
49
+ StatusCode :: CREATED . into ( ) ,
50
+ agreement,
51
+ ) ) )
52
+ }
53
+
54
+ /// GET a particular Agreement specified by its id.
55
+ #[ utoipa:: path(
56
+ get,
57
+ path = "/agreements/{id}" ,
58
+ params(
59
+ ApiVersion ,
60
+ ( "id" = String , Path , description = "Agreement id to retrieve" )
61
+ ) ,
62
+ responses(
63
+ ( status = 200 , description = "Successfully retrieved a specific Agreement by its id" , body = [ entity:: notes:: Model ] ) ,
64
+ ( status = 401 , description = "Unauthorized" ) ,
65
+ ( status = 404 , description = "Note not found" ) ,
66
+ ( status = 405 , description = "Method not allowed" )
67
+ ) ,
68
+ security(
69
+ ( "cookie_auth" = [ ] )
70
+ )
71
+ ) ]
72
+ pub async fn read (
73
+ CompareApiVersion ( _v) : CompareApiVersion ,
74
+ State ( app_state) : State < AppState > ,
75
+ Path ( id) : Path < Id > ,
76
+ ) -> Result < impl IntoResponse , Error > {
77
+ debug ! ( "GET Agreement by id: {}" , id) ;
78
+
79
+ let note: Option < Model > = AgreementApi :: find_by_id ( app_state. db_conn_ref ( ) , id) . await ?;
80
+
81
+ Ok ( Json ( ApiResponse :: new ( StatusCode :: OK . into ( ) , note) ) )
49
82
}
50
83
51
84
#[ utoipa:: path(
@@ -114,8 +147,5 @@ pub async fn index(
114
147
115
148
debug ! ( "Found Agreements: {:?}" , agreements) ;
116
149
117
- Ok ( Json ( ApiResponse :: new (
118
- StatusCode :: OK . into ( ) ,
119
- agreements,
120
- ) ) )
150
+ Ok ( Json ( ApiResponse :: new ( StatusCode :: OK . into ( ) , agreements) ) )
121
151
}
0 commit comments