save "create sync group" table in database

This commit is contained in:
2026-01-11 05:19:20 -07:00
parent a7c8fe4d64
commit 889aead6b6
28 changed files with 1396 additions and 408 deletions
+54
View File
@@ -0,0 +1,54 @@
package accounts
import (
"fmt"
"strings"
)
type (
Platform string
)
const (
Etsy Platform = "Etsy"
Tiktok Platform = "Tiktok"
Wix Platform = "Wix"
)
func NewPlatform(s string) (Platform, error) {
switch strings.ToLower(s) {
case strings.ToLower(string(Etsy)):
return Etsy, nil
case strings.ToLower(string(Tiktok)):
return Tiktok, nil
case strings.ToLower(string(Wix)):
return Wix, nil
default:
return "", fmt.Errorf("unrecognized constant: %q", s)
}
}
// sql.Scanner implementation
func (p *Platform) Scan(src any) error {
var s string
switch v := src.(type) {
case string:
s = v
case byte:
s = string(v)
default:
return fmt.Errorf("unsupported type: %T: %v", src, src)
}
dst, err := NewPlatform(s)
if err == nil {
*p = dst
}
return err
}
// sql/driver.Valuer implementation
func (p Platform) Value() (any, error) {
return string(p), nil
}