Skip to content

Commit 8274133

Browse files
authored
spi-obj: fix route bug (#765)
1 parent c44eaa0 commit 8274133

File tree

8 files changed

+38
-47
lines changed

8 files changed

+38
-47
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1+
pub mod event_persistent;
12
pub mod event_topic;
2-
pub mod event_persistent;

backend/middlewares/event/src/domain/event_persistent.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use serde::{Deserialize, Serialize};
32
use tardis::chrono::Utc;
43
use tardis::db::sea_orm::{self, DeriveEntityModel, DerivePrimaryKey, DeriveRelation, EntityName, EntityTrait, EnumIter, PrimaryKeyTrait};
@@ -41,7 +40,7 @@ impl Status {
4140
Status::Sending => "Sending",
4241
Status::Success => "Success",
4342
Status::Failed => "Failed",
44-
_ => "Unknown"
43+
_ => "Unknown",
4544
}
4645
}
4746
}
@@ -66,4 +65,4 @@ impl From<&str> for Status {
6665
_ => Status::Unknown,
6766
}
6867
}
69-
}
68+
}

backend/middlewares/event/src/serv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pub mod event_listener_serv;
2+
pub mod event_persistent_serv;
23
pub mod event_proc_serv;
34
pub mod event_topic_serv;
4-
pub mod event_persistent_serv;

backend/middlewares/schedule/tests/test_basic_schedual_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::{collections::VecDeque, env, sync::atomic::Ordering, time::Duration};
21
use bios_mw_schedule::{dto::schedule_job_dto::ScheduleJobAddOrModifyReq, schedule_config::ScheduleConfig, serv::schedule_job_serv::ScheduleTaskServ};
2+
use std::{collections::VecDeque, env, sync::atomic::Ordering, time::Duration};
33

44
use tardis::{
55
basic::result::TardisResult,

backend/spi/spi-object/src/api/ci/object_ci_obj_api.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use std::collections::HashMap;
22

3-
use itertools::Itertools;
43
use tardis::web::context_extractor::TardisContextExtractor;
54

65
use tardis::web::poem::web::Json;
76
use tardis::web::poem_openapi;
87
use tardis::web::poem_openapi::param::Query;
98
use tardis::web::web_resp::{TardisApiResult, TardisResp, Void};
109

11-
use crate::dto::object_dto::{ObjectBatchBuildCreatePresignUrlReq, ObjectCompleteMultipartUploadReq, ObjectCopyReq, ObjectInitiateMultipartUploadReq, ObjectObjPresignKind};
10+
use crate::dto::object_dto::{
11+
ObjectBatchBuildCreatePresignUrlReq, ObjectBatchDeleteReq, ObjectCompleteMultipartUploadReq, ObjectCopyReq, ObjectInitiateMultipartUploadReq, ObjectObjPresignKind,
12+
ObjectPresignBatchViewReq,
13+
};
1214
use crate::serv::object_obj_serv;
1315
#[derive(Clone)]
1416
pub struct ObjectCiObjApi;
@@ -94,18 +96,11 @@ impl ObjectCiObjApi {
9496
TardisResp::ok(url)
9597
}
9698

97-
/// Fetch URL for temporary authorization of file upload
98-
#[oai(path = "/presign/put", method = "get")]
99-
async fn batch_get_presign_obj_url(
100-
&self,
101-
object_path: Query<String>,
102-
exp_secs: Query<u32>,
103-
private: Query<Option<bool>>,
104-
special: Query<Option<bool>>,
105-
ctx: TardisContextExtractor,
106-
) -> TardisApiResult<HashMap<String, String>> {
99+
/// Batch fetch URL for temporary authorization of file
100+
#[oai(path = "/presign/batch_view", method = "get")]
101+
async fn batch_presign_view_obj_url(&self, req: Json<ObjectPresignBatchViewReq>, ctx: TardisContextExtractor) -> TardisApiResult<HashMap<String, String>> {
107102
let funs = crate::get_tardis_inst();
108-
let url = object_obj_serv::batch_get_presign_obj_url(object_path.0.split(',').collect_vec(), exp_secs.0, private.0, special.0, &funs, &ctx.0).await?;
103+
let url = object_obj_serv::batch_get_presign_obj_url(req.0.object_path, req.0.expire_sec, req.0.private, req.0.special, &funs, &ctx.0).await?;
109104
TardisResp::ok(url)
110105
}
111106

@@ -151,15 +146,9 @@ impl ObjectCiObjApi {
151146

152147
/// Deleting Objects
153148
#[oai(path = "/object/batch_delete", method = "delete")]
154-
async fn batch_object_delete(
155-
&self,
156-
object_path: Query<String>,
157-
private: Query<Option<bool>>,
158-
special: Query<Option<bool>>,
159-
ctx: TardisContextExtractor,
160-
) -> TardisApiResult<Vec<String>> {
149+
async fn batch_object_delete(&self, req: Json<ObjectBatchDeleteReq>, ctx: TardisContextExtractor) -> TardisApiResult<Vec<String>> {
161150
let funs = crate::get_tardis_inst();
162-
TardisResp::ok(object_obj_serv::batch_object_delete(object_path.0.split(',').collect_vec(), private.0, special.0, &funs, &ctx.0).await?)
151+
TardisResp::ok(object_obj_serv::batch_object_delete(req.0.object_path, req.0.private, req.0.special, &funs, &ctx.0).await?)
163152
}
164153

165154
/// Check object is exist

backend/spi/spi-object/src/dto/object_dto.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,18 @@ pub struct ObjectCopyReq {
4343
pub private: Option<bool>,
4444
pub special: Option<bool>,
4545
}
46+
47+
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
48+
pub struct ObjectBatchDeleteReq {
49+
pub object_path: Vec<String>,
50+
pub private: Option<bool>,
51+
pub special: Option<bool>,
52+
}
53+
54+
#[derive(poem_openapi::Object, Serialize, Deserialize, Debug)]
55+
pub struct ObjectPresignBatchViewReq {
56+
pub object_path: Vec<String>,
57+
pub expire_sec: u32,
58+
pub private: Option<bool>,
59+
pub special: Option<bool>,
60+
}

backend/spi/spi-object/src/serv/object_obj_serv.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,14 @@ pub async fn presign_obj_url(
2525
match inst.kind_code() {
2626
#[cfg(feature = "spi-s3")]
2727
object_constants::SPI_S3_KIND_CODE => {
28-
s3::object_s3_obj_serv::presign_obj_url(
29-
presign_kind,
30-
object_path,
31-
max_width,
32-
max_height,
33-
exp_secs,
34-
private,
35-
special,
36-
funs,
37-
ctx,
38-
&inst,
39-
)
40-
.await
28+
s3::object_s3_obj_serv::presign_obj_url(presign_kind, object_path, max_width, max_height, exp_secs, private, special, funs, ctx, &inst).await
4129
}
4230
kind_code => Err(funs.bs_not_implemented(kind_code)),
4331
}
4432
}
4533

4634
pub async fn batch_get_presign_obj_url(
47-
object_paths: Vec<&str>,
35+
object_paths: Vec<String>,
4836
exp_secs: u32,
4937
private: Option<bool>,
5038
special: Option<bool>,
@@ -112,7 +100,7 @@ pub async fn object_delete(object_path: String, private: Option<bool>, special:
112100
}
113101
}
114102

115-
pub async fn batch_object_delete(object_paths: Vec<&str>, private: Option<bool>, special: Option<bool>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<Vec<String>> {
103+
pub async fn batch_object_delete(object_paths: Vec<String>, private: Option<bool>, special: Option<bool>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<Vec<String>> {
116104
let inst = funs.init(ctx, true, object_initializer::init_fun).await?;
117105
match inst.kind_code() {
118106
#[cfg(feature = "spi-s3")]

backend/spi/spi-object/src/serv/s3/object_s3_obj_serv.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub async fn object_delete(object_path: &str, private: Option<bool>, special: Op
5454
}
5555

5656
pub async fn batch_object_delete(
57-
object_paths: Vec<&str>,
57+
object_paths: Vec<String>,
5858
private: Option<bool>,
5959
special: Option<bool>,
6060
_funs: &TardisFunsInst,
@@ -64,8 +64,8 @@ pub async fn batch_object_delete(
6464
let failed_object_paths = join_all(
6565
object_paths
6666
.into_iter()
67-
.map(|object_path| async {
68-
let result = object_delete(object_path, private, special, _funs, _ctx, inst).await;
67+
.map(|object_path| async move {
68+
let result = object_delete(&object_path, private, special, _funs, _ctx, inst).await;
6969
if result.is_err() {
7070
object_path.to_string()
7171
} else {
@@ -100,7 +100,7 @@ pub async fn object_exist(object_path: &str, private: Option<bool>, special: Opt
100100
}
101101

102102
pub async fn batch_get_presign_obj_url(
103-
object_paths: Vec<&str>,
103+
object_paths: Vec<String>,
104104
exp_secs: u32,
105105
private: Option<bool>,
106106
special: Option<bool>,
@@ -112,7 +112,7 @@ pub async fn batch_get_presign_obj_url(
112112
object_paths
113113
.into_iter()
114114
.map(|object_path| async move {
115-
let result = presign_obj_url(ObjectObjPresignKind::View, object_path, None, None, exp_secs, private, special, _funs, _ctx, inst).await;
115+
let result = presign_obj_url(ObjectObjPresignKind::View, &object_path, None, None, exp_secs, private, special, _funs, _ctx, inst).await;
116116
if let Ok(presign_obj_url) = result {
117117
(object_path.to_string(), presign_obj_url)
118118
} else {

0 commit comments

Comments
 (0)