File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,13 @@ pub fn api_router(cfg: &mut web::ServiceConfig) {
58
58
)
59
59
. service (
60
60
scope ( "/product" )
61
- . service (
61
+ . route ( "/list" , post ( ) . to ( product_list) )
62
+ . route ( "/info/{uid}" , get ( ) . to ( product_info) )
63
+ . route ( "/down/{uid}" , get ( ) . to ( product_download) ) . service (
62
64
scope ( "/{owner}/{repo}" )
63
65
. route ( "/post" , post ( ) . to ( product_post) )
64
66
)
65
- . route ( "/list" , post ( ) . to ( product_list) )
66
- . route ( "/info/{uid}" , get ( ) . to ( product_info) )
67
- . route ( "/down/{uid}" , get ( ) . to ( product_download) )
67
+
68
68
)
69
69
70
70
;
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ use crate::services::AppState;
6
6
impl AppState {
7
7
pub async fn product_data_download_zip ( & self , product : Uuid ) -> io:: Result < actix_files:: NamedFile > {
8
8
let product = self . product_info ( product) . await ?;
9
- let repo = self . repo_get_by_uid ( product. repository_uid ) . await ?;
10
- let hash = product. hash ;
9
+ let repo = self . repo_get_by_uid ( product. data . repository_uid ) . await ?;
10
+ let hash = product. data . hash ;
11
11
let path = format ! ( "{}/{}/{}/" , GIT_ROOT , repo. node_uid, repo. uid) ;
12
12
let zip_path = format ! ( "{}/product/{}.zip" , path, hash) ;
13
13
if std:: fs:: metadata ( & zip_path) . is_err ( ) {
Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ use sea_orm::EntityTrait;
3
3
use uuid:: Uuid ;
4
4
use crate :: model:: product:: data_product;
5
5
use crate :: services:: AppState ;
6
+ use crate :: services:: product:: list:: ProductList ;
6
7
7
8
impl AppState {
8
- pub async fn product_info ( & self , uid : Uuid ) -> io:: Result < data_product :: Model > {
9
- data_product:: Entity :: find_by_id ( uid)
9
+ pub async fn product_info ( & self , uid : Uuid ) -> io:: Result < ProductList > {
10
+ let data = data_product:: Entity :: find_by_id ( uid)
10
11
. one ( & self . read )
11
12
. await
12
13
. map_err ( |e| io:: Error :: new ( io:: ErrorKind :: Other , e. to_string ( ) ) ) ?
13
- . ok_or_else ( || io:: Error :: new ( io:: ErrorKind :: NotFound , "Product not found" ) )
14
+ . ok_or_else ( || io:: Error :: new ( io:: ErrorKind :: NotFound , "Product not found" ) ) ?;
15
+ Ok ( ProductList {
16
+ data : data. clone ( ) ,
17
+ owner : self . user_info_by_uid ( data. owner ) . await ?,
18
+ repo : self . repo_get_by_uid ( data. repository_uid ) . await ?,
19
+ } )
14
20
}
15
21
}
You can’t perform that action at this time.
0 commit comments