Compare commits

..

No commits in common. "18841ea58abdce86444fbf7db3dd537e4549f5b3" and "dd736bc927a20800724b40a0b3a8cfdd3ece640f" have entirely different histories.

4 changed files with 15 additions and 105 deletions

View File

@ -13,5 +13,6 @@ COPY --from=build /app/web /app/web
COPY --from=build /app/server/config.test.yaml /app/server/config.test.yaml COPY --from=build /app/server/config.test.yaml /app/server/config.test.yaml
COPY --from=build /app/server/config.prod.yaml /app/server/config.prod.yaml COPY --from=build /app/server/config.prod.yaml /app/server/config.prod.yaml
RUN mkdir -p /app/storage/export RUN mkdir -p /app/storage/export
ENV APP_ENV=prod
EXPOSE 8077 EXPOSE 8077
ENTRYPOINT ["/app/bin/marketing-data-server"] ENTRYPOINT ["/app/bin/marketing-data-server"]

File diff suppressed because one or more lines are too long

View File

@ -5,6 +5,7 @@ import (
"marketing-system-data-tool/server/internal/api" "marketing-system-data-tool/server/internal/api"
"marketing-system-data-tool/server/internal/config" "marketing-system-data-tool/server/internal/config"
"marketing-system-data-tool/server/internal/db" "marketing-system-data-tool/server/internal/db"
"marketing-system-data-tool/server/internal/migrate"
"marketing-system-data-tool/server/internal/logging" "marketing-system-data-tool/server/internal/logging"
"net/http" "net/http"
"time" "time"
@ -13,7 +14,6 @@ import (
func main() { func main() {
cfg := config.Load() cfg := config.Load()
log.Println("APP_ENV:", os.Getenv("APP_ENV"))
if cfg.YMTKeyDecryptKeyB64 != "" { os.Setenv("YMT_KEY_DECRYPT_KEY_B64", cfg.YMTKeyDecryptKeyB64) } if cfg.YMTKeyDecryptKeyB64 != "" { os.Setenv("YMT_KEY_DECRYPT_KEY_B64", cfg.YMTKeyDecryptKeyB64) }
_ = logging.Init("log") _ = logging.Init("log")
log.Println("connecting YMT MySQL:", cfg.YMTDB.Host+":"+cfg.YMTDB.Port, "db", cfg.YMTDB.Name, "user", cfg.YMTDB.User) log.Println("connecting YMT MySQL:", cfg.YMTDB.Host+":"+cfg.YMTDB.Port, "db", cfg.YMTDB.Name, "user", cfg.YMTDB.User)
@ -32,8 +32,14 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
_ = ymt if cfg.YMTDB.DSN() != "" {
r := api.NewRouter(ymt, marketing) if err := migrate.Apply(ymt); err != nil {
log.Fatal(err)
}
} else {
log.Println("skip migrations: YMT DSN missing")
}
r := api.NewRouter(ymt, marketing)
addr := ":" + func() string { addr := ":" + func() string {
s := cfg.Port s := cfg.Port
if s == "" { if s == "" {

View File

@ -61,8 +61,10 @@ func ExportsHandler(meta, marketing *sql.DB) http.Handler {
}) })
} }
// owner_id 列在只读库不做运行时变更,避免 ALTER TABLE 触发错误 func (a *ExportsAPI) ensureOwnerColumn() {
func (a *ExportsAPI) ensureOwnerColumn() {} // Try to add owner_id column if not exists; ignore errors
_, _ = a.meta.Exec("ALTER TABLE export_jobs ADD COLUMN owner_id BIGINT UNSIGNED NOT NULL DEFAULT 0")
}
type ExportPayload struct { type ExportPayload struct {
TemplateID uint64 `json:"template_id"` TemplateID uint64 `json:"template_id"`
@ -945,6 +947,7 @@ func toString(v interface{}) string {
} }
} }
func (a *ExportsAPI) list(w http.ResponseWriter, r *http.Request) { func (a *ExportsAPI) list(w http.ResponseWriter, r *http.Request) {
a.ensureOwnerColumn()
q := r.URL.Query() q := r.URL.Query()
page := 1 page := 1
size := 15 size := 15