初始化项目
This commit is contained in:
39
customerserver/consts/account/platform.go
Normal file
39
customerserver/consts/account/platform.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package account
|
||||
|
||||
import "github.com/gogf/gf/v2/util/gconv"
|
||||
|
||||
var (
|
||||
PlatformXHS = newPlatform(gconv.PtrString("xiaohongshu"), "小红书")
|
||||
PlatformDY = newPlatform(gconv.PtrString("douyin"), "抖音")
|
||||
PlatformKS = newPlatform(gconv.PtrString("kuaishou"), "快手")
|
||||
)
|
||||
|
||||
type Platform *string
|
||||
|
||||
type platform struct {
|
||||
code Platform
|
||||
desc string
|
||||
}
|
||||
|
||||
func (s platform) Code() Platform {
|
||||
return s.code
|
||||
}
|
||||
func (s platform) Desc() string {
|
||||
return s.desc
|
||||
}
|
||||
|
||||
func newPlatform(code Platform, desc string) platform {
|
||||
return platform{code: code, desc: desc}
|
||||
}
|
||||
|
||||
func GetDescByCode(code Platform) string {
|
||||
switch *code {
|
||||
case *PlatformXHS.Code():
|
||||
return PlatformXHS.Desc()
|
||||
case *PlatformDY.Code():
|
||||
return PlatformDY.Desc()
|
||||
case *PlatformKS.Code():
|
||||
return PlatformKS.Desc()
|
||||
}
|
||||
return "未知平台"
|
||||
}
|
||||
26
customerserver/consts/account/status.go
Normal file
26
customerserver/consts/account/status.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package account
|
||||
|
||||
import "github.com/gogf/gf/v2/util/gconv"
|
||||
|
||||
var (
|
||||
StatusDisable = newStatus(gconv.PtrInt8(0), "disable")
|
||||
StatusEnable = newStatus(gconv.PtrInt8(1), "enable")
|
||||
)
|
||||
|
||||
type Status *int8
|
||||
|
||||
type status struct {
|
||||
code Status
|
||||
desc string
|
||||
}
|
||||
|
||||
func (s status) Code() Status {
|
||||
return s.code
|
||||
}
|
||||
func (s status) Desc() string {
|
||||
return s.desc
|
||||
}
|
||||
|
||||
func newStatus(code Status, desc string) status {
|
||||
return status{code: code, desc: desc}
|
||||
}
|
||||
Reference in New Issue
Block a user