ch prefix

This commit is contained in:
2026-08-18 00:59:32 +05:00
parent dbb6f7bda9
commit 25e5068c8b
2446 changed files with 393356 additions and 455 deletions

View File

@@ -4,8 +4,8 @@ listen:
port: 5050
jwt_key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpX@VCJ9.yueyJzdWIiOiIyNTEyNzMiLCJpYXQiOjE1MTYy#MzkwMjJ9.o_LoJm03CaE6!0dugdR8sjIuFgPxGT7I2W8NvugFqHRY
storage:
host: main-db
# host: localhost
# host: main-db
host: localhost
port: 5432
database: bank_db
username: bank_admin

View File

@@ -0,0 +1,132 @@
CREATE TABLE IF NOT EXISTS admin (
"id" bigserial primary key,
"login" character varying(250) NOT NULL DEFAULT '',
"password" character varying(250) NOT NULL DEFAULT '',
"fullname" character varying(250) NOT NULL DEFAULT '',
"username" character varying(250) NOT NULL DEFAULT '',
"phone_number" character varying(250) NOT NULL DEFAULT '',
"avatar" character varying(250) NOT NULL DEFAULT '',
"social_media" json NOT NULL DEFAULT '{}'::json,
"light_mode" integer DEFAULT 1 NOT NULL,
"role" character varying(250) NOT NULL DEFAULT 'user',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
INSERT INTO admin (phone_number, password, fullname, login, role)
VALUES (
'61531216',
'$2a$12$k2QqAe13wQSnblm9wPCfV.215AmK6Y7rnquoUEzL/0g6ekZ2jvR2C',
'Admin',
'admin@admin.com',
'admin'
);
-- tbbank2026
CREATE TABLE IF NOT EXISTS categories (
"id" bigserial primary key,
"name" json NOT NULL DEFAULT '{}'::json,
"status" boolean DEFAULT false NOT NULL,
"img" character varying(250) NOT NULL DEFAULT '',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS sub_categories (
"id" bigserial primary key,
"category_id" int,
"name" json NOT NULL DEFAULT '{}'::json,
"status" boolean DEFAULT false NOT NULL,
"count" integer DEFAULT 0 NOT NULL,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT sub_cat_id_fk
FOREIGN KEY ("category_id")
REFERENCES categories("id")
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS sub_categories_content (
"id" bigserial primary key,
"sub_category_id" int,
"en" TEXT NOT NULL,
"ru" TEXT NOT NULL,
"tm" TEXT NOT NULL,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT sub_categories_content_sub_category_id_key UNIQUE ("sub_category_id"),
CONSTRAINT sub_category_id_fk
FOREIGN KEY ("sub_category_id")
REFERENCES sub_categories("id")
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS banner (
"id" bigserial primary key,
"title" json NOT NULL DEFAULT '{}'::json,
"content_tm" TEXT NOT NULL DEFAULT '',
"content_ru" TEXT NOT NULL DEFAULT '',
"content_en" TEXT NOT NULL DEFAULT '',
"img" character varying(250) NOT NULL,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS setting (
"id" bigserial primary key,
"uuid" uuid NOT NULL DEFAULT gen_random_uuid() UNIQUE,
"logo_r" character varying(250) NOT NULL DEFAULT '',
"phone_number" character varying(250) NOT NULL DEFAULT '',
"fax_number" character varying(250) NOT NULL DEFAULT '',
"help_number" character varying(250) NOT NULL DEFAULT '',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
INSERT INTO setting (logo_r, phone_number, fax_number, help_number)
VALUES ('', '', '', '');
CREATE TABLE IF NOT EXISTS news (
"id" bigserial primary key,
"img" character varying(250) NOT NULL,
"title" json NOT NULL DEFAULT '{}'::json,
"date_release" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS news_content (
"id" bigserial primary key,
"news_id" int,
"en" TEXT NOT NULL,
"ru" TEXT NOT NULL,
"tm" TEXT NOT NULL,
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
CONSTRAINT news_content_news_id_key UNIQUE ("news_id"),
CONSTRAINT news_id_fk
FOREIGN KEY ("news_id")
REFERENCES news("id")
ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS static (
"id" bigserial primary key,
"logo" character varying(250) NOT NULL DEFAULT '',
"title" json NOT NULL DEFAULT '{}'::json,
"content_tm" TEXT NOT NULL DEFAULT '',
"content_ru" TEXT NOT NULL DEFAULT '',
"content_en" TEXT NOT NULL DEFAULT '',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);
CREATE TABLE IF NOT EXISTS currency (
"id" bigserial primary key,
"title" json NOT NULL DEFAULT '{}'::json,
"content_tm" TEXT NOT NULL DEFAULT '',
"content_ru" TEXT NOT NULL DEFAULT '',
"content_en" TEXT NOT NULL DEFAULT '',
"path" character varying(250) NOT NULL DEFAULT '',
"updated_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
"created_at" TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL
);

View File

@@ -0,0 +1,321 @@
#!/usr/bin/env python3
"""Convert backup_2026-08-05.sql COPY data into init.up seed INSERTs."""
from __future__ import annotations
import json
import re
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
BACKUP = ROOT / "public" / "images" / "backup_2026-08-05.sql"
OUT = Path(__file__).resolve().parent / "seed_from_backup.sql"
COPY_RE = re.compile(
r"^COPY public\.(\w+) \(([^)]+)\) FROM stdin;\n(.*?)^\\\.\n",
re.MULTILINE | re.DOTALL,
)
def copy_unescape(s: str) -> str:
"""Decode PostgreSQL COPY text-format escapes."""
out: list[str] = []
i = 0
while i < len(s):
if s[i] != "\\" or i + 1 >= len(s):
out.append(s[i])
i += 1
continue
n = s[i + 1]
if n == "\\":
out.append("\\")
i += 2
elif n == "b":
out.append("\b")
i += 2
elif n == "f":
out.append("\f")
i += 2
elif n == "n":
out.append("\n")
i += 2
elif n == "r":
out.append("\r")
i += 2
elif n == "t":
out.append("\t")
i += 2
elif n == "v":
out.append("\v")
i += 2
elif n == "x" and i + 3 < len(s):
out.append(chr(int(s[i + 2 : i + 4], 16)))
i += 4
elif n.isdigit():
j = i + 1
while j < len(s) and j < i + 4 and s[j].isdigit():
j += 1
out.append(chr(int(s[i + 1 : j], 8)))
i = j
else:
out.append(n)
i += 2
return "".join(out)
def parse_copy_rows(body: str, columns: list[str]) -> list[dict[str, str | None]]:
rows: list[dict[str, str | None]] = []
if not body.strip():
return rows
for line in body.split("\n"):
if line == "" or line == "\\.":
continue
parts = line.split("\t")
if len(parts) != len(columns):
raise SystemExit(
f"column count mismatch: expected {len(columns)}, got {len(parts)}: {line[:120]!r}"
)
row: dict[str, str | None] = {}
for col, raw in zip(columns, parts):
if raw == "\\N":
row[col] = None
else:
row[col] = copy_unescape(raw)
rows.append(row)
return rows
def load_tables(path: Path) -> dict[str, list[dict[str, str | None]]]:
text = path.read_text(encoding="utf-8")
tables: dict[str, list[dict[str, str | None]]] = {}
for m in COPY_RE.finditer(text):
name = m.group(1)
cols = [c.strip() for c in m.group(2).split(",")]
tables[name] = parse_copy_rows(m.group(3), cols)
return tables
def sql_str(value: str | None) -> str:
if value is None:
return "NULL"
tag = "s"
n = 0
while f"${tag}$" in value:
n += 1
tag = f"s{n}"
return f"${tag}${value}${tag}$"
def sql_json(value: str | None) -> str:
if not value:
return "'{}'::json"
# Normalize via json round-trip so we emit valid JSON text.
obj = json.loads(value)
dumped = json.dumps(obj, ensure_ascii=False, separators=(",", ":"))
return f"{sql_str(dumped)}::json"
def lang_parts(content: str | None) -> tuple[str, str, str]:
if not content:
return "", "", ""
obj = json.loads(content)
if not isinstance(obj, dict):
return "", "", ""
return (
str(obj.get("tm") or ""),
str(obj.get("ru") or ""),
str(obj.get("en") or ""),
)
def ts(value: str | None) -> str:
if not value:
return "DEFAULT"
# date-only → midnight
if re.fullmatch(r"\d{4}-\d{2}-\d{2}", value):
value = f"{value} 00:00:00"
return sql_str(value)
def setval(table: str) -> str:
return (
f"SELECT setval(pg_get_serial_sequence('{table}', 'id'), "
f"COALESCE((SELECT MAX(id) FROM {table}), 1));"
)
def build_seed(tables: dict[str, list[dict[str, str | None]]]) -> str:
lines: list[str] = []
lines.append("-- Auto-generated from backup_2026-08-05.sql — do not edit by hand")
lines.append("")
# ---- categories ----
cat_map: dict[str, int] = {}
cats = tables.get("categories", [])
if cats:
lines.append("-- categories")
for i, row in enumerate(cats, start=1):
uid = row["uuid"]
assert uid
cat_map[uid] = i
lines.append(
"INSERT INTO categories (id, name, status, img, updated_at, created_at) VALUES ("
f"{i}, {sql_json(row.get('name'))}, true, '', "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("categories"))
lines.append("")
# ---- sub_categories + content ----
sub_map: dict[str, int] = {}
subs = tables.get("sub_cat", [])
if subs:
lines.append("-- sub_categories")
for i, row in enumerate(subs, start=1):
uid = row["uuid"]
assert uid
sub_map[uid] = i
cat_id_uuid = row.get("cat_id")
if not cat_id_uuid or cat_id_uuid not in cat_map:
raise SystemExit(f"unknown sub_cat.cat_id={cat_id_uuid!r} for uuid={uid}")
category_id = cat_map[cat_id_uuid]
lines.append(
"INSERT INTO sub_categories (id, category_id, name, status, count, updated_at, created_at) VALUES ("
f"{i}, {category_id}, {sql_json(row.get('name'))}, true, 0, "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("sub_categories"))
lines.append("")
lines.append("-- sub_categories_content")
for i, row in enumerate(subs, start=1):
tm, ru, en = lang_parts(row.get("content"))
lines.append(
"INSERT INTO sub_categories_content (id, sub_category_id, en, ru, tm, updated_at, created_at) VALUES ("
f"{i}, {i}, {sql_str(en)}, {sql_str(ru)}, {sql_str(tm)}, "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("sub_categories_content"))
lines.append("")
# ---- banner (from sliders) ----
sliders = tables.get("sliders", [])
if sliders:
lines.append("-- banner (from sliders)")
for i, row in enumerate(sliders, start=1):
tm, ru, en = lang_parts(row.get("content"))
img = row.get("image_path") or ""
lines.append(
"INSERT INTO banner (id, title, content_tm, content_ru, content_en, img, updated_at, created_at) VALUES ("
f"{i}, {sql_json(row.get('title'))}, {sql_str(tm)}, {sql_str(ru)}, {sql_str(en)}, "
f"{sql_str(img)}, {ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("banner"))
lines.append("")
# ---- setting (replace empty seed) ----
settings = tables.get("settings", [])
if settings:
lines.append("-- setting")
for i, row in enumerate(settings, start=1):
uid = row["uuid"]
assert uid
lines.append(
"INSERT INTO setting (id, uuid, logo_r, phone_number, fax_number, help_number, updated_at, created_at) VALUES ("
f"{i}, {sql_str(uid)}::uuid, {sql_str(row.get('logo_r') or '')}, "
f"{sql_str(row.get('phone_number') or '')}, {sql_str(row.get('fax_number') or '')}, "
f"{sql_str(row.get('help_number') or '')}, "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("setting"))
lines.append("")
# ---- news + news_content ----
news_rows = tables.get("news", [])
if news_rows:
lines.append("-- news")
for i, row in enumerate(news_rows, start=1):
img = row.get("image_path") or "default.jpg"
date_raw = row.get("date") or row.get("created_at")
lines.append(
"INSERT INTO news (id, img, title, date_release, updated_at, created_at) VALUES ("
f"{i}, {sql_str(img)}, {sql_json(row.get('title'))}, "
f"{ts(date_raw)}, {ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("news"))
lines.append("")
lines.append("-- news_content")
for i, row in enumerate(news_rows, start=1):
tm, ru, en = lang_parts(row.get("content"))
lines.append(
"INSERT INTO news_content (id, news_id, en, ru, tm, updated_at, created_at) VALUES ("
f"{i}, {i}, {sql_str(en)}, {sql_str(ru)}, {sql_str(tm)}, "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("news_content"))
lines.append("")
# ---- static (from four_category) ----
four = tables.get("four_category", [])
if four:
lines.append("-- static (from four_category)")
for i, row in enumerate(four, start=1):
tm, ru, en = lang_parts(row.get("content"))
logo = row.get("image_path") or ""
lines.append(
"INSERT INTO static (id, logo, title, content_tm, content_ru, content_en, updated_at, created_at) VALUES ("
f"{i}, {sql_str(logo)}, {sql_json(row.get('title'))}, "
f"{sql_str(tm)}, {sql_str(ru)}, {sql_str(en)}, "
f"{ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("static"))
lines.append("")
# ---- currency ----
curr = tables.get("currency", [])
if curr:
lines.append("-- currency")
for i, row in enumerate(curr, start=1):
tm, ru, en = lang_parts(row.get("content"))
path = row.get("video_path") or ""
lines.append(
"INSERT INTO currency (id, title, content_tm, content_ru, content_en, path, updated_at, created_at) VALUES ("
f"{i}, {sql_json(row.get('title'))}, {sql_str(tm)}, {sql_str(ru)}, {sql_str(en)}, "
f"{sql_str(path)}, {ts(row.get('updated_at'))}, {ts(row.get('created_at'))});"
)
lines.append(setval("currency"))
lines.append("")
return "\n".join(lines)
def main() -> None:
backup = Path(sys.argv[1]) if len(sys.argv) > 1 else BACKUP
out = Path(sys.argv[2]) if len(sys.argv) > 2 else OUT
tables = load_tables(backup)
expected = {
"categories": 8,
"sub_cat": 31,
"news": 73,
"sliders": 6,
"four_category": 4,
"currency": 1,
"settings": 1,
}
for name, n in expected.items():
got = len(tables.get(name, []))
if got != n:
raise SystemExit(f"{name}: expected {n} rows, got {got}")
seed = build_seed(tables)
out.write_text(seed, encoding="utf-8")
print(f"wrote {out} ({len(seed):,} bytes)")
print(
"counts:",
{k: len(tables[k]) for k in expected},
)
if __name__ == "__main__":
main()

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
-- Update currency row with seed data
UPDATE currency
SET
content_tm = $s$<table><tbody><tr><th colspan="4" rowspan="1" colwidth="396,79,79,79"><p>Alyş-çalyş amallary üçin kesgitlenen nyrhlar (05.08.2026)</p></th></tr><tr><th colspan="2" rowspan="1" colwidth="396,79"><p>Walýutanyň belgisi</p></th><th colspan="1" rowspan="1" colwidth="79"><p>Alyş</p></th><th colspan="1" rowspan="1" colwidth="79"><p>Çalyş</p></th></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>USD</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x1</p></td><td colspan="1" rowspan="1" colwidth="79"><p>3.4913</p></td><td colspan="1" rowspan="1" colwidth="79"><p>3.5175</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>EUR</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x1</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.0185</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.0486</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>RUB</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x100</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.3103</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.3426</p></td></tr></tbody></table>$s$,
content_ru = $s$<table><tbody><tr><th colspan="4" rowspan="1" colwidth="396,74,79,79"><p>Alyş-çalyş amallary üçin kesgitlenen nyrhlar (05.08.2026)</p></th></tr><tr><th colspan="2" rowspan="1" colwidth="396,74"><p>Walýutanyň belgisi</p></th><th colspan="1" rowspan="1" colwidth="79"><p>Alyş</p></th><th colspan="1" rowspan="1" colwidth="79"><p>Çalyş</p></th></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>USD</p></td><td colspan="1" rowspan="1" colwidth="74"><p>x1</p></td><td colspan="1" rowspan="1" colwidth="79"><p>3.4913</p></td><td colspan="1" rowspan="1" colwidth="79"><p>3.5175</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>EUR</p></td><td colspan="1" rowspan="1" colwidth="74"><p>x1</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.0185</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.0486</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>RUB</p></td><td colspan="1" rowspan="1" colwidth="74"><p>x100</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.3103</p></td><td colspan="1" rowspan="1" colwidth="79"><p>4.3426</p></td></tr></tbody></table>$s$,
content_en = $s$<table><tbody><tr><th colspan="4" rowspan="1" colwidth="396,79"><p>Alyş-çalyş amallary üçin kesgitlenen nyrhlar (30.09.2023).</p></th></tr><tr><th colspan="2" rowspan="1" colwidth="396,79"><p>Walýutanyň belgisi</p></th><th colspan="1" rowspan="1"><p>Alyş</p></th><th colspan="1" rowspan="1"><p>Çalyş</p></th></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>USD</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x1</p></td><td colspan="1" rowspan="1"><p>3.4913</p></td><td colspan="1" rowspan="1"><p>3.5175</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>EUR</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x1</p></td><td colspan="1" rowspan="1"><p>3.7026</p></td><td colspan="1" rowspan="1"><p>3.7304</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="396"><p>RUB</p></td><td colspan="1" rowspan="1" colwidth="79"><p>x100</p></td><td colspan="1" rowspan="1"><p>3.5919</p></td><td colspan="1" rowspan="1"><p>3.6189</p></td></tr></tbody></table>$s$,
path = $s$/public/images/1698259964512186182.mp4$s$,
updated_at = NOW()
WHERE id = 1;

View File

@@ -0,0 +1,30 @@
# Snippet: /public → Go backend (Static serve)
# Include inside the tbbank.gov.tm server { } block, e.g.:
# include /var/www/tbbank/backend/deployment/nginx-public.conf;
#
# Or paste the location blocks into the existing site config.
# Uploaded / CMS media: /public/images/...
location /public/ {
proxy_pass http://127.0.0.1:5050;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# optional cache for static assets
proxy_cache_valid 200 1h;
expires 1h;
add_header Cache-Control "public";
}
# MinIO-backed images via backend handler (if used)
location /images/ {
proxy_pass http://127.0.0.1:5050;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

View File

@@ -0,0 +1,4 @@
time="2026-08-05T14:40:26+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-05T14:40:26+05:00" level=info func="bankline/internal/config.GetConfig.func1()" file="config.go:44"
time="2026-08-05T14:40:26+05:00" level=fatal msg="open ./config.yaml: no such file or directory" func="bankline/internal/config.GetConfig.func1()" file="config.go:45"
time="2026-08-05T14:41:20+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"

View File

@@ -0,0 +1,111 @@
package auth
import (
"bytes"
"encoding/json"
"io"
"mime/multipart"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"
"bankline/internal/config"
"github.com/gin-gonic/gin"
)
func TestFileUploadPublicImages(t *testing.T) {
gin.SetMode(gin.TestMode)
wd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
// package dir -> backend root (for config.yaml)
backendRoot := filepath.Clean(filepath.Join(wd, "..", "..", ".."))
if err := os.Chdir(backendRoot); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = os.Chdir(wd) })
tmpPublic := t.TempDir()
cfg := config.GetConfig()
prev := cfg.PublicFilePath
cfg.PublicFilePath = tmpPublic
t.Cleanup(func() { cfg.PublicFilePath = prev })
h := &handler{}
src := filepath.Join(backendRoot, "public", "images", "1698258358562790757.jpg")
img, err := os.ReadFile(src)
if err != nil {
img = []byte{
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xd9,
}
}
t.Run("ok under 10MB", func(t *testing.T) {
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Request = multipartRequest(t, "ok.jpg", img)
h.fileUpload(c)
if w.Code != http.StatusOK {
t.Fatalf("status=%d body=%s", w.Code, w.Body.String())
}
var resp struct {
Data string `json:"data"`
}
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
t.Fatal(err)
}
if resp.Data == "" || filepath.Ext(resp.Data) != ".jpg" {
t.Fatalf("unexpected data path: %q", resp.Data)
}
local := filepath.Join(tmpPublic, "images", filepath.Base(resp.Data))
if _, err := os.Stat(local); err != nil {
t.Fatalf("file not saved at %s: %v", local, err)
}
t.Logf("saved path in response: %s", resp.Data)
})
t.Run("reject over 10MB", func(t *testing.T) {
big := bytes.Repeat([]byte("a"), 10<<20+1)
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Request = multipartRequest(t, "big.jpg", big)
h.fileUpload(c)
if w.Code != http.StatusBadRequest {
t.Fatalf("expected 400, got %d body=%s", w.Code, w.Body.String())
}
t.Logf("rejected body: %s", w.Body.String())
})
}
func multipartRequest(t *testing.T, filename string, content []byte) *http.Request {
t.Helper()
var body bytes.Buffer
w := multipart.NewWriter(&body)
part, err := w.CreateFormFile("file", filename)
if err != nil {
t.Fatal(err)
}
if _, err := io.Copy(part, bytes.NewReader(content)); err != nil {
t.Fatal(err)
}
if err := w.Close(); err != nil {
t.Fatal(err)
}
req := httptest.NewRequest(http.MethodPost, "/api/v1/admin/file", &body)
req.Header.Set("Content-Type", w.FormDataContentType())
return req
}

View File

@@ -30,7 +30,7 @@ var sortColumns = map[string]string{
func (r repository) GetAllData(ctx context.Context, params listing.Params) (banner.DataBannerDTO, error) {
ns := []banner.GetBannerDTO{}
ns := []banner.BannerListItemDTO{}
var (
dt banner.DataBannerDTO
err error
@@ -40,16 +40,16 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (bann
where := ""
args := []interface{}{}
if params.Search != "" {
where = ` where title::text ILIKE $1 or content_tm ILIKE $1 or content_ru ILIKE $1 or content_en ILIKE $1 `
where = ` where title::text ILIKE $1 `
args = append(args, params.SearchPattern())
}
qC := `select count(*) from banner` + where + `;`
r.client.QueryRow(ctx, qC, args...).Scan(&dt.Count)
// List: skip content_* (large HTML). Full body is loaded via GetOneData.
q := ` select
id, title,
content_tm, content_ru, content_en,
img, created_at
from banner` +
where +
@@ -68,10 +68,9 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (bann
defer rows.Close()
for rows.Next() {
var n banner.GetBannerDTO
var n banner.BannerListItemDTO
errN := rows.Scan(
&n.Id, &n.Title,
&n.ContentTm, &n.ContentRu, &n.ContentEn,
&n.Image, &n.CreatedAt,
)
if errN != nil {

View File

@@ -3,8 +3,8 @@ package banner
import "time"
type DataBannerDTO struct {
Categories []GetBannerDTO `json:"banners"`
Count int `json:"count"`
Categories []BannerListItemDTO `json:"banners"`
Count int `json:"count"`
}
type Language struct {
@@ -13,6 +13,14 @@ type Language struct {
En string `json:"en"`
}
// BannerListItemDTO is the list payload — no content (loaded via GetOne).
type BannerListItemDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`
Image string `json:"imagePath"`
CreatedAt time.Time `json:"createdAt"`
}
type GetBannerDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`

View File

@@ -30,7 +30,7 @@ var sortColumns = map[string]string{
func (r repository) GetAllData(ctx context.Context, params listing.Params) (currency.DataCurrencyDTO, error) {
ns := []currency.CurrencyDTO{}
ns := []currency.CurrencyListItemDTO{}
var (
dt currency.DataCurrencyDTO
err error
@@ -40,16 +40,16 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (curr
where := ""
args := []interface{}{}
if params.Search != "" {
where = ` where title::text ILIKE $1 or content_tm ILIKE $1 or content_ru ILIKE $1 or content_en ILIKE $1 `
where = ` where title::text ILIKE $1 `
args = append(args, params.SearchPattern())
}
qC := `select count(*) from currency` + where + `;`
r.client.QueryRow(ctx, qC, args...).Scan(&dt.Count)
// List: skip content_* (large HTML). Full body is loaded via GetData.
q := ` select
id, title,
content_tm, content_ru, content_en,
path, created_at
from currency` +
where +
@@ -68,10 +68,9 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (curr
defer rows.Close()
for rows.Next() {
var n currency.CurrencyDTO
var n currency.CurrencyListItemDTO
errN := rows.Scan(
&n.Id, &n.Title,
&n.ContentTm, &n.ContentRu, &n.ContentEn,
&n.Path, &n.CreatedAt,
)
if errN != nil {

View File

@@ -3,8 +3,8 @@ package currency
import "time"
type DataCurrencyDTO struct {
Currencies []CurrencyDTO `json:"currencies"`
Count int `json:"count"`
Currencies []CurrencyListItemDTO `json:"currencies"`
Count int `json:"count"`
}
type Language struct {
@@ -13,6 +13,14 @@ type Language struct {
En string `json:"en"`
}
// CurrencyListItemDTO is the list payload — no content (loaded via GetData).
type CurrencyListItemDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`
Path string `json:"path"`
CreatedAt time.Time `json:"createdAt"`
}
type CurrencyDTO struct {
Id int `json:"Id"`
Title Language `json:"title"`

View File

@@ -30,7 +30,7 @@ var sortColumns = map[string]string{
func (r repository) GetAllData(ctx context.Context, params listing.Params) (static.DataStaticDTO, error) {
ns := []static.StaticDTO{}
ns := []static.StaticListItemDTO{}
var (
dt static.DataStaticDTO
err error
@@ -40,16 +40,16 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (stat
where := ""
args := []interface{}{}
if params.Search != "" {
where = ` where title::text ILIKE $1 or content_tm ILIKE $1 or content_ru ILIKE $1 or content_en ILIKE $1 `
where = ` where title::text ILIKE $1 `
args = append(args, params.SearchPattern())
}
qC := `select count(*) from static` + where + `;`
r.client.QueryRow(ctx, qC, args...).Scan(&dt.Count)
// List: skip content_* (large HTML). Full body is loaded via GetData.
q := ` select
id, logo, title,
content_tm, content_ru, content_en,
created_at
from static` +
where +
@@ -68,10 +68,9 @@ func (r repository) GetAllData(ctx context.Context, params listing.Params) (stat
defer rows.Close()
for rows.Next() {
var n static.StaticDTO
var n static.StaticListItemDTO
errN := rows.Scan(
&n.Id, &n.Logo, &n.Title,
&n.ContentTm, &n.ContentRu, &n.ContentEn,
&n.CreatedAt,
)
if errN != nil {

View File

@@ -3,8 +3,8 @@ package static
import "time"
type DataStaticDTO struct {
Statics []StaticDTO `json:"statics"`
Count int `json:"count"`
Statics []StaticListItemDTO `json:"statics"`
Count int `json:"count"`
}
type Language struct {
@@ -13,6 +13,14 @@ type Language struct {
En string `json:"en"`
}
// StaticListItemDTO is the list payload — no content (loaded via GetData).
type StaticListItemDTO struct {
Id int `json:"Id"`
Logo string `json:"logo"`
Title Language `json:"title"`
CreatedAt time.Time `json:"createdAt"`
}
type StaticDTO struct {
Id int `json:"Id"`
Logo string `json:"logo"`

View File

@@ -31,9 +31,9 @@ var resources = []Resource{
// Register mounts templates, static assets and all dashboard page routes.
func Register(router *gin.Engine) {
router.LoadHTMLGlob("web/admin/templates/**/*.html")
router.Static("/admin/assets", "./web/admin/assets")
router.Static("/M0n1t0r/assets", "./web/admin/assets")
admin := router.Group("/admin")
admin := router.Group("/M0n1t0r")
admin.GET("/login", appresult.AdminGuestOnly(), func(c *gin.Context) {
c.HTML(http.StatusOK, "pages/login", gin.H{
@@ -96,7 +96,7 @@ func Register(router *gin.Engine) {
}
router.NoRoute(func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/admin") {
if strings.HasPrefix(c.Request.URL.Path, "/M0n1t0r") {
c.HTML(http.StatusNotFound, "pages/404", gin.H{
"Title": "Page not found",
"Page": "404",

View File

View File

@@ -74,7 +74,7 @@ func AdminPageAuth() gin.HandlerFunc {
claims, ok := adminClaimsFromRequest(c)
if !ok {
ClearAuthCookies(c)
c.Redirect(http.StatusFound, "/admin/login")
c.Redirect(http.StatusFound, "/M0n1t0r/login")
c.Abort()
return
}
@@ -94,7 +94,7 @@ func AdminGuestOnly() gin.HandlerFunc {
}
c.Set("id", fmt.Sprint(claims["id"]))
c.Redirect(http.StatusFound, "/admin")
c.Redirect(http.StatusFound, "/M0n1t0r")
c.Abort()
}
}

View File

@@ -2,3 +2,25 @@ time="2026-08-04T15:11:49+05:00" level=info msg="read application configuration"
time="2026-08-04T15:12:04+05:00" level=info msg="start application" func="main.start()" file="app.go:64"
time="2026-08-04T15:13:01+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-04T15:13:16+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-06T12:17:35+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-06T12:17:35+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-06T12:17:47+05:00" level=error msg="get news :::ERROR: relation \"news\" does not exist (SQLSTATE 42P01)" func="bankline/internal/client/users/db.repository.GetNews()" file="postgresql.go:47"
time="2026-08-06T12:17:47+05:00" level=error msg="get news :::ERROR: relation \"news\" does not exist (SQLSTATE 42P01)" func="bankline/internal/client/users/db.repository.GetNews()" file="postgresql.go:47"
time="2026-08-06T12:17:47+05:00" level=error msg="get news :::ERROR: relation \"news\" does not exist (SQLSTATE 42P01)" func="bankline/internal/client/users/db.repository.GetNews()" file="postgresql.go:47"
time="2026-08-06T12:17:47+05:00" level=error msg="get categories :::ERROR: relation \"categories\" does not exist (SQLSTATE 42P01)" func="bankline/internal/client/users/db.repository.GetCategories()" file="postgresql.go:94"
time="2026-08-18T00:35:04+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:35:04+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:37:49+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:37:49+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:40:03+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:40:03+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:41:12+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:41:12+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:44:03+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:44:03+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:47:09+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:47:09+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:47:18+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:47:18+05:00" level=info msg="start application" func="main.start()" file="app.go:66"
time="2026-08-18T00:48:59+05:00" level=info msg="read application configuration" func="bankline/internal/config.GetConfig.func1()" file="config.go:40"
time="2026-08-18T00:48:59+05:00" level=info msg="start application" func="main.start()" file="app.go:66"

BIN
backend/myapp Executable file

Binary file not shown.

BIN
backend/myapp-local Executable file

Binary file not shown.

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 336 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 517 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Some files were not shown because too many files have changed in this diff Show More