@@ -17,7 +17,7 @@ use super::schema::{access, user_access};
17
17
18
18
#[ derive( Queryable , Serialize , Deserialize ) ]
19
19
pub struct Access {
20
- pub id : i64 ,
20
+ pub id : u64 ,
21
21
pub access_name : String ,
22
22
}
23
23
@@ -34,18 +34,18 @@ pub struct PartialAccess {
34
34
}
35
35
36
36
pub enum AccessRequest {
37
- GetAccess ( i64 ) , //id of access name searched
37
+ GetAccess ( u64 ) , //id of access name searched
38
38
CreateAccess ( NewAccess ) , //new access type of some name to be created
39
- UpdateAccess ( i64 , PartialAccess ) , //Contains id to be changed to new access_name
40
- DeleteAccess ( i64 ) , //if of access to be deleted
39
+ UpdateAccess ( u64 , PartialAccess ) , //Contains id to be changed to new access_name
40
+ DeleteAccess ( u64 ) , //if of access to be deleted
41
41
}
42
42
43
43
impl AccessRequest {
44
44
pub fn from_rouille ( request : & rouille:: Request ) -> Result < AccessRequest , WebdevError > {
45
45
trace ! ( "Creating AccessRequest from {:#?}" , request) ;
46
46
47
47
router ! ( request,
48
- ( GET ) ( /{ id: i64 } ) => {
48
+ ( GET ) ( /{ id: u64 } ) => {
49
49
Ok ( AccessRequest :: GetAccess ( id) )
50
50
} ,
51
51
@@ -56,14 +56,14 @@ impl AccessRequest {
56
56
Ok ( AccessRequest :: CreateAccess ( new_access) )
57
57
} ,
58
58
59
- ( POST ) ( /{ id: i64 } ) => {
59
+ ( POST ) ( /{ id: u64 } ) => {
60
60
let request_body = request. data( ) . ok_or( WebdevError :: new( WebdevErrorKind :: Format ) ) ?;
61
61
let update_access: PartialAccess = serde_json:: from_reader( request_body) ?;
62
62
63
63
Ok ( AccessRequest :: UpdateAccess ( id, update_access) )
64
64
} ,
65
65
66
- ( DELETE ) ( /{ id: i64 } ) => {
66
+ ( DELETE ) ( /{ id: u64 } ) => {
67
67
Ok ( AccessRequest :: DeleteAccess ( id) )
68
68
} ,
69
69
@@ -94,41 +94,41 @@ impl AccessResponse {
94
94
95
95
#[ derive( Queryable , Serialize , Deserialize ) ]
96
96
pub struct UserAccess {
97
- pub permission_id : i64 ,
98
- pub access_id : i64 ,
99
- pub user_id : i64 ,
97
+ pub permission_id : u64 ,
98
+ pub access_id : u64 ,
99
+ pub user_id : u64 ,
100
100
pub permission_level : Option < String > ,
101
101
}
102
102
103
103
#[ derive( Insertable , Serialize , Deserialize ) ]
104
104
#[ table_name = "user_access" ]
105
105
pub struct NewUserAccess {
106
- pub access_id : i64 ,
107
- pub user_id : i64 ,
106
+ pub access_id : u64 ,
107
+ pub user_id : u64 ,
108
108
pub permission_level : Option < String > ,
109
109
}
110
110
111
111
#[ derive( AsChangeset , Serialize , Deserialize ) ]
112
112
#[ table_name = "user_access" ]
113
113
pub struct PartialUserAccess {
114
- pub access_id : i64 ,
115
- pub user_id : i64 ,
114
+ pub access_id : u64 ,
115
+ pub user_id : u64 ,
116
116
pub permission_level : Option < Option < String > > ,
117
117
}
118
118
119
119
pub struct SearchUserAccess {
120
- pub access_id : Search < i64 > ,
121
- pub user_id : Search < i64 > ,
120
+ pub access_id : Search < u64 > ,
121
+ pub user_id : Search < u64 > ,
122
122
pub permission_level : NullableSearch < String > ,
123
123
}
124
124
125
125
pub enum UserAccessRequest {
126
126
SearchAccess ( SearchUserAccess ) , //list of users with access id or (?) name
127
- GetAccess ( i64 ) , //get individual access entry from its id
128
- CheckAccess ( i64 , i64 ) , //entry allowing user of user_id to perform action of action_id
127
+ GetAccess ( u64 ) , //get individual access entry from its id
128
+ CheckAccess ( u64 , u64 ) , //entry allowing user of user_id to perform action of action_id
129
129
CreateAccess ( NewUserAccess ) , //entry to add to database
130
- UpdateAccess ( i64 , PartialUserAccess ) , //entry to update with new information
131
- DeleteAccess ( i64 ) , //entry to delete from database
130
+ UpdateAccess ( u64 , PartialUserAccess ) , //entry to update with new information
131
+ DeleteAccess ( u64 ) , //entry to delete from database
132
132
}
133
133
134
134
impl UserAccessRequest {
@@ -160,11 +160,11 @@ impl UserAccessRequest {
160
160
} ) )
161
161
} ,
162
162
163
- ( GET ) ( /{ permission_id: i64 } ) => {
163
+ ( GET ) ( /{ permission_id: u64 } ) => {
164
164
Ok ( UserAccessRequest :: GetAccess ( permission_id) )
165
165
} ,
166
166
167
- ( GET ) ( /{ user_id: i64 } /{ access_id: i64 } ) => {
167
+ ( GET ) ( /{ user_id: u64 } /{ access_id: u64 } ) => {
168
168
Ok ( UserAccessRequest :: CheckAccess ( user_id, access_id) )
169
169
} ,
170
170
@@ -175,14 +175,14 @@ impl UserAccessRequest {
175
175
Ok ( UserAccessRequest :: CreateAccess ( new_user_access) )
176
176
} ,
177
177
178
- ( POST ) ( /{ id: i64 } ) => {
178
+ ( POST ) ( /{ id: u64 } ) => {
179
179
let request_body = request. data( ) . ok_or( WebdevError :: new( WebdevErrorKind :: Format ) ) ?;
180
180
let update_user_access: PartialUserAccess = serde_json:: from_reader( request_body) ?;
181
181
182
182
Ok ( UserAccessRequest :: UpdateAccess ( id, update_user_access) )
183
183
} ,
184
184
185
- ( DELETE ) ( /{ id: i64 } ) => {
185
+ ( DELETE ) ( /{ id: u64 } ) => {
186
186
Ok ( UserAccessRequest :: DeleteAccess ( id) )
187
187
} ,
188
188
@@ -216,9 +216,9 @@ impl UserAccessResponse {
216
216
217
217
#[ derive( Queryable , Serialize , Deserialize ) ]
218
218
pub struct JoinedUserAccess {
219
- pub permission_id : i64 ,
220
- pub user_id : i64 ,
221
- pub access_id : i64 ,
219
+ pub permission_id : u64 ,
220
+ pub user_id : u64 ,
221
+ pub access_id : u64 ,
222
222
pub first_name : String ,
223
223
pub last_name : String ,
224
224
pub banner_id : u32 ,
0 commit comments