fix(ws-org): enforce org-scoped lianxi relation lookups
Require current_org_id for lianxi deletion and relation traversal, and add org-scoped relation lookups to prevent cross-organization hits in daka/jihua counters. Made-with: Cursor
This commit is contained in:
@@ -2150,6 +2150,24 @@ impl JihuaCourseSection {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_by_id_in_org(
|
||||
id_search: &String,
|
||||
id_org: &String,
|
||||
conn: &mut PgConnection,
|
||||
) -> anyhow::Result<JihuaCourseSection> {
|
||||
use crate::schema::jihua_course_section::columns::*;
|
||||
use crate::schema::jihua_course_section::dsl::*;
|
||||
jihua_course_section
|
||||
.filter(id.eq(id_search).and(org_id.eq(id_org)))
|
||||
.first::<JihuaCourseSection>(conn)
|
||||
.map_err(|e| {
|
||||
anyhow!(HtyErr {
|
||||
code: HtyErrCode::DbErr,
|
||||
reason: Some(e.to_string()),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn find_first_by_course_section_id(
|
||||
id_course_section: &String,
|
||||
conn: &mut PgConnection,
|
||||
@@ -3833,6 +3851,24 @@ impl DakaCourseSection {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_by_id_in_org(
|
||||
id_search: &String,
|
||||
id_org: &String,
|
||||
conn: &mut PgConnection,
|
||||
) -> anyhow::Result<DakaCourseSection> {
|
||||
use crate::schema::daka_course_section::columns::*;
|
||||
use crate::schema::daka_course_section::dsl::*;
|
||||
daka_course_section
|
||||
.filter(id.eq(id_search).and(org_id.eq(id_org)))
|
||||
.first::<DakaCourseSection>(conn)
|
||||
.map_err(|e| {
|
||||
anyhow!(HtyErr {
|
||||
code: HtyErrCode::DbErr,
|
||||
reason: Some(e.to_string()),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn find_by_daka_id_and_course_section_id(
|
||||
id_daka: &String,
|
||||
id_course_section: &String,
|
||||
|
||||
Reference in New Issue
Block a user