|
|
@@ -46,7 +46,7 @@ def _row_to_dict_cell_product_type(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_cell_product_types(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
+def list_cell_product_types(db, *, page=1, page_size=10, keyword=None, tenant_no=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizCellProductType).filter(BizCellProductType.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -60,6 +60,9 @@ def list_cell_product_types(db, *, page=1, page_size=10, keyword=None, tenant_no
|
|
|
BizCellProductType.product_type_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizCellProductType, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizCellProductType.id)).scalar() or 0
|
|
|
@@ -158,7 +161,7 @@ def _row_to_dict_cell_product_spec(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_cell_product_specs(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
+def list_cell_product_specs(db, *, page=1, page_size=10, keyword=None, tenant_no=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizCellProductSpec).filter(BizCellProductSpec.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -172,6 +175,9 @@ def list_cell_product_specs(db, *, page=1, page_size=10, keyword=None, tenant_no
|
|
|
BizCellProductSpec.spec_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizCellProductSpec, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizCellProductSpec.id)).scalar() or 0
|
|
|
@@ -276,7 +282,7 @@ def _row_to_dict_cell_product_price(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_cell_product_prices(db, *, page=1, page_size=10, keyword=None, tenant_no=None, cell_product_type_id=None):
|
|
|
+def list_cell_product_prices(db, *, page=1, page_size=10, keyword=None, tenant_no=None, cell_product_type_id=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizCellProductPrice).filter(BizCellProductPrice.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -293,6 +299,9 @@ def list_cell_product_prices(db, *, page=1, page_size=10, keyword=None, tenant_n
|
|
|
BizCellProductPrice.cell_type_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizCellProductPrice, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizCellProductPrice.id)).scalar() or 0
|
|
|
@@ -441,7 +450,7 @@ def _row_to_dict_project_system(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_project_systems(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
+def list_project_systems(db, *, page=1, page_size=10, keyword=None, tenant_no=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizCellProductProjectSystem).filter(BizCellProductProjectSystem.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -455,6 +464,9 @@ def list_project_systems(db, *, page=1, page_size=10, keyword=None, tenant_no=No
|
|
|
BizCellProductProjectSystem.system_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizCellProductProjectSystem, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizCellProductProjectSystem.id)).scalar() or 0
|
|
|
@@ -566,7 +578,7 @@ def _row_to_dict_project_system_item(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_project_system_items(db, project_system_id, tenant_no=None):
|
|
|
+def list_project_system_items(db, project_system_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizCellProductProjectSystemItem).filter(
|
|
|
and_(
|
|
|
BizCellProductProjectSystemItem.project_system_id == project_system_id,
|
|
|
@@ -575,6 +587,9 @@ def list_project_system_items(db, project_system_id, tenant_no=None):
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizCellProductProjectSystemItem.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizCellProductProjectSystemItem, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizCellProductProjectSystemItem.create_time.desc()).all()
|
|
|
return [_row_to_dict_project_system_item(x) for x in rows]
|
|
|
|
|
|
@@ -723,7 +738,7 @@ def _row_to_dict_channel(
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_channels(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
+def list_channels(db, *, page=1, page_size=10, keyword=None, tenant_no=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizChannel).filter(BizChannel.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -738,6 +753,9 @@ def list_channels(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
BizChannel.contact_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizChannel, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizChannel.id)).scalar() or 0
|
|
|
@@ -870,7 +888,7 @@ def _row_to_dict_channel_invoice(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_channel_invoices(db, channel_id, tenant_no=None):
|
|
|
+def list_channel_invoices(db, channel_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizChannelInvoice).filter(
|
|
|
and_(
|
|
|
BizChannelInvoice.channel_id == channel_id,
|
|
|
@@ -879,6 +897,9 @@ def list_channel_invoices(db, channel_id, tenant_no=None):
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizChannelInvoice.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizChannelInvoice, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizChannelInvoice.create_time.desc()).all()
|
|
|
return [_row_to_dict_channel_invoice(x) for x in rows]
|
|
|
|
|
|
@@ -1003,7 +1024,7 @@ def _row_to_dict_channel_mail_address(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_channel_mail_addresses(db, channel_id, tenant_no=None):
|
|
|
+def list_channel_mail_addresses(db, channel_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizChannelMailAddress).filter(
|
|
|
and_(
|
|
|
BizChannelMailAddress.channel_id == channel_id,
|
|
|
@@ -1012,6 +1033,9 @@ def list_channel_mail_addresses(db, channel_id, tenant_no=None):
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizChannelMailAddress.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizChannelMailAddress, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizChannelMailAddress.create_time.desc()).all()
|
|
|
return [_row_to_dict_channel_mail_address(x) for x in rows]
|
|
|
|
|
|
@@ -1131,7 +1155,7 @@ def _row_to_dict_channel_agreement(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_channel_agreements(db, channel_id, tenant_no=None):
|
|
|
+def list_channel_agreements(db, channel_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizChannelAgreement).filter(
|
|
|
and_(
|
|
|
BizChannelAgreement.channel_id == channel_id,
|
|
|
@@ -1140,6 +1164,9 @@ def list_channel_agreements(db, channel_id, tenant_no=None):
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizChannelAgreement.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizChannelAgreement, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizChannelAgreement.create_time.desc()).all()
|
|
|
return [_row_to_dict_channel_agreement(x) for x in rows]
|
|
|
|
|
|
@@ -1366,7 +1393,7 @@ def _channel_agreement_price_exists(
|
|
|
return False
|
|
|
|
|
|
|
|
|
-def list_channel_agreement_prices(db, channel_agreement_id, tenant_no=None):
|
|
|
+def list_channel_agreement_prices(db, channel_agreement_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizChannelAgreementProductPrice).filter(
|
|
|
and_(
|
|
|
BizChannelAgreementProductPrice.channel_agreement_id == channel_agreement_id,
|
|
|
@@ -1375,6 +1402,9 @@ def list_channel_agreement_prices(db, channel_agreement_id, tenant_no=None):
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizChannelAgreementProductPrice.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizChannelAgreementProductPrice, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizChannelAgreementProductPrice.create_time.desc()).all()
|
|
|
return [_row_to_dict_channel_agreement_price(x) for x in rows]
|
|
|
|
|
|
@@ -1533,7 +1563,7 @@ def _row_to_dict_checkup_institution(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_checkup_institutions(db, *, page=1, page_size=10, keyword=None, tenant_no=None):
|
|
|
+def list_checkup_institutions(db, *, page=1, page_size=10, keyword=None, tenant_no=None, user_info=None):
|
|
|
def _filtered():
|
|
|
q0 = db.query(BizCheckupInstitution).filter(BizCheckupInstitution.del_flag == 0)
|
|
|
if tenant_no:
|
|
|
@@ -1547,6 +1577,9 @@ def list_checkup_institutions(db, *, page=1, page_size=10, keyword=None, tenant_
|
|
|
BizCheckupInstitution.contact_name.like(like),
|
|
|
)
|
|
|
)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q0 = apply_data_scope(q0, BizCheckupInstitution, user_info, db, tenant_no)
|
|
|
return q0
|
|
|
|
|
|
total = _filtered().order_by(None).with_entities(func.count(BizCheckupInstitution.id)).scalar() or 0
|
|
|
@@ -1671,7 +1704,7 @@ def _row_to_dict_checkup_institution_invoice(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_checkup_institution_invoices(db, checkup_institution_id, tenant_no=None):
|
|
|
+def list_checkup_institution_invoices(db, checkup_institution_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizCheckupInstitutionInvoice).filter(
|
|
|
and_(
|
|
|
BizCheckupInstitutionInvoice.checkup_institution_id == checkup_institution_id,
|
|
|
@@ -1680,6 +1713,9 @@ def list_checkup_institution_invoices(db, checkup_institution_id, tenant_no=None
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizCheckupInstitutionInvoice.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizCheckupInstitutionInvoice, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizCheckupInstitutionInvoice.create_time.desc()).all()
|
|
|
return [_row_to_dict_checkup_institution_invoice(x) for x in rows]
|
|
|
|
|
|
@@ -1804,7 +1840,7 @@ def _row_to_dict_checkup_institution_project(row) -> Dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def list_checkup_institution_projects(db, checkup_institution_id, tenant_no=None):
|
|
|
+def list_checkup_institution_projects(db, checkup_institution_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizCheckupInstitutionProject).filter(
|
|
|
and_(
|
|
|
BizCheckupInstitutionProject.checkup_institution_id == checkup_institution_id,
|
|
|
@@ -1813,6 +1849,9 @@ def list_checkup_institution_projects(db, checkup_institution_id, tenant_no=None
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizCheckupInstitutionProject.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizCheckupInstitutionProject, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizCheckupInstitutionProject.create_time.desc()).all()
|
|
|
return [_row_to_dict_checkup_institution_project(x) for x in rows]
|
|
|
|
|
|
@@ -2084,7 +2123,7 @@ def _insert_package_items(
|
|
|
db.add(obj)
|
|
|
|
|
|
|
|
|
-def list_checkup_institution_packages(db, checkup_institution_id, tenant_no=None):
|
|
|
+def list_checkup_institution_packages(db, checkup_institution_id, tenant_no=None, user_info=None):
|
|
|
q = db.query(BizCheckupInstitutionPackage).filter(
|
|
|
and_(
|
|
|
BizCheckupInstitutionPackage.checkup_institution_id == checkup_institution_id,
|
|
|
@@ -2093,6 +2132,9 @@ def list_checkup_institution_packages(db, checkup_institution_id, tenant_no=None
|
|
|
)
|
|
|
if tenant_no:
|
|
|
q = q.filter(BizCheckupInstitutionPackage.tenant_no == tenant_no)
|
|
|
+ if user_info:
|
|
|
+ from app.core.data_scope import apply_data_scope
|
|
|
+ q = apply_data_scope(q, BizCheckupInstitutionPackage, user_info, db, tenant_no)
|
|
|
rows = q.order_by(BizCheckupInstitutionPackage.create_time.desc()).all()
|
|
|
out = []
|
|
|
for row in rows:
|