-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
6,971 additions
and
2,213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from bisheng.api.errcode.base import BaseErrorCode | ||
|
||
|
||
# 标签模块相关的返回错误码,功能模块代码:107 | ||
class TagExistError(BaseErrorCode): | ||
Code: int = 10700 | ||
Msg: str = '标签已存在' | ||
|
||
|
||
class TagNotExistError(BaseErrorCode): | ||
Code: int = 10700 | ||
Msg: str = '未找到对应的标签' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from bisheng.cache import InMemoryCache | ||
from bisheng.cache.redis import redis_client | ||
from bisheng.utils.minio_client import MinioClient | ||
|
||
|
||
class BaseService: | ||
|
||
LogoMemoryCache = InMemoryCache(max_size=200, expiration_time=3600 * 24) | ||
|
||
@classmethod | ||
def get_logo_share_link(cls, logo_path: str): | ||
if not logo_path: | ||
return '' | ||
cache_key = f'logo_cache:{logo_path}' | ||
# 先从内存中获取 | ||
share_url = cls.LogoMemoryCache.get(cache_key) | ||
if share_url: | ||
return share_url | ||
|
||
# 再从redis缓存中获取 | ||
share_url = redis_client.get(cache_key) | ||
if share_url: | ||
cls.LogoMemoryCache.set(cache_key, share_url) | ||
return share_url | ||
|
||
minio_client = MinioClient() | ||
share_url = minio_client.get_share_link(logo_path) | ||
# 缓存5天, 临时链接有效期为7天 | ||
redis_client.set(cache_key, share_url, 3600 * 120) | ||
cls.LogoMemoryCache.set(cache_key, share_url) | ||
return share_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.