ch some
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
2026-09-04 19:33:26 +05:00
parent 28509eb4ca
commit d1a6fcaadc
102 changed files with 2089 additions and 1957 deletions

42
internal/shared/sql.go Normal file
View File

@@ -0,0 +1,42 @@
package shared
import (
"encoding/json"
"strings"
"time"
)
const UserDisplaySQL = `COALESCE(NULLIF(TRIM(CONCAT_WS(' ', u.first_name, u.last_name)), ''), NULLIF(u.name, ''), u.username, '')`
const UserInfoSQL = UserDisplaySQL + `, COALESCE(u.username, ''), COALESCE(u.phone, ''), COALESCE(u.email, '')`
func PrefixedColumns(alias string, cols []string) string {
parts := make([]string, len(cols))
for i, col := range cols {
parts[i] = alias + "." + col
}
return strings.Join(parts, ", ")
}
func UnmarshalLocalized(raw []byte, dest *LocalizedText) error {
if len(raw) == 0 {
return nil
}
return json.Unmarshal(raw, dest)
}
func OptionalTime(t *FlexibleTime) *time.Time {
if t == nil || t.IsZero() {
return nil
}
tt := t.Time()
return &tt
}
func OptionalInt64(n *FlexibleInt64) *int64 {
if n == nil {
return nil
}
v := n.Int64()
return &v
}