from pydantic import BaseModel from typing import Optional import datetime from pymysql import NULL SECRET_KEY = "df2f77bd544240801a048bd4293afd8eeb7fff3cb7050e42c791db4b83ebadcd" ALGORITHM = "HS256" class Token(BaseModel): access_token: str token_type: str class del_user(BaseModel): access_token: str del_name: str class User(BaseModel): id: int username: str password: str changPwdTime: Optional[datetime.datetime] = None isAdmin: Optional[bool] = None isEnable: Optional[bool] = True updateTime: Optional[datetime.datetime] = None token: Optional[str] = None class user_authority(BaseModel): ai_prediction_isView : int ai_prediction_isAdd : int ai_prediction_isEdit : int ai_prediction_isDel : int channel_isView : int channel_isAdd : int channel_isEdit : int channel_isDel : int device_isView : int device_isAdd : int device_isEdit : int device_isDel : int event_isView : int event_isAdd : int event_isEdit : int event_isDel : int index_isView : int index_isAdd : int index_isEdit : int index_isDel : int performance_isView : int performance_isAdd : int performance_isEdit : int performance_isDel : int record_isView : int record_isAdd : int record_isEdit : int record_isDel : int setting_device_isView : int setting_device_isAdd : int setting_device_isEdit : int setting_device_isDel : int setting_system_isView : int setting_system_isAdd : int setting_system_isEdit : int setting_system_isDel : int tower_isView : int tower_isAdd : int tower_isEdit : int tower_isDel : int ai_prediction_id:int channel_id:int device_id:int event_id:int index_id:int performance_id:int record_id:int setting_device_id:int setting_system_id:int tower_id:int role_id:str access_token: str def get_acl_from_module_name(self,module_name:str): result = {} exec("result['id'] = self.{}".format(module_name+'_id')) exec("result['isView'] = self.{}".format(module_name+'_isView')) exec("result['isAdd'] = self.{}".format(module_name+'_isAdd')) exec("result['isEdit'] = self.{}".format(module_name+'_isEdit')) exec("result['isDel'] = self.{}".format(module_name+'_isDel')) result["role_id"]= self.role_id result["module_id"]= module_name print(result) return result # AuthJWT setting class Settings(BaseModel): authjwt_secret_key: str = SECRET_KEY authjwt_token_location: set = {"cookies"} authjwt_cookie_secure: bool = False authjwt_cookie_csrf_protect: bool = True