schemas updated

This commit is contained in:
berkay 2025-01-13 22:55:56 +03:00
parent 50ae911d4e
commit ab76e972e3
12 changed files with 121 additions and 45 deletions

View File

@ -0,0 +1,71 @@
import datetime
class ApiStatic:
PLACEHOLDER = "https://s.tmimgcdn.com/scr/800x500/276800/building-home-nature-logo-vector-template-3_276851-original.jpg"
FORGOT_LINK = "https://www.evyos.com.tr/password/create?tokenUrl="
BLACKLIST_LINK = "https://www.evyos.com.tr/support/unknown-login-notice/"
APP_DIR = "/home/berkay/git-evyos/api-managment-backend/"
@classmethod
def forgot_link(cls, forgot_key):
return cls.FORGOT_LINK + forgot_key
@classmethod
def blacklist_login(cls, record_id):
return cls.BLACKLIST_LINK + record_id
class Auth:
ACCESS_EMAIL_EXT = "evyos.com.tr"
ACCESS_TOKEN_TAG = "evyos-session-key"
REFRESHER_TOKEN_TAG = "eys_token_refresher"
SECRET_KEY_72 = (
"t3sUAmjTGeTgDc6dAUrB41u2SNg0ZHzj4HTjem95y3fRH1nZXOHIBj163kib6iLybT0gLaxq"
)
SECRET_KEY_96 = "7ct8VpiwaP1hR2bVSet4dEEAgepuTZUOnO1QxOgKyDqBR2PkqNhcubSrbUUigQKoQA1PBoeeQn5ZCo24pESmVtKs76nA4EKq"
SECRET_KEY_144 = (
"R2p5Rq6KCr6PCfjFYUeH1keF2VWHFEuqINVjBGGnvRA2m10pYUKqfOtIGBcaj2v5wZmElDndzSHGOS7roQsoTelPSok0"
+ "qqMucurMWE0FGexGpFuJkfPEm9tH2OjMOqegvEetpSVywH0W4Kh4"
)
ALGORITHM = "HS256"
ACCESS_TOKEN_LENGTH: int = 90
REFRESHER_TOKEN_LENGTH: int = 144
PASSWORD_EXPIRE_DAY = datetime.timedelta(days=30)
TOKEN_EXPIRE_MINUTES_1 = datetime.timedelta(minutes=1)
TOKEN_EXPIRE_MINUTES_15 = datetime.timedelta(minutes=15)
TOKEN_EXPIRE_MINUTES_30 = datetime.timedelta(minutes=30)
TOKEN_EXPIRE_DAY_1 = datetime.timedelta(days=1)
TOKEN_EXPIRE_DAY_5 = datetime.timedelta(days=5)
TOKEN_EXPIRE_DAY_15 = datetime.timedelta(days=15)
TOKEN_EXPIRE_DAY_30 = datetime.timedelta(days=30)
class Routers:
NO_TOKEN_REQUIRES = [
"/",
"/metrics",
"/openapi.json",
"/docs",
"/redoc",
"/auth/login",
"/favicon.ico",
"/docs/oauth2-redirect",
"/authentication/select",
"/authentication/login",
"/authentication/logout",
"/authentication/refresher",
"/authentication/refresh",
"/authentication/disconnect",
"/authentication/create_password",
"/authentication/reset_password",
"/authentication/forgot",
"/authentication/valid",
]
NO_EVENT_REQUIRES = [
"/access/endpoints/available",
"/access/endpoint/available",
"/validations/endpoint",
"/authentication/avatar",
]

View File

@ -1,9 +1,16 @@
class HostConfig:
MAIN_HOST = "10.10.2.36" # http://10.10.2.36
EMAIL_HOST = "10.10.2.34" # http://10.10.2.34
class MainConfig:
APP_NAME = "evyos-web-api-gateway"
TITLE = "WAG API Web Api Gateway"
DESCRIPTION = "This api is serves as web api gateway only to evyos web services."
APP_URL = "https://www.wag.eys.gen.tr"
DATETIME_FORMAT = "YYYY-MM-DD HH:mm:ss Z"
DATETIME_FORMAT_JS = "YYYY-MM-DD HH:mm:ss +0"

View File

View File

@ -6,7 +6,7 @@ from sqlalchemy import String
from sqlalchemy.orm import mapped_column, Mapped
from cryptography.fernet import Fernet, MultiFernet
from databases.sql_models.core_mixin import CrudCollection
from Services.PostgresDb import CrudCollection
class CrypterEngine(CrudCollection):

View File

@ -1,5 +1,5 @@
from datetime import datetime, timedelta
from typing import List, Optional, Union
from datetime import timedelta
from typing import List, Union
from fastapi import HTTPException, status
from sqlalchemy.orm import mapped_column, relationship, Mapped
@ -16,17 +16,17 @@ from sqlalchemy import (
or_,
)
from api_library.date_time_actions.date_functions import system_arrow
from ApiLibrary.date_time_actions.date_functions import system_arrow
from Services.PostgresDb import CrudCollection
from databases.extensions.selector_classes import SelectActionWithEmployee
from api_validations.validations_request import (
from ApiValidations.Request import (
InsertBuild,
InsertBuildParts,
InsertBuildLivingSpace,
UpdateBuild,
)
from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
from databases.language_models.building.build import (
# from databases.extensions.selector_classes import SelectActionWithEmployee
# from api_objects.auth.token_objects import EmployeeTokenObject, OccupantTokenObject
from LanguageModels.Database.building.build import (
BuildTypesLanguageModel,
Part2EmployeeLanguageModel,
BuildPartsLanguageModel,
@ -246,7 +246,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
@classmethod
def create_action(cls, data: InsertBuild, token):
from databases import Addresses
from Schemas import Addresses
data_dict = data.excluded_dump()
data_dict["address_id"] = None
@ -280,7 +280,7 @@ class Build(CrudCollection, SelectActionWithEmployee):
@classmethod
def update_action(cls, data: UpdateBuild, build_uu_id: str, token):
from databases import Addresses
from Schemas import Addresses
print("data_dict", data.dump())
data_dict = data.excluded_dump()
@ -427,7 +427,7 @@ class BuildParts(CrudCollection):
@classmethod
def create_action(cls, data: InsertBuildParts, token):
from databases import ApiEnumDropdown
from Schemas import ApiEnumDropdown
data_dict = data.dump()
build_from_duty = Build.select_action(
@ -565,7 +565,7 @@ class BuildLivingSpace(CrudCollection):
data: dict,
token_dict: Union[EmployeeTokenObject, OccupantTokenObject],
):
from databases import Services, OccupantTypes
from Schemas import Services, OccupantTypes
from api_events.events.events.events_bind_modules import (
ModulesBindOccupantEventMethods,
)
@ -596,7 +596,7 @@ class BuildLivingSpace(CrudCollection):
def find_living_from_customer_id(
cls, customer_id, process_date, add_days: int = 32
):
from api_library.date_time_actions.date_functions import system_arrow
from ApiLibrary.date_time_actions.date_functions import system_arrow
formatted_date = system_arrow.get(str(process_date))
living_spaces = cls.filter_all(

View File

@ -1,6 +1,5 @@
from fastapi.exceptions import HTTPException
from databases.sql_models.core_mixin import CrudCollection
from sqlalchemy import (
String,
@ -14,19 +13,19 @@ from sqlalchemy import (
)
from sqlalchemy.orm import mapped_column, relationship, Mapped
from api_configs import RelationAccess
from databases.extensions import SelectAction
from api_validations.validations_request import (
# from databases.extensions import SelectAction
from ApiValidations.Request import (
InsertCompany,
UpdateCompany,
MatchCompany2Company,
)
from api_objects.auth.token_objects import EmployeeTokenObject
from databases.language_models.company.company import (
from LanguageModels.Database.company.company import (
RelationshipDutyCompanyLanguageModel,
CompaniesLanguageModel,
# CompanyDutiesLanguageModel,
)
from Services.PostgresDb import CrudCollection
class RelationshipDutyCompany(CrudCollection):
@ -44,7 +43,6 @@ class RelationshipDutyCompany(CrudCollection):
__tablename__ = "relationship_duty_company"
__exclude__fields__ = []
__access_by__ = RelationAccess.SuperAccessList
__language_model__ = RelationshipDutyCompanyLanguageModel
owner_id: Mapped[int] = mapped_column(
@ -75,7 +73,7 @@ class RelationshipDutyCompany(CrudCollection):
@classmethod
def match_company_to_company_commercial(cls, data: MatchCompany2Company, token):
from databases import (
from Schemas import (
Duties,
)
@ -123,7 +121,7 @@ class RelationshipDutyCompany(CrudCollection):
@classmethod
def match_company_to_company_organization(cls, data: MatchCompany2Company, token):
from databases import (
from Schemas import (
Duties,
)
@ -251,7 +249,7 @@ class Companies(CrudCollection, SelectAction):
@classmethod
def create_action(cls, data: InsertCompany, token: EmployeeTokenObject):
from databases import Addresses, Duties
from Schemas import Addresses, Duties
data_dict = data.model_dump()
if cls.filter_one(cls.tax_no == str(data.tax_no).strip(), system=True).data:
@ -298,7 +296,7 @@ class Companies(CrudCollection, SelectAction):
@classmethod
def update_action(cls, data: UpdateCompany, token):
from databases import (
from Schemas import (
Addresses,
)

View File

@ -1,7 +1,7 @@
from sqlalchemy import String, Integer, ForeignKey, Index, Boolean, Identity
from sqlalchemy.orm import mapped_column, Mapped
from databases.sql_models.core_mixin import CrudCollection
from Services.PostgresDb import CrudCollection
class Departments(CrudCollection):

View File

@ -6,15 +6,15 @@ from sqlalchemy import (
)
from sqlalchemy.orm import mapped_column, Mapped
from databases.language_models.company.employee import (
from LanguageModels.Database.company.employee import (
StaffLanguageModel,
EmployeesLanguageModel,
EmployeeHistoryLanguageModel,
EmployeesSalariesLanguageModel,
)
from databases.sql_models.core_mixin import CrudCollection
from Services.PostgresDb import CrudCollection
from api_validations.validations_request import InsertCompanyEmployees
from ApiValidations.Request import InsertCompanyEmployees
class Staff(CrudCollection):
@ -47,7 +47,7 @@ class Staff(CrudCollection):
@classmethod
def create_action(cls, data: InsertCompanyEmployees):
from databases import Duties
from Schemas import Duties
data_dict = data.model_dump()
if duty := Duties.find_one(uu_id=data.duty_uu_id):

View File

@ -1,5 +1,5 @@
from databases.sql_models.core_mixin import CrudCollection
from databases.language_models.event.event import (
from Services.PostgresDb import CrudCollection
from LanguageModels.Database.event.event import (
EventsLanguageModel,
ModulesLanguageModel,
ServicesLanguageModel,
@ -122,7 +122,7 @@ class Services(CrudCollection):
@classmethod
def retrieve_service_via_occupant_code(cls, occupant_code):
from databases import OccupantTypes
from Schemas import OccupantTypes
occupant_type = OccupantTypes.filter_by_one(
system=True,

View File

@ -16,13 +16,14 @@ from sqlalchemy import (
)
from sqlalchemy.orm import mapped_column, relationship, Mapped
from api_library.date_time_actions.date_functions import system_arrow
from api_configs import Auth, ApiStatic, RelationAccess
from databases.sql_models.core_mixin import CrudCollection
from databases.extensions import SelectAction, SelectActionWithEmployee
from databases.extensions.auth import UserLoginModule
from api_validations.validations_request import InsertUsers, InsertPerson
from databases.language_models.identity.identity import (
from ApiLibrary.date_time_actions.date_functions import system_arrow
from AllConfigs.Token.config import Auth, ApiStatic
from Services.PostgresDb import CrudCollection
# from databases.extensions import SelectAction, SelectActionWithEmployee
# from databases.extensions.auth import UserLoginModule
from ApiValidations.Request import InsertUsers, InsertPerson
from LanguageModels.Database.identity.identity import (
UsersTokensLanguageModel,
UsersLanguageModel,
PeopleLanguageModel,
@ -197,7 +198,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
}
def get_employee_and_duty_details(self):
from databases import Employees, Duties
from Schemas import Employees, Duties
found_person = People.filter_one(
People.id == self.person_id,
@ -234,7 +235,7 @@ class Users(CrudCollection, UserLoginModule, SelectAction):
}
def get_main_domain_and_other_domains(self, get_main_domain: bool = True):
from databases import MongoQueryIdentity
from Schemas import MongoQueryIdentity
query_engine = MongoQueryIdentity(company_uuid=self.related_company)
domain_via_user = query_engine.get_domain_via_user(user_uu_id=str(self.uu_id))
@ -253,7 +254,6 @@ class RelationshipDutyPeople(CrudCollection):
__tablename__ = "relationship_duty_people"
__exclude__fields__ = []
__access_by__ = RelationAccess.SuperAccessList
__language_model__ = RelationshipDutyPeopleLanguageModel
company_id: Mapped[int] = mapped_column(
@ -374,7 +374,7 @@ class People(CrudCollection, SelectAction):
@classmethod
def create_action(cls, data: InsertPerson, token):
from databases import Duties
from Schemas import Duties
token_duties_id, token_company_id = (
token.selected_company.duty_id,

View File

@ -9,7 +9,7 @@ from sqlalchemy.orm import (
Mapped,
mapped_column,
)
from databases.sql_models.core_mixin import CrudCollection
from Services.PostgresDb import CrudCollection
class ApiEnumDropdown(CrudCollection):

View File

@ -1,8 +1,8 @@
from sqlalchemy import String
from sqlalchemy.orm import mapped_column, Mapped
from databases.language_models.rules.rules import EndpointRestrictionLanguageModel
from databases.sql_models.core_mixin import CrudCollection
from LanguageModels.Database.rules.rules import EndpointRestrictionLanguageModel
from Services.PostgresDb import CrudCollection
class EndpointRestriction(CrudCollection):