Skip to content

Commit

Permalink
Update singleton pattern class typing
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-clan committed Nov 8, 2024
1 parent 0cfeeb4 commit fc3848e
Show file tree
Hide file tree
Showing 25 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion backend/app/admin/service/api_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ async def delete(*, pk: list[int]) -> int:
return count


api_service = ApiService()
api_service: ApiService = ApiService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/auth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ async def logout(*, request: Request, response: Response) -> None:
await redis_client.delete_prefix(key_prefix)


auth_service = AuthService()
auth_service: AuthService = AuthService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/casbin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ async def delete_all_groups(*, uuid: UUID) -> int:
return count


casbin_service = CasbinService()
casbin_service: CasbinService = CasbinService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/config_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ async def delete(*, pk: list[int]) -> int:
return count


config_service = ConfigService()
config_service: ConfigService = ConfigService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/dept_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ async def delete(*, pk: int) -> int:
return count


dept_service = DeptService()
dept_service: DeptService = DeptService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/dict_data_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ async def delete(*, pk: list[int]) -> int:
return count


dict_data_service = DictDataService()
dict_data_service: DictDataService = DictDataService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/dict_type_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ async def delete(*, pk: list[int]) -> int:
return count


dict_type_service = DictTypeService()
dict_type_service: DictTypeService = DictTypeService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/login_log_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ async def delete_all() -> int:
return count


login_log_service = LoginLogService()
login_log_service: LoginLogService = LoginLogService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/menu_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ async def delete(*, pk: int) -> int:
return count


menu_service = MenuService()
menu_service: MenuService = MenuService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/oauth2_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ async def create_with_login(
return data


oauth2_service = OAuth2Service()
oauth2_service: OAuth2Service = OAuth2Service()
2 changes: 1 addition & 1 deletion backend/app/admin/service/opera_log_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ async def delete_all() -> int:
return count


opera_log_service = OperaLogService()
opera_log_service: OperaLogService = OperaLogService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/role_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ async def delete(*, pk: list[int]) -> int:
return count


role_service = RoleService()
role_service: RoleService = RoleService()
2 changes: 1 addition & 1 deletion backend/app/admin/service/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ async def delete(*, username: str) -> int:
return count


user_service = UserService()
user_service: UserService = UserService()
2 changes: 1 addition & 1 deletion backend/app/generator/service/gen_business_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ async def delete(*, pk: int) -> int:
return count


gen_business_service = GenBusinessService()
gen_business_service: GenBusinessService = GenBusinessService()
2 changes: 1 addition & 1 deletion backend/app/generator/service/gen_model_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ async def delete(*, pk: int) -> int:
return count


gen_model_service = GenModelService()
gen_model_service: GenModelService = GenModelService()
2 changes: 1 addition & 1 deletion backend/app/generator/service/gen_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ async def download(self, *, pk: int) -> io.BytesIO:
return bio


gen_service = GenService()
gen_service: GenService = GenService()
2 changes: 1 addition & 1 deletion backend/app/task/service/task_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def run(*, name: str, args: list | None = None, kwargs: dict | None = None):
return task


task_service = TaskService()
task_service: TaskService = TaskService()
2 changes: 1 addition & 1 deletion backend/common/response/response_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ def fast_success(
return MsgSpecJSONResponse({'code': res.code, 'msg': res.msg, 'data': data})


response_base = ResponseBase()
response_base: ResponseBase = ResponseBase()
2 changes: 1 addition & 1 deletion backend/common/security/rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ async def rbac_verify(self, request: Request, _token: str = DependsJwtAuth) -> N
raise AuthorizationError


rbac = RBAC()
rbac: RBAC = RBAC()
# RBAC 授权依赖注入
DependsRBAC = Depends(rbac.rbac_verify)
4 changes: 2 additions & 2 deletions backend/database/db_redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ async def delete_prefix(self, prefix: str, exclude: str | list = None):
await self.delete(*keys)


# 创建 redis 客户端实例
redis_client = RedisCli()
# 创建 redis 客户端单例
redis_client: RedisCli = RedisCli()
2 changes: 1 addition & 1 deletion backend/templates/py/service.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ class {{ table_name_class }}Service:
return count


{{ table_name_en }}_service = {{ table_name_class }}Service()
{{ table_name_en }}_service: {{ table_name_class }}Service = {{ table_name_class }}Service()
2 changes: 1 addition & 1 deletion backend/utils/gen_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ def get_vars(business: GenBusiness, models: list[GenModel]) -> dict:
}


gen_template = GenTemplate()
gen_template: GenTemplate = GenTemplate()
2 changes: 1 addition & 1 deletion backend/utils/redis_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ async def get_stats():
return stats_list


redis_info = RedisInfo()
redis_info: RedisInfo = RedisInfo()
2 changes: 1 addition & 1 deletion backend/utils/server_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ def get_service_info():
}


server_info = ServerInfo()
server_info: ServerInfo = ServerInfo()
2 changes: 1 addition & 1 deletion backend/utils/timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def f_utc(dt: datetime) -> datetime:
return dt.astimezone(datetime_timezone.utc)


timezone = TimeZone()
timezone: TimeZone = TimeZone()

0 comments on commit fc3848e

Please sign in to comment.