@@ -9,6 +9,7 @@ use axum::{
99} ;
1010
1111use crate :: middlewares:: ExtractAuthInfo ;
12+ use _utils:: types:: SystemUserRole ;
1213
1314/// 获取指定槽位的最新存档
1415/// GET /archive/last/{slot_index}
@@ -17,7 +18,11 @@ pub async fn get_last(
1718 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
1819 Path ( slot_index) : Path < u64 > ,
1920) -> Result < impl IntoResponse , ( StatusCode , String ) > {
20- Ok ( ( ) )
21+ if auth. info . role_id != SystemUserRole :: Admin {
22+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
23+ }
24+
25+ Ok ( Json ( ( ) ) . into_response ( ) )
2126}
2227
2328/// 获取指定槽位的所有历史存档
@@ -27,7 +32,11 @@ pub async fn get_history(
2732 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
2833 Path ( slot_index) : Path < u64 > ,
2934) -> Result < impl IntoResponse , ( StatusCode , String ) > {
30- Ok ( ( ) )
35+ if auth. info . role_id != SystemUserRole :: Admin {
36+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
37+ }
38+
39+ Ok ( Json ( ( ) ) . into_response ( ) )
3140}
3241
3342/// 获取所有槽位的历史存档
@@ -36,7 +45,11 @@ pub async fn get_history(
3645pub async fn get_all_history (
3746 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
3847) -> Result < impl IntoResponse , ( StatusCode , String ) > {
39- Ok ( ( ) )
48+ if auth. info . role_id != SystemUserRole :: Admin {
49+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
50+ }
51+
52+ Ok ( Json ( ( ) ) . into_response ( ) )
4053}
4154
4255#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
@@ -55,7 +68,11 @@ pub async fn put(
5568 Path ( ( slot_index, name) ) : Path < ( u64 , String ) > ,
5669 Json ( payload) : Json < ArchiveSaveParams > ,
5770) -> Result < impl IntoResponse , ( StatusCode , String ) > {
58- Ok ( ( ) )
71+ if auth. info . role_id != SystemUserRole :: Admin {
72+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
73+ }
74+
75+ Ok ( Json ( ( ) ) . into_response ( ) )
5976}
6077
6178/// 存档入指定槽位
@@ -66,7 +83,11 @@ pub async fn save(
6683 Path ( slot_index) : Path < u64 > ,
6784 Json ( payload) : Json < ArchiveSaveParams > ,
6885) -> Result < impl IntoResponse , ( StatusCode , String ) > {
69- Ok ( ( ) )
86+ if auth. info . role_id != SystemUserRole :: Admin {
87+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
88+ }
89+
90+ Ok ( Json ( ( ) ) . into_response ( ) )
7091}
7192
7293/// 重命名指定槽位
@@ -76,7 +97,11 @@ pub async fn rename(
7697 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
7798 Path ( ( slot_index, new_name) ) : Path < ( u64 , String ) > ,
7899) -> Result < impl IntoResponse , ( StatusCode , String ) > {
79- Ok ( ( ) )
100+ if auth. info . role_id != SystemUserRole :: Admin {
101+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
102+ }
103+
104+ Ok ( Json ( ( ) ) . into_response ( ) )
80105}
81106
82107/// 删除最近一次存档(恢复为上次存档)
@@ -86,7 +111,11 @@ pub async fn restore(
86111 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
87112 Path ( slot_index) : Path < u64 > ,
88113) -> Result < impl IntoResponse , ( StatusCode , String ) > {
89- Ok ( ( ) )
114+ if auth. info . role_id != SystemUserRole :: Admin {
115+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
116+ }
117+
118+ Ok ( Json ( ( ) ) . into_response ( ) )
90119}
91120
92121/// 删除存档槽位
@@ -96,5 +125,9 @@ pub async fn delete_slot(
96125 ExtractAuthInfo ( auth) : ExtractAuthInfo ,
97126 Path ( slot_index) : Path < u64 > ,
98127) -> Result < impl IntoResponse , ( StatusCode , String ) > {
99- Ok ( ( ) )
128+ if auth. info . role_id != SystemUserRole :: Admin {
129+ return Ok ( ( axum:: http:: StatusCode :: FORBIDDEN , "Forbidden" . to_string ( ) ) . into_response ( ) ) ;
130+ }
131+
132+ Ok ( Json ( ( ) ) . into_response ( ) )
100133}
0 commit comments