TODO 各种格式
This commit is contained in:
@@ -13,8 +13,22 @@ const (
|
||||
TypeS3KeyGuest TypeFormatS3KeyName = 2 // 游客
|
||||
)
|
||||
|
||||
type TypeCategory string
|
||||
|
||||
const TCategoryPersonalization TypeCategory = "personalization"
|
||||
const TCategory3DTools TypeCategory = "3dtools"
|
||||
const TCategoryQuotation TypeCategory = "quotation"
|
||||
const TCategoryRenderMegre TypeCategory = "render_megre"
|
||||
|
||||
var CategoryMap = map[string]bool{
|
||||
string(TCategoryPersonalization): true,
|
||||
string(TCategory3DTools): true,
|
||||
string(TCategoryQuotation): true,
|
||||
string(TCategoryRenderMegre): true,
|
||||
}
|
||||
|
||||
// FormatS3KeyName 需要输入选
|
||||
func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env, category, name string) string {
|
||||
func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||
if keytype == TypeS3KeyUser {
|
||||
return FormatS3KeyNameUser(uid, now, env, category, name)
|
||||
} else if keytype == TypeS3KeyGuest {
|
||||
@@ -25,7 +39,7 @@ func FormatS3KeyName(keytype TypeFormatS3KeyName, uid int64, now time.Time, env,
|
||||
}
|
||||
|
||||
// FormatS3KeyNameUser
|
||||
func FormatS3KeyNameUser(userid int64, now time.Time, env, category, name string) string {
|
||||
func FormatS3KeyNameUser(userid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||
year, month, _ := now.Date()
|
||||
names := strings.Split(name, ".")
|
||||
var ext string
|
||||
@@ -35,11 +49,17 @@ func FormatS3KeyNameUser(userid int64, now time.Time, env, category, name string
|
||||
name = names[0]
|
||||
ext = names[1]
|
||||
}
|
||||
|
||||
switch category {
|
||||
case TCategoryPersonalization:
|
||||
// TODO:
|
||||
}
|
||||
|
||||
return fmt.Sprintf("/%s/%s/%d/%04d%02d/%s_%d.%s", env, category, userid, year, int(month), name, now.Unix(), ext)
|
||||
}
|
||||
|
||||
// FormatS3KeyNameGuest 游客的格式化存储
|
||||
func FormatS3KeyNameGuest(guestid int64, now time.Time, env, category, name string) string {
|
||||
func FormatS3KeyNameGuest(guestid int64, now time.Time, env string, category TypeCategory, name string) string {
|
||||
year, month, _ := now.Date()
|
||||
names := strings.Split(name, ".")
|
||||
var ext string
|
||||
|
||||
Reference in New Issue
Block a user