feat: 添加租户ID字段并重构文件上传逻辑
This commit is contained in:
@@ -385,3 +385,23 @@ func intPow10(n int) int {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// GetFileAddressPrefix 拼接图片前缀地址
|
||||
func GetFileAddressPrefix(ctx context.Context) (imageUrl string, err error) {
|
||||
// 拼接图片前缀地址
|
||||
bucketName, err := GetBucketName(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
imageUrl = fmt.Sprintf("%s/%s", g.Cfg().MustGet(ctx, "filePrefix").String(), bucketName)
|
||||
return
|
||||
}
|
||||
|
||||
func GetBucketName(ctx context.Context) (bucketName string, err error) {
|
||||
user, err := GetUserInfo(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
bucketName = fmt.Sprintf("tenantid-%d", user.TenantId)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user