Compare commits
205 Commits
72ac41cac0
...
is_oem
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
754bf2fe01 | ||
|
|
2ca07f03ce | ||
| 84b4c70ffb | |||
|
|
2fd9472db1 | ||
| 66df535317 | |||
|
|
e0a86febc4 | ||
|
|
40154ec861 | ||
|
|
bb507036db | ||
| 80a1314dc0 | |||
|
|
100a9f57d4 | ||
| 773e7d3c20 | |||
| 03a0e5ea64 | |||
| ce8c19f715 | |||
| 4edcb0a852 | |||
| a4120dafa2 | |||
| 5e1a8e898c | |||
|
|
c610ce38cc | ||
| 8e3e41d6fe | |||
| b33da9d072 | |||
|
|
604247b7c8 | ||
| e5988a85f3 | |||
|
|
0cb5cc47bb | ||
|
|
1efc5417be | ||
|
|
a0c3dd8ec8 | ||
| ab783b599d | |||
| d173af29fe | |||
| f14d60d67b | |||
| 967b101f9b | |||
| 97ca510b99 | |||
| 26cbdeec0a | |||
|
|
ce4cadaa16 | ||
|
|
7f05d39b38 | ||
| 83b7cd49dd | |||
|
|
88255776f3 | ||
| 38cb07f3d4 | |||
|
|
1f6d5ecb72 | ||
| 2e61cde742 | |||
|
|
d4d55e2757 | ||
| 54608410ea | |||
|
|
80d26bba12 | ||
|
|
33e9d016e9 | ||
|
|
a03a2b461f | ||
|
|
134bc4ea53 | ||
|
|
8595969c6e | ||
|
|
a6aa06faa0 | ||
|
|
4f4b32b131 | ||
|
|
dfdf8b4db9 | ||
|
|
438a13c04c | ||
| 8024d9f739 | |||
|
|
c5832c0cf5 | ||
|
|
61ccd32c4a | ||
|
|
f7f56c2928 | ||
|
|
0a5ce5d9c2 | ||
|
|
f1f5daa82b | ||
|
|
393de36cb2 | ||
| 9fb8e034fc | |||
|
|
1083ab7a61 | ||
| 75af44b0df | |||
| 75997ab15b | |||
|
|
569a805a13 | ||
|
|
578d8c6cac | ||
|
|
cbd0baaa50 | ||
|
|
7eee0bd032 | ||
| 92ba9c5f07 | |||
| a121ddc246 | |||
| d56650ae5d | |||
| 1a6311dc3d | |||
| 2e645f3368 | |||
| de3f2d1777 | |||
| 9187297367 | |||
| 813d1f4879 | |||
| c5cc4f7a48 | |||
| 76ca2a2eed | |||
| 84388792f0 | |||
|
|
7264a11ba6 | ||
| 61dc240c38 | |||
|
|
f6b321b602 | ||
|
|
af91842b14 | ||
| 04e238fd66 | |||
|
|
e0c53c97ba | ||
| 09a77c14c9 | |||
|
|
c7533a8deb | ||
|
|
1bab7f642f | ||
|
|
a988bbbc33 | ||
| 701004d005 | |||
| c31964c41b | |||
| 0ed9d792b6 | |||
|
|
395d670298 | ||
|
|
7d4242abb1 | ||
|
|
9c7eb5ee4e | ||
|
|
833f4a5a07 | ||
|
|
b9bc121d43 | ||
|
|
b2acb8c922 | ||
| cf4d14a3cb | |||
| 30eb82ba53 | |||
| a2a2c35ab3 | |||
|
|
03f04b2f53 | ||
|
|
55da953f32 | ||
| 684f910090 | |||
| 5feaa9e15c | |||
|
|
04e2549a66 | ||
| 6428ddb527 | |||
| fb4f7048ab | |||
|
|
a3f01eca7c | ||
|
|
1fa6206b75 | ||
|
|
fa89723eb6 | ||
|
|
8665c566ee | ||
| ec5ff123ac | |||
| 17317e778c | |||
| 94291ccc03 | |||
| 91c5de1f67 | |||
|
|
d0ce65c287 | ||
| 05bfa6e8b8 | |||
| 68f4850445 | |||
| 9ec329b1d6 | |||
| f4ad8e02b4 | |||
| ec05101037 | |||
| 29260080c2 | |||
| 9336cdfa28 | |||
| bd97ed1a3b | |||
| 396e25b750 | |||
| df14eb5ae4 | |||
| 3246ef4fb7 | |||
| 21bea39e46 | |||
| 94cb8123d5 | |||
| 30c1278254 | |||
| c09e525736 | |||
| f5d524d45b | |||
| 78bdac8ff0 | |||
| ca27cbea1c | |||
| af2b276599 | |||
| 7c5a993623 | |||
| 96383fce06 | |||
| e7a7daa2e3 | |||
| 8f37ecbac2 | |||
|
|
d38095f912 | ||
|
|
f81eb84499 | ||
| 7be02d1b6c | |||
| 5d1abafdd3 | |||
| 0c448c05c9 | |||
| 2c128a4b36 | |||
| e279899e49 | |||
| e7adddb927 | |||
| 62aaa23164 | |||
| 0f21ed1f81 | |||
| c13365916c | |||
| a96efacb3e | |||
| 9ed1106ff4 | |||
| fb2bc94a42 | |||
| e570297011 | |||
| bb1cdee3f4 | |||
|
|
d6fa655c21 | ||
|
|
defdfc7b06 | ||
|
|
c464c02301 | ||
| bdaf00ce45 | |||
| 73cc936d56 | |||
| 3b80fa6dbe | |||
| f773eed2d2 | |||
| 7de369e46a | |||
| 0cee3e5cb7 | |||
| 78b32cbd9c | |||
|
|
04538d4373 | ||
| 32a651064e | |||
|
|
bfc488bad8 | ||
|
|
f5f23f8a27 | ||
| d0c1f49d3e | |||
| cffe4c2f83 | |||
| 15e8626280 | |||
|
|
528f12b065 | ||
| 508418523f | |||
| 0853424c4e | |||
| 12e9e49f9b | |||
|
|
25ad592be3 | ||
| a984d2ac0d | |||
|
|
26e6a3c384 | ||
| a4c1773415 | |||
| 8e07daac66 | |||
| 6408b93e5c | |||
| 27fa88b076 | |||
| f60d1bb6de | |||
|
|
b67c4e3aef | ||
| 95b73b9836 | |||
|
|
0d29d8f6a2 | ||
|
|
884e15bb8a | ||
| 99fe11fbeb | |||
| dd806bbb1e | |||
|
|
1ea50af96a | ||
|
|
b6bf6ed5c6 | ||
| 7a66d6f429 | |||
| 43f856ee8d | |||
| 506c64e240 | |||
| 718b4d23f1 | |||
| 22e8556c9d | |||
|
|
52c17d7017 | ||
|
|
e094865fc7 | ||
|
|
01c8f4333f | ||
|
|
6cebcacb5d | ||
| c79e08dbb8 | |||
| 789d59b0c9 | |||
| 7388d0f828 | |||
|
|
a0dcb56fda | ||
| e30088209e | |||
|
|
0da596826e | ||
|
|
7aa16c644f | ||
| 56a1495a0b |
23
.env
23
.env
@@ -21,16 +21,22 @@ AUTH_JWT_SECRET=5c020e6ed3d8d6e67e5804d67c83c4bd5ae474df749af6d63d8f20e7e2ba29b3
|
||||
AUTH_JWT_EXPIRATION=86400
|
||||
AUTH_REFRESH_EXPIRATION=604800
|
||||
|
||||
# Meili search
|
||||
MEILISEARCH_URL=http://localhost:7700
|
||||
MEILISEARCH_API_KEY=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
|
||||
# OpenAI
|
||||
OPENAI_KEY=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
|
||||
|
||||
# Google Translate Client
|
||||
# Path to your service account JSON key file downloaded from Google Cloud Console
|
||||
GOOGLE_APPLICATION_CREDENTIALS=/home/daniel/coding/work/b2b/google-cred.json
|
||||
# Your Google Cloud project ID (visible in the Google Cloud Console dashboard)
|
||||
GOOGLE_CLOUD_PROJECT_ID=YOUR_PROJECT_ID
|
||||
GOOGLE_APPLICATION_CREDENTIALS=./google-cred.json
|
||||
GOOGLE_CLOUD_PROJECT_ID=translation-343517
|
||||
|
||||
# Google OAuth2
|
||||
OAUTH_GOOGLE_CLIENT_ID=331979954218-9vrpe08oqhhcgj6bvu6d4lds0dt630m9.apps.googleusercontent.com
|
||||
OAUTH_GOOGLE_CLIENT_SECRET=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
|
||||
OAUTH_GOOGLE_REDIRECT_URL=http://localhost:3000/api/v1/public/auth/google/callback
|
||||
|
||||
# Email Configuration (SMTP)
|
||||
# Set EMAIL_ENABLED=true to require email verification
|
||||
EMAIL_ENABLED=true
|
||||
@@ -42,6 +48,10 @@ EMAIL_FROM=test@ma-al.com
|
||||
EMAIL_FROM_NAME=Gitea Manager
|
||||
EMAIL_ADMIN=goc_marek@ma-al.pl
|
||||
|
||||
# STORAGE
|
||||
STORAGE_ROOT=./storage
|
||||
|
||||
|
||||
I18N_LANGS=en,pl,cs
|
||||
|
||||
PDF_SERVER_URL=http://localhost:8000
|
||||
@@ -49,3 +59,8 @@ PDF_SERVER_URL=http://localhost:8000
|
||||
|
||||
FILE_MAAL_PL_USER=git_operator
|
||||
FILE_MAAL_PL_PASSWORD=1FnwqcEgIUjQHjt1
|
||||
|
||||
IMAGE_PREFIX=https://www.naluconcept.com # remove prefix to serv them from same host as presta
|
||||
CORS_ORGIN=https://www.naluconcept.com
|
||||
|
||||
DSN=root:Maal12345678@tcp(localhost:3306)/nalu
|
||||
59
.env_example
Normal file
59
.env_example
Normal file
@@ -0,0 +1,59 @@
|
||||
SERVER_PORT=3000
|
||||
SERVER_HOST=0.0.0.0
|
||||
|
||||
# Database Configuration
|
||||
DB_HOST=localhost
|
||||
DB_PORT=3306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=Maal12345678
|
||||
DB_NAME=nalu
|
||||
PROJECT_NAME=nalu_b2b
|
||||
DB_SERVICE_NAME=nalu_b2b
|
||||
DB_SSLMODE=disable
|
||||
|
||||
# App COnfig
|
||||
APP_NAME="B2b Management System"
|
||||
APP_VERSION=2.1.0
|
||||
APP_ENVIRONMENT=development
|
||||
|
||||
# JWT Configuration
|
||||
AUTH_JWT_SECRET=5c020e6ed3d8d6e67e5804d67c83c4bd5ae474df749af6d63d8f20e7e2ba29b3
|
||||
AUTH_JWT_EXPIRATION=86400
|
||||
AUTH_REFRESH_EXPIRATION=604800
|
||||
|
||||
# Meili search
|
||||
MEILISEARCH_URL=http://localhost:7700
|
||||
MEILISEARCH_API_KEY=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||
|
||||
# OpenAI
|
||||
OPENAI_KEY=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
|
||||
|
||||
# Google Translate Client
|
||||
GOOGLE_APPLICATION_CREDENTIALS=./google-cred.json
|
||||
GOOGLE_CLOUD_PROJECT_ID=translation-343517
|
||||
|
||||
# Google OAuth2
|
||||
OAUTH_GOOGLE_CLIENT_ID=331979954218-9vrpe08oqhhcgj6bvu6d4lds0dt630m9.apps.googleusercontent.com
|
||||
OAUTH_GOOGLE_CLIENT_SECRET=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
|
||||
OAUTH_GOOGLE_REDIRECT_URL=http://localhost:3000/api/v1/public/auth/google/callback
|
||||
|
||||
# Email Configuration (SMTP)
|
||||
# Set EMAIL_ENABLED=true to require email verification
|
||||
EMAIL_ENABLED=true
|
||||
EMAIL_SMTP_HOST=mail.ma-al.com
|
||||
EMAIL_SMTP_PORT=587
|
||||
EMAIL_SMTP_USER=test@ma-al.com
|
||||
EMAIL_SMTP_PASSWORD=maal12345678
|
||||
EMAIL_FROM=test@ma-al.com
|
||||
EMAIL_FROM_NAME=Gitea Manager
|
||||
EMAIL_ADMIN=goc_marek@ma-al.pl
|
||||
|
||||
I18N_LANGS=en,pl,cs
|
||||
|
||||
PDF_SERVER_URL=http://localhost:8000
|
||||
|
||||
|
||||
FILE_MAAL_PL_USER=git_operator
|
||||
FILE_MAAL_PL_PASSWORD=1FnwqcEgIUjQHjt1
|
||||
|
||||
IMAGE_PREFIX=https://www.naluconcept.com # remove prefix to serv them from same host as presta
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -4,3 +4,7 @@ assets/public/dist
|
||||
bin/
|
||||
i18n/*.json
|
||||
*_templ.go
|
||||
tmp/main
|
||||
test.go
|
||||
storage/*
|
||||
!storage/.gitkeep
|
||||
14
.vscode/launch.json
vendored
Normal file
14
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "./app/cmd/main.go",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"envFile": "${workspaceFolder}/.env"
|
||||
}
|
||||
]
|
||||
}
|
||||
16
Taskfile.yml
16
Taskfile.yml
@@ -72,11 +72,23 @@ vars:
|
||||
MP_SMTP_AUTH_ACCEPT_ANY: true
|
||||
MP_SMTP_AUTH_ALLOW_INSECURE: true
|
||||
MP_ENABLE_SPAMASSASSIN: postmark
|
||||
MP_VERBOSE: true
|
||||
MP_VERBOSE: true
|
||||
meilisearch:
|
||||
image: getmeili/meilisearch:latest
|
||||
container_name: meilisearch
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 7700:7700
|
||||
volumes:
|
||||
- meilisearch:/data.ms
|
||||
environment:
|
||||
MEILI_MASTER_KEY: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
mailpit_data:
|
||||
mailpit_data:
|
||||
meilisearch:
|
||||
|
||||
|
||||
includes:
|
||||
|
||||
1656
app/api/openapi.json
1656
app/api/openapi.json
File diff suppressed because it is too large
Load Diff
25
app/cmd/cmds/genModels.go
Normal file
25
app/cmd/cmds/genModels.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package cmds
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/db"
|
||||
genmodels "git.ma-al.com/goc_daniel/b2b/app/utils/genModels"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var generateModelsCmd = &cobra.Command{
|
||||
Use: "genmodels",
|
||||
Short: "generate input database models",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer cancel()
|
||||
|
||||
err := genmodels.New(db.Get()).GormGenModels(ctx)
|
||||
if err != nil {
|
||||
slog.Error("Error performing work: " + err.Error())
|
||||
}
|
||||
},
|
||||
}
|
||||
60
app/cmd/cmds/startServer.go
Normal file
60
app/cmd/cmds/startServer.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package cmds
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/langsService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "b2b",
|
||||
Short: "This is set of tools for b2b application",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if versionFlag, _ := cmd.Flags().GetBool("version"); versionFlag {
|
||||
log.Println(version.String())
|
||||
return
|
||||
}
|
||||
|
||||
// Create and setup the server
|
||||
server := web.New()
|
||||
|
||||
// Configure routes
|
||||
if err := server.Setup(); err != nil {
|
||||
log.Fatalf("Failed to setup server: %v", err)
|
||||
}
|
||||
|
||||
// Load translations on startup
|
||||
if err := langsService.LangSrv.LoadTranslations(); err != nil {
|
||||
log.Printf("Warning: Failed to load translations on startup: %v", err)
|
||||
} else {
|
||||
log.Println("Translations loaded successfully on startup")
|
||||
}
|
||||
|
||||
// Start the server
|
||||
if err := server.Run(); err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func Execute() error {
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.Flags().BoolP("version", "v", false, "show version and exit")
|
||||
rootCmd.AddCommand(generateModelsCmd)
|
||||
}
|
||||
@@ -1,41 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/langsService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/version"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/cmd/cmds"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Check for version subcommand
|
||||
versionFlag := flag.Bool("version", false, "Show version information")
|
||||
flag.Parse()
|
||||
|
||||
if *versionFlag {
|
||||
log.Println(version.String())
|
||||
return
|
||||
}
|
||||
|
||||
// Create and setup the server
|
||||
server := web.New()
|
||||
|
||||
// Configure routes
|
||||
if err := server.Setup(); err != nil {
|
||||
log.Fatalf("Failed to setup server: %v", err)
|
||||
}
|
||||
|
||||
// Load translations on startup
|
||||
if err := langsService.LangSrv.LoadTranslations(); err != nil {
|
||||
log.Printf("Warning: Failed to load translations on startup: %v", err)
|
||||
} else {
|
||||
log.Println("Translations loaded successfully on startup")
|
||||
}
|
||||
|
||||
// Start the server
|
||||
if err := server.Run(); err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
cmds.Execute()
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -22,6 +24,10 @@ type Config struct {
|
||||
I18n I18n
|
||||
Pdf PdfPrinter
|
||||
GoogleTranslate GoogleTranslateConfig
|
||||
Image ImageConfig
|
||||
Cors CorsConfig
|
||||
MeiliSearch MeiliSearchConfig
|
||||
Storage StorageConfig
|
||||
}
|
||||
|
||||
type I18n struct {
|
||||
@@ -32,6 +38,19 @@ type ServerConfig struct {
|
||||
Host string `env:"SERVER_HOST,0.0.0.0"`
|
||||
}
|
||||
|
||||
type CorsConfig struct {
|
||||
Origins []string `env:"CORS_ORGIN"`
|
||||
}
|
||||
|
||||
type MeiliSearchConfig struct {
|
||||
ServerURL string `env:"MEILISEARCH_URL"`
|
||||
ApiKey string `env:"MEILISEARCH_API_KEY"`
|
||||
}
|
||||
|
||||
type ImageConfig struct {
|
||||
ImagePrefix string `env:"IMAGE_PREFIX"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Host string `env:"DB_HOST,localhost"`
|
||||
Port int `env:"DB_PORT"`
|
||||
@@ -79,6 +98,10 @@ type EmailConfig struct {
|
||||
Enabled bool `env:"EMAIL_ENABLED,false"`
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
RootFolder string `env:"STORAGE_ROOT"`
|
||||
}
|
||||
|
||||
type PdfPrinter struct {
|
||||
ServerUrl string `env:"PDF_SERVER_URL,http://localhost:8000"`
|
||||
}
|
||||
@@ -139,7 +162,7 @@ func load() *Config {
|
||||
|
||||
err = loadEnv(&cfg.OAuth.Google)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for outh google : ", err.Error(), "")
|
||||
slog.Error("not possible to load env variables for oauth google : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.App)
|
||||
@@ -154,12 +177,12 @@ func load() *Config {
|
||||
|
||||
err = loadEnv(&cfg.I18n)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for email : ", err.Error(), "")
|
||||
slog.Error("not possible to load env variables for i18n : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.Pdf)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for email : ", err.Error(), "")
|
||||
slog.Error("not possible to load env variables for pdf : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.GoogleTranslate)
|
||||
@@ -167,6 +190,27 @@ func load() *Config {
|
||||
slog.Error("not possible to load env variables for google translate : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.Image)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for image : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.Cors)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for cors : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.MeiliSearch)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for meili search : ", err.Error(), "")
|
||||
}
|
||||
|
||||
err = loadEnv(&cfg.Storage)
|
||||
if err != nil {
|
||||
slog.Error("not possible to load env variables for storage : ", err.Error(), "")
|
||||
}
|
||||
cfg.Storage.RootFolder = ResolveRelativePath(cfg.Storage.RootFolder)
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
@@ -277,6 +321,22 @@ func setValue(field reflect.Value, val string, key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func ResolveRelativePath(relativePath string) string {
|
||||
// get working directory (where program was started)
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// convert to absolute path
|
||||
absPath := relativePath
|
||||
if !filepath.IsAbs(absPath) {
|
||||
absPath = filepath.Join(wd, absPath)
|
||||
}
|
||||
|
||||
return filepath.Clean(absPath)
|
||||
}
|
||||
|
||||
func parseEnvTag(tag string) (key string, def *string) {
|
||||
if tag == "" {
|
||||
return "", nil
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
|
||||
extraClausePlugin "github.com/WinterYukky/gorm-extra-clause-plugin"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
@@ -52,7 +53,10 @@ func newMySQLDB(cfg *config.DatabaseConfig) (*gorm.DB, error) {
|
||||
sqlDB.SetConnMaxLifetime(cfg.ConnMaxLifetime)
|
||||
|
||||
log.Println("✓ Database connection established successfully")
|
||||
|
||||
err = db.Use(extraClausePlugin.New())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return db, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/authService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// AuthMiddleware creates authentication middleware
|
||||
func AuthMiddleware() fiber.Handler {
|
||||
func Authenticate() fiber.Handler {
|
||||
authService := authService.NewAuthService()
|
||||
|
||||
return func(c fiber.Ctx) error {
|
||||
// Get token from Authorization header
|
||||
authHeader := c.Get("Authorization")
|
||||
@@ -21,17 +26,13 @@ func AuthMiddleware() fiber.Handler {
|
||||
// Try to get from cookie
|
||||
authHeader = c.Cookies("access_token")
|
||||
if authHeader == "" {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "authorization token required",
|
||||
})
|
||||
return c.Next()
|
||||
}
|
||||
} else {
|
||||
// Extract token from "Bearer <token>"
|
||||
parts := strings.Split(authHeader, " ")
|
||||
if len(parts) != 2 || parts[0] != "Bearer" {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "invalid authorization header format",
|
||||
})
|
||||
return c.Next()
|
||||
}
|
||||
authHeader = parts[1]
|
||||
}
|
||||
@@ -39,79 +40,147 @@ func AuthMiddleware() fiber.Handler {
|
||||
// Validate token
|
||||
claims, err := authService.ValidateToken(authHeader)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "invalid or expired token",
|
||||
})
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// Get user from database
|
||||
user, err := authService.GetUserByID(claims.UserID)
|
||||
if err != nil {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// Check if user is active
|
||||
if !user.IsActive {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// Create locale. LangID is overwritten by auth Token
|
||||
var userLocale model.UserLocale
|
||||
userLocale.OriginalUser = user
|
||||
|
||||
// Check if target user is present
|
||||
targetUserIDAttribute := c.Query("target_user_id")
|
||||
|
||||
if targetUserIDAttribute == "" {
|
||||
userLocale.User = user
|
||||
c.Locals(constdata.USER_LOCALE, &userLocale)
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
// We now populate the target user
|
||||
if !userLocale.OriginalUser.HasPermission(perms.Teleport) {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
targetUserID, err := strconv.Atoi(targetUserIDAttribute)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"error": "invalid target user id attribute",
|
||||
})
|
||||
}
|
||||
|
||||
// to verify target user, we use the same functionality as for verifying original user
|
||||
// Get target user from database
|
||||
user, err = authService.GetUserByID(uint(targetUserID))
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "target user not found",
|
||||
})
|
||||
}
|
||||
|
||||
// Check if target user is active
|
||||
if !user.IsActive {
|
||||
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
|
||||
"error": "target user account is inactive",
|
||||
})
|
||||
}
|
||||
|
||||
userLocale.User = user
|
||||
c.Locals(constdata.USER_LOCALE, &userLocale)
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func Authorize() fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
_, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "not authenticated",
|
||||
})
|
||||
}
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// Webdav
|
||||
func Webdav() fiber.Handler {
|
||||
authService := authService.NewAuthService()
|
||||
|
||||
return func(c fiber.Ctx) error {
|
||||
authHeader := c.Get("Authorization")
|
||||
if authHeader == "" {
|
||||
c.Set("WWW-Authenticate", `Basic realm="webdav"`)
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "authorization token required",
|
||||
})
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(authHeader, "Basic ") {
|
||||
c.Set("WWW-Authenticate", `Basic realm="webdav"`)
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "invalid authorization token",
|
||||
})
|
||||
}
|
||||
|
||||
encoded := strings.TrimPrefix(authHeader, "Basic ")
|
||||
decoded, err := base64.StdEncoding.DecodeString(encoded)
|
||||
if err != nil {
|
||||
c.Set("WWW-Authenticate", `Basic realm="webdav"`)
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "invalid authorization token",
|
||||
})
|
||||
}
|
||||
|
||||
credentials := strings.SplitN(string(decoded), ":", 2)
|
||||
rawToken := ""
|
||||
if len(credentials) == 1 {
|
||||
rawToken = credentials[0]
|
||||
} else if len(credentials) == 2 {
|
||||
rawToken = credentials[1]
|
||||
}
|
||||
if len(rawToken) != constdata.NBYTES_IN_WEBDAV_TOKEN*2 {
|
||||
c.Set("WWW-Authenticate", `Basic realm="webdav"`)
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "invalid authorization token",
|
||||
})
|
||||
}
|
||||
|
||||
// we identify user based on this token.
|
||||
user, err := authService.GetUserByWebdavToken(rawToken)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "user not found",
|
||||
})
|
||||
}
|
||||
|
||||
// Check if user is active
|
||||
if !user.IsActive {
|
||||
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
|
||||
"error": "user account is inactive",
|
||||
})
|
||||
}
|
||||
|
||||
// Set user in context
|
||||
c.Locals("user", user.ToSession())
|
||||
c.Locals("userID", user.ID)
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// RequireAdmin creates admin-only middleware
|
||||
func RequireAdmin() fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
user := c.Locals("user")
|
||||
if user == nil {
|
||||
if user.WebdavExpires != nil && user.WebdavExpires.Before(time.Now()) {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": "not authenticated",
|
||||
"error": "invalid or expired token",
|
||||
})
|
||||
}
|
||||
|
||||
userSession, ok := user.(*model.UserSession)
|
||||
if !ok {
|
||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||
"error": "invalid user session",
|
||||
})
|
||||
}
|
||||
|
||||
if userSession.Role != model.RoleAdmin {
|
||||
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
|
||||
"error": "admin access required",
|
||||
})
|
||||
}
|
||||
var userLocale model.UserLocale
|
||||
userLocale.OriginalUser = user
|
||||
userLocale.User = user
|
||||
c.Locals(constdata.USER_LOCALE, &userLocale)
|
||||
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserID extracts user ID from context
|
||||
func GetUserID(c fiber.Ctx) uint {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return userID
|
||||
}
|
||||
|
||||
// GetUser extracts user from context
|
||||
func GetUser(c fiber.Ctx) *model.UserSession {
|
||||
user, ok := c.Locals("user").(*model.UserSession)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
// GetConfig returns the app config
|
||||
func GetConfig() *config.Config {
|
||||
return config.Get()
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
package middleware
|
||||
|
||||
import "github.com/gofiber/fiber/v3"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// CORSMiddleware creates CORS middleware
|
||||
func CORSMiddleware() fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
c.Set("Access-Control-Allow-Origin", "*")
|
||||
|
||||
if strings.Contains(c.Get("Host"), "localhost") {
|
||||
c.Set("Access-Control-Allow-Origin", c.Get("Host"))
|
||||
} else {
|
||||
origins := strings.Join(config.Get().Cors.Origins, ",")
|
||||
c.Set("Access-Control-Allow-Origin", origins)
|
||||
}
|
||||
|
||||
c.Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
|
||||
c.Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/langsService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
@@ -22,12 +24,8 @@ func LanguageMiddleware() fiber.Handler {
|
||||
if id, err := strconv.ParseUint(langIDStr, 10, 32); err == nil {
|
||||
langID = uint(id)
|
||||
if langID > 0 {
|
||||
lang, err := langService.GetLanguageById(langID)
|
||||
if err == nil {
|
||||
c.Locals("langID", langID)
|
||||
c.Locals("lang", lang)
|
||||
return c.Next()
|
||||
}
|
||||
c.Locals(constdata.USER_LOCALE, returnNewLocale(langID))
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,12 +36,8 @@ func LanguageMiddleware() fiber.Handler {
|
||||
if id, err := strconv.ParseUint(cookieLang, 10, 32); err == nil {
|
||||
langID = uint(id)
|
||||
if langID > 0 {
|
||||
lang, err := langService.GetLanguageById(langID)
|
||||
if err == nil {
|
||||
c.Locals("langID", langID)
|
||||
c.Locals("lang", lang)
|
||||
return c.Next()
|
||||
}
|
||||
c.Locals(constdata.USER_LOCALE, returnNewLocale(langID))
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,8 +51,7 @@ func LanguageMiddleware() fiber.Handler {
|
||||
lang, err := langService.GetLanguageByISOCode(isoCode)
|
||||
if err == nil && lang != nil {
|
||||
langID = uint(lang.ID)
|
||||
c.Locals("langID", langID)
|
||||
c.Locals("lang", lang)
|
||||
c.Locals(constdata.USER_LOCALE, returnNewLocale(langID))
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
@@ -68,8 +61,7 @@ func LanguageMiddleware() fiber.Handler {
|
||||
defaultLang, err := langService.GetDefaultLanguage()
|
||||
if err == nil && defaultLang != nil {
|
||||
langID = uint(defaultLang.ID)
|
||||
c.Locals("langID", langID)
|
||||
c.Locals("lang", defaultLang)
|
||||
c.Locals(constdata.USER_LOCALE, returnNewLocale(langID))
|
||||
}
|
||||
|
||||
return c.Next()
|
||||
@@ -104,11 +96,9 @@ func parseAcceptLanguage(header string) string {
|
||||
return strings.ToLower(first)
|
||||
}
|
||||
|
||||
// GetLanguageID extracts language ID from context
|
||||
func GetLanguageID(c fiber.Ctx) uint {
|
||||
langID, ok := c.Locals("langID").(uint)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return langID
|
||||
func returnNewLocale(lang_id uint) *model.UserLocale {
|
||||
newLocale := model.UserLocale{}
|
||||
newLocale.OriginalUser = &model.Customer{}
|
||||
newLocale.OriginalUser.LangID = lang_id
|
||||
return &newLocale
|
||||
}
|
||||
|
||||
28
app/delivery/middleware/permissions.go
Normal file
28
app/delivery/middleware/permissions.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func Require(p perms.Permission) fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
user, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
for _, perm := range user.Role.Permissions {
|
||||
if perm.Name == p {
|
||||
return c.Next()
|
||||
}
|
||||
}
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrForbidden)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrForbidden)))
|
||||
}
|
||||
}
|
||||
18
app/delivery/middleware/perms/permissions.go
Normal file
18
app/delivery/middleware/perms/permissions.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package perms
|
||||
|
||||
type Permission string
|
||||
|
||||
const (
|
||||
UserReadAny Permission = "user.read.any"
|
||||
UserWriteAny Permission = "user.write.any"
|
||||
UserDeleteAny Permission = "user.delete.any"
|
||||
CurrencyWrite Permission = "currency.write"
|
||||
SpecificPriceManage Permission = "specific_price.manage"
|
||||
WebdavCreateToken Permission = "webdav.create_token"
|
||||
ProductTranslationSave Permission = "product_translation.save"
|
||||
ProductTranslationTranslate Permission = "product_translation.translate"
|
||||
SearchCreateIndex Permission = "search.create_index"
|
||||
OrdersViewAll Permission = "orders.view_all"
|
||||
OrdersModifyAll Permission = "orders.modify_all"
|
||||
Teleport Permission = "teleport"
|
||||
)
|
||||
@@ -2,13 +2,17 @@ package public
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/authService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
@@ -45,8 +49,9 @@ func AuthHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
r.Get("/google", handler.GoogleLogin)
|
||||
r.Get("/google/callback", handler.GoogleCallback)
|
||||
|
||||
authProtected := r.Group("", middleware.AuthMiddleware())
|
||||
authProtected := r.Group("", middleware.Authorize())
|
||||
authProtected.Get("/me", handler.Me)
|
||||
authProtected.Post("/update-choice", handler.UpdateJWTToken)
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -263,15 +268,15 @@ func (h *AuthHandler) RefreshToken(c fiber.Ctx) error {
|
||||
|
||||
// Me returns the current user info
|
||||
func (h *AuthHandler) Me(c fiber.Ctx) error {
|
||||
user := c.Locals("user")
|
||||
if user == nil {
|
||||
userLocale := c.Locals(constdata.USER_LOCALE).(*model.UserLocale)
|
||||
if userLocale.OriginalUser == nil {
|
||||
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrNotAuthenticated),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"user": user,
|
||||
"user": *userLocale.OriginalUser,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -344,6 +349,51 @@ func (h *AuthHandler) CompleteRegistration(c fiber.Ctx) error {
|
||||
return c.Status(fiber.StatusCreated).JSON(response)
|
||||
}
|
||||
|
||||
// Updates JWT Tokens. Requires authentication and updates access token only
|
||||
func (h *AuthHandler) UpdateJWTToken(c fiber.Ctx) error {
|
||||
userLocale, ok := c.Locals(constdata.USER_LOCALE).(*model.UserLocale)
|
||||
if !ok {
|
||||
return c.Status(fiber.StatusUnauthorized).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrNotAuthenticated)))
|
||||
}
|
||||
|
||||
// Parse language and country_id from query params
|
||||
langIDStr := c.Query("lang_id")
|
||||
|
||||
if langIDStr != "" {
|
||||
parsedID, err := strconv.ParseUint(langIDStr, 10, 32)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadLangID)))
|
||||
}
|
||||
userLocale.OriginalUser.LangID = uint(parsedID)
|
||||
}
|
||||
|
||||
countryIDStr := c.Query("country_id")
|
||||
|
||||
if countryIDStr != "" {
|
||||
parsedID, err := strconv.ParseUint(countryIDStr, 10, 32)
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusBadRequest).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadCountryID)))
|
||||
}
|
||||
userLocale.OriginalUser.CountryID = uint(parsedID)
|
||||
}
|
||||
|
||||
newAccessToken, err := h.authService.UpdateJWTToken(userLocale.OriginalUser)
|
||||
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, err),
|
||||
})
|
||||
}
|
||||
|
||||
// does not reset refresh token
|
||||
h.setAuthCookies(c, newAccessToken, "")
|
||||
|
||||
return c.JSON(response.Make(&fiber.Map{"token": newAccessToken}, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// GoogleLogin redirects the user to Google's OAuth2 consent page
|
||||
func (h *AuthHandler) GoogleLogin(c fiber.Ctx) error {
|
||||
// Generate a random state token and store it in a short-lived cookie
|
||||
@@ -408,9 +458,12 @@ func (h *AuthHandler) GoogleCallback(c fiber.Ctx) error {
|
||||
|
||||
// Redirect to the locale-prefixed charts page after successful Google login.
|
||||
// The user's preferred language is stored in the auth response; fall back to "en".
|
||||
lang := response.User.Lang
|
||||
if lang == "" {
|
||||
lang = "en"
|
||||
lang_iso_code, err := h.authService.GetLangISOCode(response.User.LangID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, err),
|
||||
})
|
||||
}
|
||||
return c.Redirect().To(h.config.App.BaseURL + "/" + lang)
|
||||
|
||||
return c.Redirect().To(h.config.App.BaseURL + "/" + lang_iso_code)
|
||||
}
|
||||
|
||||
56
app/delivery/web/api/public/routing.go
Normal file
56
app/delivery/web/api/public/routing.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package public
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/menuService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type RoutingHandler struct {
|
||||
menuService *menuService.MenuService
|
||||
}
|
||||
|
||||
func NewRoutingHandler() *RoutingHandler {
|
||||
menuService := menuService.New()
|
||||
return &RoutingHandler{
|
||||
menuService: menuService,
|
||||
}
|
||||
}
|
||||
|
||||
// AuthHandlerRoutes registers all auth routes
|
||||
func RoutingHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewRoutingHandler()
|
||||
|
||||
r.Get("/get-routes", handler.GetRouting)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *RoutingHandler) GetRouting(c fiber.Ctx) error {
|
||||
langId, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
var roleId uint
|
||||
customer, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok {
|
||||
roleId = constdata.UNLOGGED_USER_ROLE_ID
|
||||
} else {
|
||||
roleId = customer.RoleID
|
||||
}
|
||||
|
||||
menu, err := h.menuService.GetRoutes(langId, roleId)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&menu, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
157
app/delivery/web/api/restricted/addresses.go
Normal file
157
app/delivery/web/api/restricted/addresses.go
Normal file
@@ -0,0 +1,157 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/addressesService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type AddressesHandler struct {
|
||||
addressesService *addressesService.AddressesService
|
||||
}
|
||||
|
||||
func NewAddressesHandler() *AddressesHandler {
|
||||
addressesService := addressesService.New()
|
||||
return &AddressesHandler{
|
||||
addressesService: addressesService,
|
||||
}
|
||||
}
|
||||
|
||||
func AddressesHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewAddressesHandler()
|
||||
|
||||
r.Get("/get-template", handler.GetTemplate)
|
||||
r.Post("/add-new-address", handler.AddNewAddress)
|
||||
r.Post("/modify-address", handler.ModifyAddress)
|
||||
r.Get("/retrieve-addresses", handler.RetrieveAddressesInfo)
|
||||
r.Delete("/delete-address", handler.DeleteAddress)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *AddressesHandler) GetTemplate(c fiber.Ctx) error {
|
||||
country_id_attribute := c.Query("country_id")
|
||||
country_id, err := strconv.Atoi(country_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
template, err := h.addressesService.GetTemplate(uint(country_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&template, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *AddressesHandler) AddNewAddress(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
address_info := string(c.Body())
|
||||
if address_info == "" {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
country_id_attribute := c.Query("country_id")
|
||||
country_id, err := strconv.Atoi(country_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.addressesService.AddNewAddress(userID, address_info, uint(country_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *AddressesHandler) ModifyAddress(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
address_id_attribute := c.Query("address_id")
|
||||
address_id, err := strconv.Atoi(address_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
address_info := string(c.Body())
|
||||
if address_info == "" {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
country_id_attribute := c.Query("country_id")
|
||||
country_id, err := strconv.Atoi(country_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.addressesService.ModifyAddress(userID, uint(address_id), address_info, uint(country_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *AddressesHandler) RetrieveAddressesInfo(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
addresses, err := h.addressesService.RetrieveAddresses(userID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(addresses, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *AddressesHandler) DeleteAddress(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
address_id_attribute := c.Query("address_id")
|
||||
address_id, err := strconv.Atoi(address_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.addressesService.DeleteAddress(userID, uint(address_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
248
app/delivery/web/api/restricted/carts.go
Normal file
248
app/delivery/web/api/restricted/carts.go
Normal file
@@ -0,0 +1,248 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/cartsService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// CartsHandler handles endpoints that modify carts.
|
||||
type CartsHandler struct {
|
||||
cartsService *cartsService.CartsService
|
||||
}
|
||||
|
||||
// CartsHandler creates a new CartsHandler instance
|
||||
func NewCartsHandler() *CartsHandler {
|
||||
cartsService := cartsService.New()
|
||||
return &CartsHandler{
|
||||
cartsService: cartsService,
|
||||
}
|
||||
}
|
||||
|
||||
func CartsHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewCartsHandler()
|
||||
|
||||
r.Get("/add-new-cart", handler.AddNewCart)
|
||||
r.Delete("/remove-cart", handler.RemoveCart)
|
||||
r.Get("/change-cart-name", handler.ChangeCartName)
|
||||
r.Get("/retrieve-carts-info", handler.RetrieveCartsInfo)
|
||||
r.Get("/retrieve-cart", handler.RetrieveCart)
|
||||
r.Get("/add-product-to-cart", handler.AddProduct)
|
||||
r.Delete("/remove-product-from-cart", handler.RemoveProduct)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *CartsHandler) AddNewCart(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
name := c.Query("name")
|
||||
new_cart, err := h.cartsService.CreateNewCart(userID, name)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&new_cart, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *CartsHandler) RemoveCart(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.cartsService.RemoveCart(userID, uint(cart_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *CartsHandler) ChangeCartName(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
new_name := c.Query("new_name")
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.cartsService.UpdateCartName(userID, uint(cart_id), new_name)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *CartsHandler) RetrieveCartsInfo(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
carts_info, err := h.cartsService.RetrieveCartsInfo(userID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&carts_info, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *CartsHandler) RetrieveCart(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
cart, err := h.cartsService.RetrieveCart(userID, uint(cart_id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(cart, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// adds or sets given amount of products to the cart
|
||||
func (h *CartsHandler) AddProduct(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
product_id_attribute := c.Query("product_id")
|
||||
product_id, err := strconv.Atoi(product_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
product_attribute_id_attribute := c.Query("product_attribute_id")
|
||||
var product_attribute_id *uint
|
||||
if product_attribute_id_attribute == "" {
|
||||
product_attribute_id = nil
|
||||
} else {
|
||||
val, err := strconv.Atoi(product_attribute_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
uval := uint(val)
|
||||
product_attribute_id = &uval
|
||||
}
|
||||
|
||||
amount_attribute := c.Query("amount")
|
||||
amount, err := strconv.Atoi(amount_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
set_amount_attribute := c.Query("set_amount")
|
||||
set_amount, err := strconv.ParseBool(set_amount_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.cartsService.AddProduct(userID, uint(cart_id), uint(product_id), product_attribute_id, amount, set_amount)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// removes product from the cart.
|
||||
func (h *CartsHandler) RemoveProduct(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
product_id_attribute := c.Query("product_id")
|
||||
product_id, err := strconv.Atoi(product_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
product_attribute_id_attribute := c.Query("product_attribute_id")
|
||||
var product_attribute_id *uint
|
||||
if product_attribute_id_attribute == "" {
|
||||
product_attribute_id = nil
|
||||
} else {
|
||||
val, err := strconv.Atoi(product_attribute_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
uval := uint(val)
|
||||
product_attribute_id = &uval
|
||||
}
|
||||
|
||||
err = h.cartsService.RemoveProduct(userID, uint(cart_id), uint(product_id), product_attribute_id)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
70
app/delivery/web/api/restricted/currency.go
Normal file
70
app/delivery/web/api/restricted/currency.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/currencyService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type CurrencyHandler struct {
|
||||
CurrencyService *currencyService.CurrencyService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
func NewCurrencyHandler() *CurrencyHandler {
|
||||
currencyService := currencyService.New()
|
||||
return &CurrencyHandler{
|
||||
CurrencyService: currencyService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func CurrencyHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewCurrencyHandler()
|
||||
|
||||
r.Post("/currency-rate", middleware.Require(perms.CurrencyWrite), handler.PostCurrencyRate)
|
||||
r.Get("/currency-rate/:id", handler.GetCurrencyRate)
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *CurrencyHandler) PostCurrencyRate(c fiber.Ctx) error {
|
||||
var currencyRate model.CurrencyRate
|
||||
if err := c.Bind().Body(¤cyRate); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrJSONBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrJSONBody)))
|
||||
}
|
||||
|
||||
err := h.CurrencyService.CreateCurrencyRate(¤cyRate)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *CurrencyHandler) GetCurrencyRate(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
|
||||
}
|
||||
|
||||
currency, err := h.CurrencyService.GetCurrency(uint(id))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(currency, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
102
app/delivery/web/api/restricted/customer.go
Normal file
102
app/delivery/web/api/restricted/customer.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/customerService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/query_params"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type customerHandler struct {
|
||||
service *customerService.CustomerService
|
||||
}
|
||||
|
||||
func NewCustomerHandler() *customerHandler {
|
||||
customerService := customerService.New()
|
||||
return &customerHandler{
|
||||
service: customerService,
|
||||
}
|
||||
}
|
||||
|
||||
func CustomerHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewCustomerHandler()
|
||||
|
||||
r.Get("", handler.customerData)
|
||||
r.Get("/list", middleware.Require(perms.UserReadAny), handler.listCustomers)
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *customerHandler) customerData(fc fiber.Ctx) error {
|
||||
var customerId uint
|
||||
|
||||
user, ok := localeExtractor.GetCustomer(fc)
|
||||
if !ok || user == nil {
|
||||
return fc.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
customerIdStr := fc.Query("id")
|
||||
if customerIdStr != "" {
|
||||
id, err := strconv.ParseUint(customerIdStr, 10, 64)
|
||||
if err != nil {
|
||||
return fiber.ErrBadRequest
|
||||
}
|
||||
|
||||
if user.ID != uint(id) && !user.HasPermission(perms.UserReadAny) {
|
||||
return fc.Status(fiber.StatusForbidden).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, responseErrors.ErrForbidden)))
|
||||
}
|
||||
|
||||
customerId = uint(id)
|
||||
} else {
|
||||
customerId = user.ID
|
||||
}
|
||||
|
||||
customer, err := h.service.GetById(customerId)
|
||||
if err != nil {
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
|
||||
return fc.JSON(response.Make(&customer, 0, i18n.T_(fc, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *customerHandler) listCustomers(fc fiber.Ctx) error {
|
||||
user, ok := localeExtractor.GetCustomer(fc)
|
||||
if !ok || user == nil {
|
||||
return fc.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
p, filt, err := query_params.ParseFilters[model.Customer](fc, columnMappingListUsers)
|
||||
if err != nil {
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
|
||||
search := fc.Query("search")
|
||||
|
||||
customer, err := h.service.Find(user.LangID, p, filt, search)
|
||||
if err != nil {
|
||||
return fc.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(fc, err)))
|
||||
}
|
||||
|
||||
return fc.JSON(response.Make(&customer, 0, i18n.T_(fc, response.Message_OK)))
|
||||
}
|
||||
|
||||
var columnMappingListUsers map[string]string = map[string]string{
|
||||
"user_id": "users.id",
|
||||
"email": "users.email",
|
||||
"first_name": "users.first_name",
|
||||
"last_name": "users.last_name",
|
||||
}
|
||||
52
app/delivery/web/api/restricted/localeSelector.go
Normal file
52
app/delivery/web/api/restricted/localeSelector.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/localeSelectorService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// LocaleSelectorHandler for getting languages and countries data
|
||||
type LocaleSelectorHandler struct {
|
||||
localeSelectorService *localeSelectorService.LocaleSelectorService
|
||||
}
|
||||
|
||||
// NewLocaleSelectorHandler creates a new LocaleSelectorHandler instance
|
||||
func NewLocaleSelectorHandler() *LocaleSelectorHandler {
|
||||
localeSelectorService := localeSelectorService.New()
|
||||
return &LocaleSelectorHandler{
|
||||
localeSelectorService: localeSelectorService,
|
||||
}
|
||||
}
|
||||
|
||||
func LocaleSelectorHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewLocaleSelectorHandler()
|
||||
|
||||
r.Get("/get-languages", handler.GetLanguages)
|
||||
r.Get("/get-countries", handler.GetCountries)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *LocaleSelectorHandler) GetLanguages(c fiber.Ctx) error {
|
||||
languages, err := h.localeSelectorService.GetLanguages()
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&languages, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *LocaleSelectorHandler) GetCountries(c fiber.Ctx) error {
|
||||
countries, err := h.localeSelectorService.GetCountriesAndCurrencies()
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&countries, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
102
app/delivery/web/api/restricted/menu.go
Normal file
102
app/delivery/web/api/restricted/menu.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/menuService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type MenuHandler struct {
|
||||
menuService *menuService.MenuService
|
||||
}
|
||||
|
||||
func NewMenuHandler() *MenuHandler {
|
||||
menuService := menuService.New()
|
||||
return &MenuHandler{
|
||||
menuService: menuService,
|
||||
}
|
||||
}
|
||||
|
||||
func MenuHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewMenuHandler()
|
||||
|
||||
r.Get("/get-category-tree", handler.GetCategoryTree)
|
||||
r.Get("/get-breadcrumb", handler.GetBreadcrumb)
|
||||
r.Get("/get-top-menu", handler.GetTopMenu)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *MenuHandler) GetCategoryTree(c fiber.Ctx) error {
|
||||
lang_id, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
root_category_id_attribute := c.Query("root_category_id")
|
||||
root_category_id, err := strconv.Atoi(root_category_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
category_tree, err := h.menuService.GetCategoryTree(uint(root_category_id), lang_id)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&category_tree, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *MenuHandler) GetBreadcrumb(c fiber.Ctx) error {
|
||||
lang_id, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
root_category_id_attribute := c.Query("root_category_id")
|
||||
root_category_id, err := strconv.Atoi(root_category_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
category_id_attribute := c.Query("category_id")
|
||||
category_id, err := strconv.Atoi(category_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
breadcrumb, err := h.menuService.GetBreadcrumb(uint(root_category_id), uint(category_id), lang_id)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&breadcrumb, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *MenuHandler) GetTopMenu(c fiber.Ctx) error {
|
||||
customer, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok || customer == nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
menu, err := h.menuService.GetTopMenu(customer.LangID, customer.RoleID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&menu, len(menu), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
171
app/delivery/web/api/restricted/orders.go
Normal file
171
app/delivery/web/api/restricted/orders.go
Normal file
@@ -0,0 +1,171 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/orderService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/query_params"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type OrdersHandler struct {
|
||||
ordersService *orderService.OrderService
|
||||
}
|
||||
|
||||
func NewOrdersHandler() *OrdersHandler {
|
||||
ordersService := orderService.New()
|
||||
return &OrdersHandler{
|
||||
ordersService: ordersService,
|
||||
}
|
||||
}
|
||||
|
||||
func OrdersHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewOrdersHandler()
|
||||
|
||||
r.Get("/list", handler.ListOrders)
|
||||
r.Post("/place-new-order", handler.PlaceNewOrder)
|
||||
r.Post("/change-order-address", handler.ChangeOrderAddress)
|
||||
r.Get("/change-order-status", handler.ChangeOrderStatus)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// when a user (not admin) wants to list orders, we automatically append filter to only view his orders.
|
||||
// we base permissions and user based on target user only.
|
||||
func (h *OrdersHandler) ListOrders(c fiber.Ctx) error {
|
||||
user, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
paging, filters, err := query_params.ParseFilters[model.CustomerOrder](c, columnMappingListOrders)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
list, err := h.ordersService.Find(user, paging, filters)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&list.Items, int(list.Count), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
var columnMappingListOrders map[string]string = map[string]string{
|
||||
"order_id": "b2b_customer_orders.order_id",
|
||||
"user_id": "b2b_customer_orders.user_id",
|
||||
"name": "b2b_customer_orders.name",
|
||||
"country_id": "b2b_customer_orders.country_id",
|
||||
"status": "b2b_customer_orders.status",
|
||||
}
|
||||
|
||||
func (h *OrdersHandler) PlaceNewOrder(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
cart_id_attribute := c.Query("cart_id")
|
||||
cart_id, err := strconv.Atoi(cart_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
country_id_attribute := c.Query("country_id")
|
||||
country_id, err := strconv.Atoi(country_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
address_info := string(c.Body())
|
||||
if address_info == "" {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
name := c.Query("name")
|
||||
|
||||
err = h.ordersService.PlaceNewOrder(userID, uint(cart_id), name, uint(country_id), address_info)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// we base permissions and user based on target user only.
|
||||
func (h *OrdersHandler) ChangeOrderAddress(c fiber.Ctx) error {
|
||||
user, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
order_id_attribute := c.Query("order_id")
|
||||
order_id, err := strconv.Atoi(order_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
country_id_attribute := c.Query("country_id")
|
||||
country_id, err := strconv.Atoi(country_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
address_info := string(c.Body())
|
||||
if address_info == "" {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
err = h.ordersService.ChangeOrderAddress(user, uint(order_id), uint(country_id), address_info)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// we base permissions and user based on target user only.
|
||||
// TODO: well, permissions and all that.
|
||||
func (h *OrdersHandler) ChangeOrderStatus(c fiber.Ctx) error {
|
||||
user, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
order_id_attribute := c.Query("order_id")
|
||||
order_id, err := strconv.Atoi(order_id_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
status := c.Query("status")
|
||||
|
||||
err = h.ordersService.ChangeOrderStatus(user, uint(order_id), status)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
188
app/delivery/web/api/restricted/product.go
Normal file
188
app/delivery/web/api/restricted/product.go
Normal file
@@ -0,0 +1,188 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model/dbmodel"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/productService"
|
||||
constdata "git.ma-al.com/goc_daniel/b2b/app/utils/const_data"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/query/query_params"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type ProductsHandler struct {
|
||||
productService *productService.ProductService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
// NewListProductsHandler creates a new ListProductsHandler instance
|
||||
func NewProductsHandler() *ProductsHandler {
|
||||
productService := productService.New()
|
||||
return &ProductsHandler{
|
||||
productService: productService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func ProductsHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewProductsHandler()
|
||||
|
||||
r.Get("/:id/:country_id/:quantity", handler.GetProductJson)
|
||||
r.Get("/list", handler.ListProducts)
|
||||
r.Get("/list-variants/:product_id", handler.ListProductVariants)
|
||||
r.Post("/favorite/:product_id", handler.AddToFavorites)
|
||||
r.Delete("/favorite/:product_id", handler.RemoveFromFavorites)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *ProductsHandler) GetProductJson(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
|
||||
p_id_product, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
country_idStr := c.Params("country_id")
|
||||
|
||||
b2b_id_country, err := strconv.Atoi(country_idStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
quantityStr := c.Params("quantity")
|
||||
|
||||
p_quantity, err := strconv.Atoi(quantityStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
customer, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok || customer == nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
productJson, err := h.productService.Get(uint(p_id_product), customer.LangID, customer.ID, uint(b2b_id_country), uint(p_quantity))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&productJson, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *ProductsHandler) ListProducts(c fiber.Ctx) error {
|
||||
paging, filters, err := query_params.ParseFilters[dbmodel.PsProduct](c, columnMappingListProducts)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
customer, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok || customer == nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
list, err := h.productService.Find(customer.LangID, customer.ID, paging, filters, customer, constdata.DEFAULT_PRODUCT_QUANTITY, constdata.SHOP_ID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&list.Items, int(list.Count), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// These are all the filterable fields
|
||||
var columnMappingListProducts map[string]string = map[string]string{
|
||||
"product_id": "bp.product_id",
|
||||
"name": "bp.name",
|
||||
"reference": "bp.reference",
|
||||
"category_id": "bp.category_id",
|
||||
"quantity": "bp.quantity",
|
||||
"is_favorite": "bp.is_favorite",
|
||||
"is_new": "bp.is_new",
|
||||
"is_oem": "bp.is_oem",
|
||||
}
|
||||
|
||||
func (h *ProductsHandler) AddToFavorites(c fiber.Ctx) error {
|
||||
productIDStr := c.Params("product_id")
|
||||
|
||||
productID, err := strconv.Atoi(productIDStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
err = h.productService.AddToFavorites(userID, uint(productID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *ProductsHandler) RemoveFromFavorites(c fiber.Ctx) error {
|
||||
productIDStr := c.Params("product_id")
|
||||
|
||||
productID, err := strconv.Atoi(productIDStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
err = h.productService.RemoveFromFavorites(userID, uint(productID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *ProductsHandler) ListProductVariants(c fiber.Ctx) error {
|
||||
productIDStr := c.Params("product_id")
|
||||
|
||||
productID, err := strconv.Atoi(productIDStr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
customer, ok := localeExtractor.GetCustomer(c)
|
||||
if !ok || customer == nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
list, err := h.productService.GetProductAttributes(customer.LangID, uint(productID), constdata.SHOP_ID, customer.ID, customer.CountryID, constdata.DEFAULT_PRODUCT_QUANTITY)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&list, len(list), i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/productDescriptionService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// ProductDescriptionHandler handles endpoints that receive, save and translate product descriptions.
|
||||
type ProductDescriptionHandler struct {
|
||||
productDescriptionService *productDescriptionService.ProductDescriptionService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
// NewProductDescriptionHandler creates a new ProductDescriptionHandler instance
|
||||
func NewProductDescriptionHandler() *ProductDescriptionHandler {
|
||||
productDescriptionService := productDescriptionService.New()
|
||||
return &ProductDescriptionHandler{
|
||||
productDescriptionService: productDescriptionService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
// ProductDescriptionRoutes registers all product description routes
|
||||
func ProductDescriptionHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewProductDescriptionHandler()
|
||||
|
||||
r.Get("/get-product-description", handler.GetProductDescription)
|
||||
r.Post("/save-product-description", handler.SaveProductDescription)
|
||||
r.Get("/translate-product-description", handler.TranslateProductDescription)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// GetProductDescription returns the product description for a given product ID
|
||||
func (h *ProductDescriptionHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody), // possibly could return a different error
|
||||
})
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productShopID_attribute := c.Query("productShopID")
|
||||
productShopID, err := strconv.Atoi(productShopID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productLangID_attribute := c.Query("productLangID")
|
||||
productLangID, err := strconv.Atoi(productLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
response, err := h.productDescriptionService.GetProductDescription(userID, uint(productID), uint(productShopID), uint(productLangID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, err),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(response)
|
||||
}
|
||||
|
||||
// SaveProductDescription saves the description for a given product ID, in given shop and language
|
||||
func (h *ProductDescriptionHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody), // possibly could return a different error
|
||||
})
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productShopID_attribute := c.Query("productShopID")
|
||||
productShopID, err := strconv.Atoi(productShopID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productLangID_attribute := c.Query("productLangID")
|
||||
productLangID, err := strconv.Atoi(productLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
updates := make(map[string]string)
|
||||
if err := c.Bind().Body(&updates); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody),
|
||||
})
|
||||
}
|
||||
|
||||
err = h.productDescriptionService.SaveProductDescription(userID, uint(productID), uint(productShopID), uint(productLangID), updates)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, err),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"message": i18n.T_(c, "product_description.successfully_updated_fields"),
|
||||
})
|
||||
}
|
||||
|
||||
// GetProductDescription returns the product description for a given product ID
|
||||
func (h *ProductDescriptionHandler) TranslateProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := c.Locals("userID").(uint)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody), // possibly could return a different error
|
||||
})
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productShopID_attribute := c.Query("productShopID")
|
||||
productShopID, err := strconv.Atoi(productShopID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productFromLangID_attribute := c.Query("productFromLangID")
|
||||
productFromLangID, err := strconv.Atoi(productFromLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
productToLangID_attribute := c.Query("productToLangID")
|
||||
productToLangID, err := strconv.Atoi(productToLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute),
|
||||
})
|
||||
}
|
||||
|
||||
response, err := h.productDescriptionService.TranslateProductDescription(userID, uint(productID), uint(productShopID), uint(productFromLangID), uint(productToLangID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).JSON(fiber.Map{
|
||||
"error": responseErrors.GetErrorCode(c, err),
|
||||
})
|
||||
}
|
||||
|
||||
return c.JSON(response)
|
||||
}
|
||||
155
app/delivery/web/api/restricted/productTranslation.go
Normal file
155
app/delivery/web/api/restricted/productTranslation.go
Normal file
@@ -0,0 +1,155 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/productTranslationService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// ProductTranslationHandler handles endpoints that receive, save and translate product descriptions.
|
||||
type ProductTranslationHandler struct {
|
||||
productTranslationService *productTranslationService.ProductTranslationService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
// NewProductTranslationHandler creates a new ProductTranslationHandler instance
|
||||
func NewProductTranslationHandler() *ProductTranslationHandler {
|
||||
productTranslationService := productTranslationService.New()
|
||||
return &ProductTranslationHandler{
|
||||
productTranslationService: productTranslationService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
// ProductTranslationRoutes registers all product description routes
|
||||
func ProductTranslationHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewProductTranslationHandler()
|
||||
|
||||
r.Get("/get-product-description", handler.GetProductDescription)
|
||||
r.Post("/save-product-description", middleware.Require(perms.ProductTranslationSave), handler.SaveProductDescription)
|
||||
r.Get("/translate-product-description", middleware.Require(perms.ProductTranslationTranslate), handler.TranslateProductDescription)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// GetProductDescription returns the product description for a given product ID
|
||||
func (h *ProductTranslationHandler) GetProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
productLangID_attribute := c.Query("productLangID")
|
||||
productLangID, err := strconv.Atoi(productLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
description, err := h.productTranslationService.GetProductDescription(userID, uint(productID), uint(productLangID))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(description, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// SaveProductDescription saves the description for a given product ID, in given language
|
||||
func (h *ProductTranslationHandler) SaveProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
productLangID_attribute := c.Query("productLangID")
|
||||
productLangID, err := strconv.Atoi(productLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
updates := make(map[string]string)
|
||||
if err := c.Bind().Body(&updates); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
err = h.productTranslationService.SaveProductDescription(userID, uint(productID), uint(productLangID), updates)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
// TranslateProductDescription returns translated product description
|
||||
func (h *ProductTranslationHandler) TranslateProductDescription(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
productID_attribute := c.Query("productID")
|
||||
productID, err := strconv.Atoi(productID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
productFromLangID_attribute := c.Query("productFromLangID")
|
||||
productFromLangID, err := strconv.Atoi(productFromLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
productToLangID_attribute := c.Query("productToLangID")
|
||||
productToLangID, err := strconv.Atoi(productToLangID_attribute)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
aiModel := c.Query("model")
|
||||
if aiModel != "OpenAI" && aiModel != "Google" {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
description, err := h.productTranslationService.TranslateProductDescription(userID, uint(productID), uint(productFromLangID), uint(productToLangID), aiModel)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(description, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
108
app/delivery/web/api/restricted/search.go
Normal file
108
app/delivery/web/api/restricted/search.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/meiliService"
|
||||
searchservice "git.ma-al.com/goc_daniel/b2b/app/service/searchService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type MeiliSearchHandler struct {
|
||||
meiliService *meiliService.MeiliService
|
||||
searchService *searchservice.SearchService
|
||||
}
|
||||
|
||||
func NewMeiliSearchHandler() *MeiliSearchHandler {
|
||||
return &MeiliSearchHandler{
|
||||
meiliService: meiliService.New(),
|
||||
searchService: searchservice.New(),
|
||||
}
|
||||
}
|
||||
|
||||
func MeiliSearchHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewMeiliSearchHandler()
|
||||
|
||||
r.Get("/create-index", middleware.Require(perms.SearchCreateIndex), handler.CreateIndex)
|
||||
r.Post("/search", handler.Search)
|
||||
r.Post("/settings", handler.GetSettings)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *MeiliSearchHandler) CreateIndex(c fiber.Ctx) error {
|
||||
id_lang, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err := h.meiliService.CreateIndex(id_lang)
|
||||
if err != nil {
|
||||
fmt.Printf("CreateIndex error: %v\n", err)
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *MeiliSearchHandler) Search(c fiber.Ctx) error {
|
||||
id_lang, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
index := meiliService.GetIndexName(id_lang)
|
||||
|
||||
var body map[string]interface{}
|
||||
if err := json.Unmarshal(c.Body(), &body); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
result, err := h.searchService.Search(index, c.Body(), id_lang)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
if h.searchService.IsIndexNotFound(result.Body) {
|
||||
if createErr := h.meiliService.CreateIndex(id_lang); createErr == nil {
|
||||
result, err = h.searchService.Search(index, c.Body(), id_lang)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.Status(result.StatusCode).Send(result.Body)
|
||||
}
|
||||
|
||||
func (h *MeiliSearchHandler) GetSettings(c fiber.Ctx) error {
|
||||
id_lang, ok := localeExtractor.GetLangID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
index := meiliService.GetIndexName(id_lang)
|
||||
|
||||
result, err := h.searchService.GetIndexSettings(index)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.Status(result.StatusCode).Send(result.Body)
|
||||
}
|
||||
160
app/delivery/web/api/restricted/specificPrice.go
Normal file
160
app/delivery/web/api/restricted/specificPrice.go
Normal file
@@ -0,0 +1,160 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/model"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/specificPriceService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type SpecificPriceHandler struct {
|
||||
SpecificPriceService *specificPriceService.SpecificPriceService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
func NewSpecificPriceHandler() *SpecificPriceHandler {
|
||||
SpecificPriceService := specificPriceService.New()
|
||||
return &SpecificPriceHandler{
|
||||
SpecificPriceService: SpecificPriceService,
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func SpecificPriceHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewSpecificPriceHandler()
|
||||
|
||||
r.Post("/", middleware.Require(perms.SpecificPriceManage), handler.Create)
|
||||
r.Put("/:id", middleware.Require(perms.SpecificPriceManage), handler.Update)
|
||||
r.Delete("/:id", middleware.Require(perms.SpecificPriceManage), handler.Delete)
|
||||
r.Get("/", middleware.Require(perms.SpecificPriceManage), handler.List)
|
||||
r.Get("/:id", middleware.Require(perms.SpecificPriceManage), handler.GetByID)
|
||||
r.Patch("/:id/activate", middleware.Require(perms.SpecificPriceManage), handler.Activate)
|
||||
r.Patch("/:id/deactivate", middleware.Require(perms.SpecificPriceManage), handler.Deactivate)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) Create(c fiber.Ctx) error {
|
||||
var pr model.SpecificPrice
|
||||
if err := c.Bind().Body(&pr); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
result, err := h.SpecificPriceService.Create(c.Context(), &pr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&result, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) Update(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
var pr model.SpecificPrice
|
||||
if err := c.Bind().Body(&pr); err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
result, err := h.SpecificPriceService.Update(c.Context(), id, &pr)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&result, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) List(c fiber.Ctx) error {
|
||||
result, err := h.SpecificPriceService.List(c.Context())
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&result, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) GetByID(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
result, err := h.SpecificPriceService.GetByID(c.Context(), id)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&result, 1, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) Activate(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.SpecificPriceService.SetActive(c.Context(), id, true)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) Deactivate(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.SpecificPriceService.SetActive(c.Context(), id, false)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *SpecificPriceHandler) Delete(c fiber.Ctx) error {
|
||||
idStr := c.Params("id")
|
||||
id, err := strconv.ParseUint(idStr, 10, 64)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrBadAttribute)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrBadAttribute)))
|
||||
}
|
||||
|
||||
err = h.SpecificPriceService.Delete(c.Context(), id)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(nullable.GetNil(""), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
95
app/delivery/web/api/restricted/storage.go
Normal file
95
app/delivery/web/api/restricted/storage.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package restricted
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/storageService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/i18n"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/localeExtractor"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/nullable"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/response"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type StorageHandler struct {
|
||||
storageService *storageService.StorageService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
func NewStorageHandler() *StorageHandler {
|
||||
return &StorageHandler{
|
||||
storageService: storageService.New(),
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewStorageHandler()
|
||||
|
||||
// for all users
|
||||
r.Get("/list-content/*", handler.ListContent)
|
||||
r.Get("/download-file/*", handler.DownloadFile)
|
||||
|
||||
// for admins only
|
||||
r.Get("/create-new-webdav-token", middleware.Require(perms.WebdavCreateToken), handler.CreateNewWebdavToken)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// accepted path looks like e.g. "/folder1/" or "folder1"
|
||||
func (h *StorageHandler) ListContent(c fiber.Ctx) error {
|
||||
// relative path defaults to root directory
|
||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
entries_in_list, err := h.storageService.ListContent(abs_path)
|
||||
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(entries_in_list, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
|
||||
func (h *StorageHandler) DownloadFile(c fiber.Ctx) error {
|
||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
f, filename, filesize, err := h.storageService.DownloadFilePrep(abs_path)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
c.Attachment(filename)
|
||||
c.Set("Content-Length", strconv.FormatInt(filesize, 10))
|
||||
c.Set("Content-Type", "application/octet-stream")
|
||||
return c.SendStream(f, int(filesize))
|
||||
}
|
||||
|
||||
func (h *StorageHandler) CreateNewWebdavToken(c fiber.Ctx) error {
|
||||
userID, ok := localeExtractor.GetUserID(c)
|
||||
if !ok {
|
||||
return c.Status(responseErrors.GetErrorStatus(responseErrors.ErrInvalidBody)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, responseErrors.ErrInvalidBody)))
|
||||
}
|
||||
|
||||
new_token, err := h.storageService.NewWebdavToken(userID)
|
||||
if err != nil {
|
||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(&new_token, 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
@@ -21,10 +21,12 @@ type SettingsResponse struct {
|
||||
|
||||
// AppSettings represents app configuration
|
||||
type AppSettings struct {
|
||||
Name string `json:"name"`
|
||||
Environment string `json:"environment"`
|
||||
BaseURL string `json:"base_url"`
|
||||
PasswordRegex string `json:"password_regex"`
|
||||
Name string `json:"name"`
|
||||
Environment string `json:"environment"`
|
||||
BaseURL string `json:"base_url"`
|
||||
PasswordRegex string `json:"password_regex"`
|
||||
CategoryTreeRootID uint `json:"category_tree_root_id"`
|
||||
ShopDefaultLanguage uint `json:"shop_default_language"`
|
||||
// Config config.Config `json:"config"`
|
||||
}
|
||||
|
||||
@@ -65,10 +67,12 @@ func (h *SettingsHandler) GetSettings(cfg *config.Config) fiber.Handler {
|
||||
return func(c fiber.Ctx) error {
|
||||
settings := SettingsResponse{
|
||||
App: AppSettings{
|
||||
Name: cfg.App.Name,
|
||||
Environment: cfg.App.Environment,
|
||||
BaseURL: cfg.App.BaseURL,
|
||||
PasswordRegex: constdata.PASSWORD_VALIDATION_REGEX,
|
||||
Name: cfg.App.Name,
|
||||
Environment: cfg.App.Environment,
|
||||
BaseURL: cfg.App.BaseURL,
|
||||
PasswordRegex: constdata.PASSWORD_VALIDATION_REGEX,
|
||||
CategoryTreeRootID: constdata.CATEGORY_TREE_ROOT_ID,
|
||||
ShopDefaultLanguage: constdata.SHOP_DEFAULT_LANGUAGE,
|
||||
// Config: *config.Get(),
|
||||
},
|
||||
Server: ServerSettings{
|
||||
@@ -86,6 +90,6 @@ func (h *SettingsHandler) GetSettings(cfg *config.Config) fiber.Handler {
|
||||
Version: version.GetInfo(),
|
||||
}
|
||||
|
||||
return c.JSON(response.Make(c, fiber.StatusOK, nullable.GetNil(settings), nullable.GetNil(0), i18n.T_(c, response.Message_OK)))
|
||||
return c.JSON(response.Make(nullable.GetNil(settings), 0, i18n.T_(c, response.Message_OK)))
|
||||
}
|
||||
}
|
||||
|
||||
198
app/delivery/web/api/webdav/storage.go
Normal file
198
app/delivery/web/api/webdav/storage.go
Normal file
@@ -0,0 +1,198 @@
|
||||
package webdav
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/config"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/service/storageService"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/utils/responseErrors"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type StorageHandler struct {
|
||||
storageService *storageService.StorageService
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
func NewStorageHandler() *StorageHandler {
|
||||
return &StorageHandler{
|
||||
storageService: storageService.New(),
|
||||
config: config.Get(),
|
||||
}
|
||||
}
|
||||
|
||||
func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewStorageHandler()
|
||||
|
||||
// for webdav use only
|
||||
r.Get("/*", handler.Get)
|
||||
r.Head("/*", handler.Get)
|
||||
r.Put("/*", handler.Put)
|
||||
r.Delete("/*", handler.Delete)
|
||||
r.Add([]string{"MKCOL"}, "/*", handler.Mkcol)
|
||||
r.Add([]string{"PROPFIND"}, "/*", handler.Propfind)
|
||||
r.Add([]string{"PROPPATCH"}, "/*", handler.Proppatch)
|
||||
r.Add([]string{"MOVE"}, "/*", handler.Move)
|
||||
r.Add([]string{"COPY"}, "/*", handler.Copy)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Get(c fiber.Ctx) error {
|
||||
// fmt.Println("GET")
|
||||
absPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
info, err := h.storageService.EntryInfo(absPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
xml, err := h.storageService.Propfind(h.config.Storage.RootFolder, absPath, "1")
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
c.Set("Content-Type", `application/xml; charset="utf-8"`)
|
||||
return c.Status(http.StatusMultiStatus).SendString(xml)
|
||||
|
||||
} else {
|
||||
f, filename, filesize, err := h.storageService.DownloadFilePrep(absPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
c.Attachment(filename)
|
||||
c.Set("Content-Length", strconv.FormatInt(filesize, 10))
|
||||
c.Set("Content-Type", "application/octet-stream")
|
||||
return c.SendStream(f, int(filesize))
|
||||
}
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Put(c fiber.Ctx) error {
|
||||
// fmt.Println("PUT")
|
||||
absPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
var src io.Reader
|
||||
if bodyStream := c.Request().BodyStream(); bodyStream != nil {
|
||||
defer c.Request().CloseBodyStream()
|
||||
src = bodyStream
|
||||
} else {
|
||||
src = bytes.NewReader(c.Body())
|
||||
}
|
||||
|
||||
err = h.storageService.Put(absPath, src)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
return c.SendStatus(http.StatusCreated)
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Delete(c fiber.Ctx) error {
|
||||
// fmt.Println("DELETE")
|
||||
absPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
if absPath == h.config.Storage.RootFolder {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(responseErrors.ErrAccessDenied))
|
||||
}
|
||||
|
||||
err = h.storageService.Delete(absPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
return c.SendStatus(http.StatusNoContent)
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Mkcol(c fiber.Ctx) error {
|
||||
// fmt.Println("Mkcol")
|
||||
absPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
err = h.storageService.Mkcol(absPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
return c.SendStatus(http.StatusCreated)
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Propfind(c fiber.Ctx) error {
|
||||
// fmt.Println("PROPFIND")
|
||||
absPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
xml, err := h.storageService.Propfind(h.config.Storage.RootFolder, absPath, "1")
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
c.Set("Content-Type", `application/xml; charset="utf-8"`)
|
||||
return c.Status(http.StatusMultiStatus).SendString(xml)
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Proppatch(c fiber.Ctx) error {
|
||||
return c.SendStatus(http.StatusNotImplemented) // 501
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Move(c fiber.Ctx) error {
|
||||
// fmt.Println("MOVE")
|
||||
srcAbsPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
dest := c.Get("Destination")
|
||||
if dest == "" {
|
||||
return c.SendStatus(http.StatusBadRequest)
|
||||
}
|
||||
destAbsPath, err := h.storageService.ObtainDestPath(h.config.Storage.RootFolder, dest)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
err = h.storageService.Move(srcAbsPath, destAbsPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
return c.SendStatus(http.StatusCreated)
|
||||
}
|
||||
|
||||
func (h *StorageHandler) Copy(c fiber.Ctx) error {
|
||||
// fmt.Println("COPY")
|
||||
srcAbsPath, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
dest := c.Get("Destination")
|
||||
if dest == "" {
|
||||
return c.SendStatus(http.StatusBadRequest)
|
||||
}
|
||||
destAbsPath, err := h.storageService.ObtainDestPath(h.config.Storage.RootFolder, dest)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
|
||||
err = h.storageService.Copy(srcAbsPath, destAbsPath)
|
||||
if err != nil {
|
||||
return c.SendStatus(responseErrors.GetErrorStatus(err))
|
||||
}
|
||||
return c.SendStatus(http.StatusCreated)
|
||||
}
|
||||
@@ -47,6 +47,11 @@ var swaggerHTML = `
|
||||
url: "/openapi.json",
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
withCredentials: true,
|
||||
"servers": [
|
||||
{ "url": "http://localhost:3000" },
|
||||
{ "url": "http://localhost:5173" }
|
||||
],
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
|
||||
@@ -14,11 +14,10 @@ import (
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web/api"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web/api/public"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web/api/restricted"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web/api/webdav"
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/web/general"
|
||||
|
||||
// "github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
// "github.com/gofiber/fiber/v3/middleware/filesystem"
|
||||
"github.com/gofiber/fiber/v3/middleware/logger"
|
||||
"github.com/gofiber/fiber/v3/middleware/recover"
|
||||
)
|
||||
@@ -27,6 +26,7 @@ import (
|
||||
type Server struct {
|
||||
app *fiber.App
|
||||
cfg *config.Config
|
||||
webdav fiber.Router
|
||||
api fiber.Router
|
||||
public fiber.Router
|
||||
restricted fiber.Router
|
||||
@@ -44,12 +44,23 @@ func (s *Server) Cfg() *config.Config {
|
||||
|
||||
// New creates a new server instance
|
||||
func New() *Server {
|
||||
return &Server{
|
||||
app: fiber.New(fiber.Config{
|
||||
ErrorHandler: customErrorHandler,
|
||||
}),
|
||||
cfg: config.Get(),
|
||||
}
|
||||
var s Server
|
||||
|
||||
app :=
|
||||
fiber.New(fiber.Config{
|
||||
ErrorHandler: customErrorHandler,
|
||||
BodyLimit: 50 * 1024 * 1024, // 50 MB
|
||||
StreamRequestBody: true,
|
||||
RequestMethods: []string{
|
||||
fiber.MethodGet, fiber.MethodHead, fiber.MethodPost, fiber.MethodPut,
|
||||
fiber.MethodDelete, fiber.MethodConnect, fiber.MethodOptions,
|
||||
fiber.MethodTrace, fiber.MethodPatch, "MKCOL", "PROPFIND", "PROPPATCH", "MOVE", "COPY",
|
||||
},
|
||||
})
|
||||
|
||||
s.app = app
|
||||
s.cfg = config.Get()
|
||||
return &s
|
||||
}
|
||||
|
||||
// Setup configures the server with routes and middleware
|
||||
@@ -75,9 +86,12 @@ func (s *Server) Setup() error {
|
||||
|
||||
// API routes
|
||||
s.api = s.app.Group("/api/v1")
|
||||
s.api.Use(middleware.Authenticate())
|
||||
s.public = s.api.Group("/public")
|
||||
s.restricted = s.api.Group("/restricted")
|
||||
s.restricted.Use(middleware.AuthMiddleware())
|
||||
s.restricted.Use(middleware.Authorize())
|
||||
s.webdav = s.api.Group("/webdav")
|
||||
s.webdav.Use(middleware.Webdav())
|
||||
|
||||
// initialize language endpoints (general)
|
||||
api.NewLangHandler().InitLanguage(s.api, s.cfg)
|
||||
@@ -89,9 +103,58 @@ func (s *Server) Setup() error {
|
||||
auth := s.public.Group("/auth")
|
||||
public.AuthHandlerRoutes(auth)
|
||||
|
||||
// Repo routes (restricted)
|
||||
productDescription := s.restricted.Group("/product-description")
|
||||
restricted.ProductDescriptionHandlerRoutes(productDescription)
|
||||
menuRouting := s.public.Group("/menu")
|
||||
public.RoutingHandlerRoutes(menuRouting)
|
||||
|
||||
pCustomer := s.restricted.Group("/customer")
|
||||
restricted.CustomerHandlerRoutes(pCustomer)
|
||||
|
||||
// product translation routes (restricted)
|
||||
productTranslation := s.restricted.Group("/product-translation")
|
||||
restricted.ProductTranslationHandlerRoutes(productTranslation)
|
||||
|
||||
product := s.restricted.Group("/product")
|
||||
restricted.ProductsHandlerRoutes(product)
|
||||
|
||||
// locale selector (restricted)
|
||||
// this is basically for changing user's selected language and country
|
||||
localeSelector := s.restricted.Group("/langs-and-countries")
|
||||
restricted.LocaleSelectorHandlerRoutes(localeSelector)
|
||||
|
||||
// menu (restricted)
|
||||
menu := s.restricted.Group("/menu")
|
||||
restricted.MenuHandlerRoutes(menu)
|
||||
|
||||
// meili search (restricted)
|
||||
meiliSearch := s.restricted.Group("/search")
|
||||
restricted.MeiliSearchHandlerRoutes(meiliSearch)
|
||||
|
||||
// carts (restricted)
|
||||
carts := s.restricted.Group("/carts")
|
||||
restricted.CartsHandlerRoutes(carts)
|
||||
|
||||
// orders (restricted)
|
||||
orders := s.restricted.Group("/orders")
|
||||
restricted.OrdersHandlerRoutes(orders)
|
||||
|
||||
specificPrice := s.restricted.Group("/specific-price")
|
||||
restricted.SpecificPriceHandlerRoutes(specificPrice)
|
||||
|
||||
// addresses (restricted)
|
||||
addresses := s.restricted.Group("/addresses")
|
||||
restricted.AddressesHandlerRoutes(addresses)
|
||||
|
||||
// storage (uses various authorization means)
|
||||
restrictedStorage := s.restricted.Group("/storage")
|
||||
webdavStorage := s.webdav.Group("/storage")
|
||||
restricted.StorageHandlerRoutes(restrictedStorage)
|
||||
webdav.StorageHandlerRoutes(webdavStorage)
|
||||
|
||||
restricted.CurrencyHandlerRoutes(s.restricted)
|
||||
|
||||
s.api.All("*", func(c fiber.Ctx) error {
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
})
|
||||
|
||||
// // Restricted routes example
|
||||
// restricted := s.api.Group("/restricted")
|
||||
@@ -104,16 +167,6 @@ func (s *Server) Setup() error {
|
||||
// })
|
||||
// })
|
||||
|
||||
// // Admin routes example
|
||||
// admin := s.api.Group("/admin")
|
||||
// admin.Use(middleware.AuthMiddleware())
|
||||
// admin.Use(middleware.RequireAdmin())
|
||||
// admin.Get("/users", func(c fiber.Ctx) error {
|
||||
// return c.JSON(fiber.Map{
|
||||
// "message": "Admin area - user management",
|
||||
// })
|
||||
// })
|
||||
|
||||
// keep this at the end because its wilderange
|
||||
general.InitBo(s.App())
|
||||
|
||||
|
||||
72
app/model/address.go
Normal file
72
app/model/address.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package model
|
||||
|
||||
type Address struct {
|
||||
ID uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
||||
CustomerID uint `gorm:"column:b2b_customer_id;not null;index" json:"customer_id"`
|
||||
AddressString string `gorm:"column:address_string;not null" json:"address_string"`
|
||||
AddressUnparsed *AddressUnparsed `gorm:"-" json:"address_unparsed"`
|
||||
CountryID uint `gorm:"column:b2b_country_id;not null" json:"country_id"`
|
||||
}
|
||||
|
||||
func (Address) TableName() string {
|
||||
return "b2b_addresses"
|
||||
}
|
||||
|
||||
type AddressUnparsed interface{}
|
||||
|
||||
// Address template in Poland
|
||||
type AddressPL struct {
|
||||
PostalCode string `json:"postal_code"` // format: 00-000
|
||||
City string `json:"city"` // e.g. Kraków
|
||||
Voivodeship string `json:"voivodeship"` // e.g. małopolskie (optional but useful)
|
||||
|
||||
Street string `json:"street"` // e.g. Marszałkowska
|
||||
BuildingNo string `json:"building_no"` // e.g. 10, 221B, 12A
|
||||
ApartmentNo string `json:"apartment_no"` // e.g. 5, 12B
|
||||
|
||||
AddressLine2 string `json:"address_line2"` // optional extra info
|
||||
|
||||
Recipient string `json:"recipient"` // name/company
|
||||
}
|
||||
|
||||
// Address template in Great Britain
|
||||
type AddressGB struct {
|
||||
PostalCode string `json:"postal_code"` // e.g. SW1A 1AA
|
||||
PostTown string `json:"post_town"` // e.g. London
|
||||
County string `json:"county"` // optional
|
||||
|
||||
Thoroughfare string `json:"thoroughfare"` // street name, e.g. Baker Street
|
||||
BuildingNo string `json:"building_no"` // e.g. 221B
|
||||
BuildingName string `json:"building_name"` // e.g. Flatiron House
|
||||
SubBuilding string `json:"sub_building"` // e.g. Flat 5, Apt 2
|
||||
|
||||
AddressLine2 string `json:"address_line2"`
|
||||
Recipient string `json:"recipient"`
|
||||
}
|
||||
|
||||
// Address template in Czech Republic
|
||||
type AddressCZ struct {
|
||||
PostalCode string `json:"postal_code"` // usually 110 00 or 11000
|
||||
City string `json:"city"` // e.g. Praha
|
||||
Region string `json:"region"`
|
||||
|
||||
Street string `json:"street"` // may be omitted in some village-style addresses
|
||||
HouseNumber string `json:"house_number"` // descriptive / conscription no.
|
||||
OrientationNumber string `json:"orientation_number"` // optional, often after slash
|
||||
|
||||
AddressLine2 string `json:"address_line2"`
|
||||
Recipient string `json:"recipient"`
|
||||
}
|
||||
|
||||
// Address template in Germany
|
||||
type AddressDE struct {
|
||||
PostalCode string `json:"postal_code"` // e.g. 10115
|
||||
City string `json:"city"` // e.g. Berlin
|
||||
State string `json:"state"` // Bundesland, optional
|
||||
|
||||
Street string `json:"street"` // e.g. Unter den Linden
|
||||
HouseNumber string `json:"house_number"` // e.g. 77, 12a
|
||||
|
||||
AddressLine2 string `json:"address_line2"` // extra details
|
||||
Recipient string `json:"recipient"`
|
||||
}
|
||||
24
app/model/cart.go
Normal file
24
app/model/cart.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package model
|
||||
|
||||
type CustomerCart struct {
|
||||
CartID uint `gorm:"column:cart_id;primaryKey;autoIncrement" json:"cart_id"`
|
||||
UserID uint `gorm:"column:user_id;not null;index" json:"-"`
|
||||
Name *string `gorm:"column:name;size:255" json:"name,omitempty"`
|
||||
Products []CartProduct `gorm:"foreignKey:CartID;references:CartID" json:"products,omitempty"`
|
||||
}
|
||||
|
||||
func (CustomerCart) TableName() string {
|
||||
return "b2b_customer_carts"
|
||||
}
|
||||
|
||||
type CartProduct struct {
|
||||
ID uint `gorm:"column:id;primaryKey;autoIncrement" json:"-"`
|
||||
CartID uint `gorm:"column:cart_id;not null;index" json:"-"`
|
||||
ProductID uint `gorm:"column:product_id;not null" json:"product_id"`
|
||||
ProductAttributeID *uint `gorm:"column:product_attribute_id" json:"product_attribute_id,omitempty"`
|
||||
Amount uint `gorm:"column:amount;not null" json:"amount"`
|
||||
}
|
||||
|
||||
func (CartProduct) TableName() string {
|
||||
return "b2b_carts_products"
|
||||
}
|
||||
35
app/model/category.go
Normal file
35
app/model/category.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package model
|
||||
|
||||
type ScannedCategory struct {
|
||||
CategoryID uint `gorm:"column:category_id;primaryKey"`
|
||||
Name string `gorm:"column:name"`
|
||||
Active uint `gorm:"column:active"`
|
||||
Position uint `gorm:"column:position"`
|
||||
ParentID uint `gorm:"column:id_parent"`
|
||||
IsRoot uint `gorm:"column:is_root_category"`
|
||||
LinkRewrite string `gorm:"column:link_rewrite"`
|
||||
IsoCode string `gorm:"column:iso_code"`
|
||||
|
||||
Visited bool // this is for internal backend use only
|
||||
Filter string // filter applicable to this category
|
||||
}
|
||||
|
||||
type Category struct {
|
||||
CategoryID uint `json:"category_id" form:"category_id"`
|
||||
Label string `json:"label" form:"label"`
|
||||
// Active bool `json:"active" form:"active"`
|
||||
Params CategoryParams `json:"params" form:"params"`
|
||||
Children []Category `json:"children" form:"children"`
|
||||
}
|
||||
|
||||
type CategoryParams struct {
|
||||
CategoryID uint `json:"category_id" form:"category_id"`
|
||||
LinkRewrite string `json:"link_rewrite" form:"link_rewrite"`
|
||||
Locale string `json:"locale" form:"locale"`
|
||||
Filter string `json:"filter" form:"filter"`
|
||||
}
|
||||
|
||||
type CategoryInBreadcrumb struct {
|
||||
CategoryID uint `json:"category_id" form:"category_id"`
|
||||
Name string `json:"name" form:"name"`
|
||||
}
|
||||
15
app/model/countries.go
Normal file
15
app/model/countries.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package model
|
||||
|
||||
// Represents a country together with its associated currency
|
||||
type Country struct {
|
||||
ID uint `gorm:"primaryKey;column:id" json:"id"`
|
||||
Name string `gorm:"column:name" json:"name"`
|
||||
Flag string `gorm:"size:16;not null;column:flag" json:"flag"`
|
||||
|
||||
CurrencyID uint `gorm:"column:b2b_id_currency" json:"currency_id"`
|
||||
Currency *Currency `gorm:"foreignKey:CurrencyID" json:"currency,omitempty"`
|
||||
}
|
||||
|
||||
func (Country) TableName() string {
|
||||
return "b2b_countries"
|
||||
}
|
||||
25
app/model/currency.go
Normal file
25
app/model/currency.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
type Currency struct {
|
||||
ID int `json:"id"`
|
||||
PsIDCurrency uint `json:"ps_id_currency"`
|
||||
IsDefault bool `json:"is_default"`
|
||||
IsActive bool `json:"is_active"`
|
||||
ConversionRate *float64 `json:"conversion_rate,omitempty"`
|
||||
}
|
||||
|
||||
func (Currency) TableName() string {
|
||||
return "b2b_currencies"
|
||||
}
|
||||
|
||||
type CurrencyRate struct {
|
||||
B2bIdCurrency uint `json:"b2b_id_currency"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
ConversionRate *float64 `json:"conversion_rate,omitempty"`
|
||||
}
|
||||
|
||||
func (CurrencyRate) TableName() string {
|
||||
return "b2b_currency_rates"
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.ma-al.com/goc_daniel/b2b/app/delivery/middleware/perms"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -13,7 +14,8 @@ type Customer struct {
|
||||
Password string `gorm:"size:255" json:"-"` // Hashed password, not exposed in JSON
|
||||
FirstName string `gorm:"size:100" json:"first_name"`
|
||||
LastName string `gorm:"size:100" json:"last_name"`
|
||||
Role CustomerRole `gorm:"type:varchar(20);default:'user'" json:"role"`
|
||||
RoleID uint `gorm:"column:role_id;not null;default:1" json:"-"`
|
||||
Role *Role `gorm:"foreignKey:RoleID" json:"role,omitempty"`
|
||||
Provider AuthProvider `gorm:"type:varchar(20);default:'local'" json:"provider"`
|
||||
ProviderID string `gorm:"size:255" json:"provider_id,omitempty"` // ID from OAuth provider
|
||||
AvatarURL string `gorm:"size:500" json:"avatar_url,omitempty"`
|
||||
@@ -23,21 +25,26 @@ type Customer struct {
|
||||
EmailVerificationExpires *time.Time `json:"-"`
|
||||
PasswordResetToken string `gorm:"size:255" json:"-"`
|
||||
PasswordResetExpires *time.Time `json:"-"`
|
||||
WebdavToken string `gorm:"size:255" json:"-"`
|
||||
WebdavExpires *time.Time `json:"-"`
|
||||
LastPasswordResetRequest *time.Time `json:"-"`
|
||||
LastLoginAt *time.Time `json:"last_login_at,omitempty"`
|
||||
Lang string `gorm:"size:10;default:'en'" json:"lang"` // User's preferred language
|
||||
LangID uint `gorm:"default:2" json:"lang_id"` // User's preferred language
|
||||
CountryID uint `gorm:"default:2" json:"country_id"` // User's selected country
|
||||
Country *Country `gorm:"foreignKey:CountryID" json:"country,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// CustomerRole represents the role of a user
|
||||
type CustomerRole string
|
||||
|
||||
const (
|
||||
RoleUser CustomerRole = "user"
|
||||
RoleAdmin CustomerRole = "admin"
|
||||
)
|
||||
func (u *Customer) HasPermission(permission perms.Permission) bool {
|
||||
for _, p := range u.Role.Permissions {
|
||||
if p.Name == permission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AuthProvider represents the authentication provider
|
||||
type AuthProvider string
|
||||
@@ -52,16 +59,6 @@ func (Customer) TableName() string {
|
||||
return "b2b_customers"
|
||||
}
|
||||
|
||||
// IsAdmin checks if the user has admin role
|
||||
func (u *Customer) IsAdmin() bool {
|
||||
return u.Role == RoleAdmin
|
||||
}
|
||||
|
||||
// CanManageUsers checks if the user can manage other users
|
||||
func (u *Customer) CanManageUsers() bool {
|
||||
return u.Role == RoleAdmin
|
||||
}
|
||||
|
||||
// FullName returns the user's full name
|
||||
func (u *Customer) FullName() string {
|
||||
if u.FirstName == "" && u.LastName == "" {
|
||||
@@ -72,31 +69,65 @@ func (u *Customer) FullName() string {
|
||||
|
||||
// UserSession represents a user session for JWT claims
|
||||
type UserSession struct {
|
||||
UserID uint `json:"user_id"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
Role CustomerRole `json:"role"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Lang string `json:"lang"`
|
||||
UserID uint `json:"user_id"`
|
||||
Email string `json:"email"`
|
||||
Username string `json:"username"`
|
||||
RoleID uint `json:"role_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
LangID uint `json:"lang_id"`
|
||||
CountryID uint `json:"country_id"`
|
||||
IsActive bool `json:"is_active"`
|
||||
Permissions []perms.Permission `json:"permissions"`
|
||||
}
|
||||
|
||||
func (us *UserSession) HasPermission(permission perms.Permission) bool {
|
||||
for _, p := range us.Permissions {
|
||||
if p == permission {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type UserLocale struct {
|
||||
// User is the Target user if present, otherwise same as Original.
|
||||
// User ought to be used in applications
|
||||
User *Customer
|
||||
// Original user is the one associated with auth token
|
||||
OriginalUser *Customer
|
||||
// Importantly, lang_id used in application is stored as OriginalUser.LangID
|
||||
}
|
||||
|
||||
// ToSession converts User to UserSession
|
||||
func (u *Customer) ToSession() *UserSession {
|
||||
|
||||
return &UserSession{
|
||||
UserID: u.ID,
|
||||
Email: u.Email,
|
||||
Role: u.Role,
|
||||
FirstName: u.FirstName,
|
||||
LastName: u.LastName,
|
||||
Lang: u.Lang,
|
||||
UserID: u.ID,
|
||||
Email: u.Email,
|
||||
RoleID: u.Role.ID,
|
||||
RoleName: u.Role.Name,
|
||||
Permissions: BuildPermissionSlice(u),
|
||||
LangID: u.LangID,
|
||||
CountryID: u.CountryID,
|
||||
IsActive: u.IsActive,
|
||||
}
|
||||
}
|
||||
|
||||
func BuildPermissionSlice(user *Customer) []perms.Permission {
|
||||
var perms []perms.Permission
|
||||
|
||||
for _, p := range user.Role.Permissions {
|
||||
perms = append(perms, p.Name)
|
||||
}
|
||||
|
||||
return perms
|
||||
}
|
||||
|
||||
// LoginRequest represents the login form data
|
||||
type LoginRequest struct {
|
||||
Email string `json:"email" form:"email"`
|
||||
Password string `json:"password" form:"password"`
|
||||
LangID *uint `json:"lang_id" form:"lang_id"`
|
||||
}
|
||||
|
||||
// RegisterRequest represents the initial registration form data
|
||||
@@ -107,7 +138,8 @@ type RegisterRequest struct {
|
||||
ConfirmPassword string `json:"confirm_password" form:"confirm_password"`
|
||||
FirstName string `json:"first_name" form:"first_name"`
|
||||
LastName string `json:"last_name" form:"last_name"`
|
||||
Lang string `form:"lang" json:"lang"`
|
||||
LangID uint `form:"lang_id" json:"lang_id"`
|
||||
CountryID uint `form:"country_id" json:"country_id"`
|
||||
}
|
||||
|
||||
// CompleteRegistrationRequest represents the completion of registration with email verification
|
||||
@@ -142,3 +174,10 @@ type RefreshToken struct {
|
||||
func (RefreshToken) TableName() string {
|
||||
return "b2b_refresh_tokens"
|
||||
}
|
||||
|
||||
type UserInList struct {
|
||||
UserID uint `gorm:"primaryKey;column:id" json:"user_id"`
|
||||
Email string `gorm:"column:email" json:"email"`
|
||||
FirstName string `gorm:"column:first_name" json:"first_name"`
|
||||
LastName string `gorm:"column:last_name" json:"last_name"`
|
||||
}
|
||||
|
||||
26
app/model/dbmodel/ps_access.go
Normal file
26
app/model/dbmodel/ps_access.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAccess = "ps_access"
|
||||
|
||||
// PsAccess mapped from table <ps_access>
|
||||
type PsAccess struct {
|
||||
IDProfile int32 `gorm:"column:id_profile;primaryKey" json:"id_profile"`
|
||||
IDAuthorizationRole int32 `gorm:"column:id_authorization_role;primaryKey" json:"id_authorization_role"`
|
||||
}
|
||||
|
||||
// TableName PsAccess's table name
|
||||
func (*PsAccess) TableName() string {
|
||||
return TableNamePsAccess
|
||||
}
|
||||
|
||||
var PsAccessCols = struct {
|
||||
IDProfile gormcol.Field
|
||||
IDAuthorizationRole gormcol.Field
|
||||
}{
|
||||
IDProfile: gormcol.Field{}.Set((&PsAccess{}).TableName(), "id_profile"),
|
||||
IDAuthorizationRole: gormcol.Field{}.Set((&PsAccess{}).TableName(), "id_authorization_role"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_accessory.go
Normal file
26
app/model/dbmodel/ps_accessory.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAccessory = "ps_accessory"
|
||||
|
||||
// PsAccessory mapped from table <ps_accessory>
|
||||
type PsAccessory struct {
|
||||
IDProduct1 int32 `gorm:"column:id_product_1;not null;index:accessory_product,priority:1" json:"id_product_1"`
|
||||
IDProduct2 int32 `gorm:"column:id_product_2;not null;index:accessory_product,priority:2" json:"id_product_2"`
|
||||
}
|
||||
|
||||
// TableName PsAccessory's table name
|
||||
func (*PsAccessory) TableName() string {
|
||||
return TableNamePsAccessory
|
||||
}
|
||||
|
||||
var PsAccessoryCols = struct {
|
||||
IDProduct1 gormcol.Field
|
||||
IDProduct2 gormcol.Field
|
||||
}{
|
||||
IDProduct1: gormcol.Field{}.Set((&PsAccessory{}).TableName(), "id_product_1"),
|
||||
IDProduct2: gormcol.Field{}.Set((&PsAccessory{}).TableName(), "id_product_2"),
|
||||
}
|
||||
98
app/model/dbmodel/ps_address.go
Normal file
98
app/model/dbmodel/ps_address.go
Normal file
@@ -0,0 +1,98 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsAddress = "ps_address"
|
||||
|
||||
// PsAddress mapped from table <ps_address>
|
||||
type PsAddress struct {
|
||||
IDAddress int32 `gorm:"column:id_address;primaryKey;autoIncrement:true" json:"id_address"`
|
||||
IDCountry int32 `gorm:"column:id_country;not null;index:id_country,priority:1" json:"id_country"`
|
||||
IDState *int32 `gorm:"column:id_state;index:id_state,priority:1" json:"id_state"`
|
||||
IDCustomer int32 `gorm:"column:id_customer;not null;index:address_customer,priority:1" json:"id_customer"`
|
||||
IDManufacturer int32 `gorm:"column:id_manufacturer;not null;index:id_manufacturer,priority:1" json:"id_manufacturer"`
|
||||
IDSupplier int32 `gorm:"column:id_supplier;not null;index:id_supplier,priority:1" json:"id_supplier"`
|
||||
IDWarehouse int32 `gorm:"column:id_warehouse;not null;index:id_warehouse,priority:1" json:"id_warehouse"`
|
||||
Alias string `gorm:"column:alias;not null" json:"alias"`
|
||||
Company *string `gorm:"column:company" json:"company"`
|
||||
Lastname string `gorm:"column:lastname;not null" json:"lastname"`
|
||||
Firstname string `gorm:"column:firstname;not null" json:"firstname"`
|
||||
Address1 string `gorm:"column:address1;not null" json:"address1"`
|
||||
Address2 *string `gorm:"column:address2" json:"address2"`
|
||||
Postcode *string `gorm:"column:postcode" json:"postcode"`
|
||||
City string `gorm:"column:city;not null" json:"city"`
|
||||
Other *string `gorm:"column:other" json:"other"`
|
||||
Phone *string `gorm:"column:phone" json:"phone"`
|
||||
PhoneMobile *string `gorm:"column:phone_mobile" json:"phone_mobile"`
|
||||
VatNumber *string `gorm:"column:vat_number" json:"vat_number"`
|
||||
Dni *string `gorm:"column:dni" json:"dni"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
Active bool `gorm:"column:active;not null;default:1" json:"active"`
|
||||
Deleted bool `gorm:"column:deleted;not null" json:"deleted"`
|
||||
IsNovat int32 `gorm:"column:is_novat;not null" json:"is_novat"`
|
||||
}
|
||||
|
||||
// TableName PsAddress's table name
|
||||
func (*PsAddress) TableName() string {
|
||||
return TableNamePsAddress
|
||||
}
|
||||
|
||||
var PsAddressCols = struct {
|
||||
IDAddress gormcol.Field
|
||||
IDCountry gormcol.Field
|
||||
IDState gormcol.Field
|
||||
IDCustomer gormcol.Field
|
||||
IDManufacturer gormcol.Field
|
||||
IDSupplier gormcol.Field
|
||||
IDWarehouse gormcol.Field
|
||||
Alias gormcol.Field
|
||||
Company gormcol.Field
|
||||
Lastname gormcol.Field
|
||||
Firstname gormcol.Field
|
||||
Address1 gormcol.Field
|
||||
Address2 gormcol.Field
|
||||
Postcode gormcol.Field
|
||||
City gormcol.Field
|
||||
Other gormcol.Field
|
||||
Phone gormcol.Field
|
||||
PhoneMobile gormcol.Field
|
||||
VatNumber gormcol.Field
|
||||
Dni gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
Active gormcol.Field
|
||||
Deleted gormcol.Field
|
||||
IsNovat gormcol.Field
|
||||
}{
|
||||
IDAddress: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_address"),
|
||||
IDCountry: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_country"),
|
||||
IDState: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_state"),
|
||||
IDCustomer: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_customer"),
|
||||
IDManufacturer: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_manufacturer"),
|
||||
IDSupplier: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_supplier"),
|
||||
IDWarehouse: gormcol.Field{}.Set((&PsAddress{}).TableName(), "id_warehouse"),
|
||||
Alias: gormcol.Field{}.Set((&PsAddress{}).TableName(), "alias"),
|
||||
Company: gormcol.Field{}.Set((&PsAddress{}).TableName(), "company"),
|
||||
Lastname: gormcol.Field{}.Set((&PsAddress{}).TableName(), "lastname"),
|
||||
Firstname: gormcol.Field{}.Set((&PsAddress{}).TableName(), "firstname"),
|
||||
Address1: gormcol.Field{}.Set((&PsAddress{}).TableName(), "address1"),
|
||||
Address2: gormcol.Field{}.Set((&PsAddress{}).TableName(), "address2"),
|
||||
Postcode: gormcol.Field{}.Set((&PsAddress{}).TableName(), "postcode"),
|
||||
City: gormcol.Field{}.Set((&PsAddress{}).TableName(), "city"),
|
||||
Other: gormcol.Field{}.Set((&PsAddress{}).TableName(), "other"),
|
||||
Phone: gormcol.Field{}.Set((&PsAddress{}).TableName(), "phone"),
|
||||
PhoneMobile: gormcol.Field{}.Set((&PsAddress{}).TableName(), "phone_mobile"),
|
||||
VatNumber: gormcol.Field{}.Set((&PsAddress{}).TableName(), "vat_number"),
|
||||
Dni: gormcol.Field{}.Set((&PsAddress{}).TableName(), "dni"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsAddress{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsAddress{}).TableName(), "date_upd"),
|
||||
Active: gormcol.Field{}.Set((&PsAddress{}).TableName(), "active"),
|
||||
Deleted: gormcol.Field{}.Set((&PsAddress{}).TableName(), "deleted"),
|
||||
IsNovat: gormcol.Field{}.Set((&PsAddress{}).TableName(), "is_novat"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_address_format.go
Normal file
26
app/model/dbmodel/ps_address_format.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAddressFormat = "ps_address_format"
|
||||
|
||||
// PsAddressFormat mapped from table <ps_address_format>
|
||||
type PsAddressFormat struct {
|
||||
IDCountry int32 `gorm:"column:id_country;primaryKey" json:"id_country"`
|
||||
Format string `gorm:"column:format;not null" json:"format"`
|
||||
}
|
||||
|
||||
// TableName PsAddressFormat's table name
|
||||
func (*PsAddressFormat) TableName() string {
|
||||
return TableNamePsAddressFormat
|
||||
}
|
||||
|
||||
var PsAddressFormatCols = struct {
|
||||
IDCountry gormcol.Field
|
||||
Format gormcol.Field
|
||||
}{
|
||||
IDCountry: gormcol.Field{}.Set((&PsAddressFormat{}).TableName(), "id_country"),
|
||||
Format: gormcol.Field{}.Set((&PsAddressFormat{}).TableName(), "format"),
|
||||
}
|
||||
41
app/model/dbmodel/ps_admin_filter.go
Normal file
41
app/model/dbmodel/ps_admin_filter.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAdminFilter = "ps_admin_filter"
|
||||
|
||||
// PsAdminFilter mapped from table <ps_admin_filter>
|
||||
type PsAdminFilter struct {
|
||||
ID int32 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||
Employee int32 `gorm:"column:employee;not null;uniqueIndex:admin_filter_search_id_idx,priority:1" json:"employee"`
|
||||
Shop int32 `gorm:"column:shop;not null;uniqueIndex:admin_filter_search_id_idx,priority:2" json:"shop"`
|
||||
Controller string `gorm:"column:controller;not null;uniqueIndex:admin_filter_search_id_idx,priority:3" json:"controller"`
|
||||
Action string `gorm:"column:action;not null;uniqueIndex:admin_filter_search_id_idx,priority:4" json:"action"`
|
||||
Filter string `gorm:"column:filter;not null" json:"filter"`
|
||||
FilterID string `gorm:"column:filter_id;not null;uniqueIndex:admin_filter_search_id_idx,priority:5" json:"filter_id"`
|
||||
}
|
||||
|
||||
// TableName PsAdminFilter's table name
|
||||
func (*PsAdminFilter) TableName() string {
|
||||
return TableNamePsAdminFilter
|
||||
}
|
||||
|
||||
var PsAdminFilterCols = struct {
|
||||
ID gormcol.Field
|
||||
Employee gormcol.Field
|
||||
Shop gormcol.Field
|
||||
Controller gormcol.Field
|
||||
Action gormcol.Field
|
||||
Filter gormcol.Field
|
||||
FilterID gormcol.Field
|
||||
}{
|
||||
ID: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "id"),
|
||||
Employee: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "employee"),
|
||||
Shop: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "shop"),
|
||||
Controller: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "controller"),
|
||||
Action: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "action"),
|
||||
Filter: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "filter"),
|
||||
FilterID: gormcol.Field{}.Set((&PsAdminFilter{}).TableName(), "filter_id"),
|
||||
}
|
||||
53
app/model/dbmodel/ps_advice.go
Normal file
53
app/model/dbmodel/ps_advice.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAdvice = "ps_advice"
|
||||
|
||||
// PsAdvice mapped from table <ps_advice>
|
||||
type PsAdvice struct {
|
||||
IDAdvice int32 `gorm:"column:id_advice;primaryKey;autoIncrement:true" json:"id_advice"`
|
||||
IDPsAdvice int32 `gorm:"column:id_ps_advice;not null" json:"id_ps_advice"`
|
||||
IDTab int32 `gorm:"column:id_tab;not null" json:"id_tab"`
|
||||
IdsTab *string `gorm:"column:ids_tab" json:"ids_tab"`
|
||||
Validated bool `gorm:"column:validated;not null" json:"validated"`
|
||||
Hide bool `gorm:"column:hide;not null" json:"hide"`
|
||||
Location string `gorm:"column:location;not null" json:"location"`
|
||||
Selector *string `gorm:"column:selector" json:"selector"`
|
||||
StartDay int32 `gorm:"column:start_day;not null" json:"start_day"`
|
||||
StopDay int32 `gorm:"column:stop_day;not null" json:"stop_day"`
|
||||
Weight *int32 `gorm:"column:weight;default:1" json:"weight"`
|
||||
}
|
||||
|
||||
// TableName PsAdvice's table name
|
||||
func (*PsAdvice) TableName() string {
|
||||
return TableNamePsAdvice
|
||||
}
|
||||
|
||||
var PsAdviceCols = struct {
|
||||
IDAdvice gormcol.Field
|
||||
IDPsAdvice gormcol.Field
|
||||
IDTab gormcol.Field
|
||||
IdsTab gormcol.Field
|
||||
Validated gormcol.Field
|
||||
Hide gormcol.Field
|
||||
Location gormcol.Field
|
||||
Selector gormcol.Field
|
||||
StartDay gormcol.Field
|
||||
StopDay gormcol.Field
|
||||
Weight gormcol.Field
|
||||
}{
|
||||
IDAdvice: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "id_advice"),
|
||||
IDPsAdvice: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "id_ps_advice"),
|
||||
IDTab: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "id_tab"),
|
||||
IdsTab: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "ids_tab"),
|
||||
Validated: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "validated"),
|
||||
Hide: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "hide"),
|
||||
Location: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "location"),
|
||||
Selector: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "selector"),
|
||||
StartDay: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "start_day"),
|
||||
StopDay: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "stop_day"),
|
||||
Weight: gormcol.Field{}.Set((&PsAdvice{}).TableName(), "weight"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_advice_lang.go
Normal file
29
app/model/dbmodel/ps_advice_lang.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAdviceLang = "ps_advice_lang"
|
||||
|
||||
// PsAdviceLang mapped from table <ps_advice_lang>
|
||||
type PsAdviceLang struct {
|
||||
IDAdvice int32 `gorm:"column:id_advice;primaryKey" json:"id_advice"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
HTML *string `gorm:"column:html" json:"html"`
|
||||
}
|
||||
|
||||
// TableName PsAdviceLang's table name
|
||||
func (*PsAdviceLang) TableName() string {
|
||||
return TableNamePsAdviceLang
|
||||
}
|
||||
|
||||
var PsAdviceLangCols = struct {
|
||||
IDAdvice gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
HTML gormcol.Field
|
||||
}{
|
||||
IDAdvice: gormcol.Field{}.Set((&PsAdviceLang{}).TableName(), "id_advice"),
|
||||
IDLang: gormcol.Field{}.Set((&PsAdviceLang{}).TableName(), "id_lang"),
|
||||
HTML: gormcol.Field{}.Set((&PsAdviceLang{}).TableName(), "html"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_alias.go
Normal file
32
app/model/dbmodel/ps_alias.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAlias = "ps_alias"
|
||||
|
||||
// PsAlias mapped from table <ps_alias>
|
||||
type PsAlias struct {
|
||||
IDAlias int32 `gorm:"column:id_alias;primaryKey;autoIncrement:true" json:"id_alias"`
|
||||
Alias string `gorm:"column:alias;not null;uniqueIndex:alias,priority:1" json:"alias"`
|
||||
Search string `gorm:"column:search;not null" json:"search"`
|
||||
Active bool `gorm:"column:active;not null;default:1" json:"active"`
|
||||
}
|
||||
|
||||
// TableName PsAlias's table name
|
||||
func (*PsAlias) TableName() string {
|
||||
return TableNamePsAlias
|
||||
}
|
||||
|
||||
var PsAliasCols = struct {
|
||||
IDAlias gormcol.Field
|
||||
Alias gormcol.Field
|
||||
Search gormcol.Field
|
||||
Active gormcol.Field
|
||||
}{
|
||||
IDAlias: gormcol.Field{}.Set((&PsAlias{}).TableName(), "id_alias"),
|
||||
Alias: gormcol.Field{}.Set((&PsAlias{}).TableName(), "alias"),
|
||||
Search: gormcol.Field{}.Set((&PsAlias{}).TableName(), "search"),
|
||||
Active: gormcol.Field{}.Set((&PsAlias{}).TableName(), "active"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_attachment.go
Normal file
35
app/model/dbmodel/ps_attachment.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttachment = "ps_attachment"
|
||||
|
||||
// PsAttachment mapped from table <ps_attachment>
|
||||
type PsAttachment struct {
|
||||
IDAttachment int32 `gorm:"column:id_attachment;primaryKey;autoIncrement:true" json:"id_attachment"`
|
||||
File string `gorm:"column:file;not null" json:"file"`
|
||||
FileName string `gorm:"column:file_name;not null" json:"file_name"`
|
||||
FileSize int64 `gorm:"column:file_size;not null" json:"file_size"`
|
||||
Mime string `gorm:"column:mime;not null" json:"mime"`
|
||||
}
|
||||
|
||||
// TableName PsAttachment's table name
|
||||
func (*PsAttachment) TableName() string {
|
||||
return TableNamePsAttachment
|
||||
}
|
||||
|
||||
var PsAttachmentCols = struct {
|
||||
IDAttachment gormcol.Field
|
||||
File gormcol.Field
|
||||
FileName gormcol.Field
|
||||
FileSize gormcol.Field
|
||||
Mime gormcol.Field
|
||||
}{
|
||||
IDAttachment: gormcol.Field{}.Set((&PsAttachment{}).TableName(), "id_attachment"),
|
||||
File: gormcol.Field{}.Set((&PsAttachment{}).TableName(), "file"),
|
||||
FileName: gormcol.Field{}.Set((&PsAttachment{}).TableName(), "file_name"),
|
||||
FileSize: gormcol.Field{}.Set((&PsAttachment{}).TableName(), "file_size"),
|
||||
Mime: gormcol.Field{}.Set((&PsAttachment{}).TableName(), "mime"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_attachment_lang.go
Normal file
32
app/model/dbmodel/ps_attachment_lang.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttachmentLang = "ps_attachment_lang"
|
||||
|
||||
// PsAttachmentLang mapped from table <ps_attachment_lang>
|
||||
type PsAttachmentLang struct {
|
||||
IDAttachment int32 `gorm:"column:id_attachment;primaryKey;autoIncrement:true" json:"id_attachment"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Name *string `gorm:"column:name" json:"name"`
|
||||
Description *string `gorm:"column:description" json:"description"`
|
||||
}
|
||||
|
||||
// TableName PsAttachmentLang's table name
|
||||
func (*PsAttachmentLang) TableName() string {
|
||||
return TableNamePsAttachmentLang
|
||||
}
|
||||
|
||||
var PsAttachmentLangCols = struct {
|
||||
IDAttachment gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
Description gormcol.Field
|
||||
}{
|
||||
IDAttachment: gormcol.Field{}.Set((&PsAttachmentLang{}).TableName(), "id_attachment"),
|
||||
IDLang: gormcol.Field{}.Set((&PsAttachmentLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsAttachmentLang{}).TableName(), "name"),
|
||||
Description: gormcol.Field{}.Set((&PsAttachmentLang{}).TableName(), "description"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_attribute.go
Normal file
32
app/model/dbmodel/ps_attribute.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttribute = "ps_attribute"
|
||||
|
||||
// PsAttribute mapped from table <ps_attribute>
|
||||
type PsAttribute struct {
|
||||
IDAttribute int32 `gorm:"column:id_attribute;primaryKey;autoIncrement:true" json:"id_attribute"`
|
||||
IDAttributeGroup int32 `gorm:"column:id_attribute_group;not null;index:attribute_group,priority:1" json:"id_attribute_group"`
|
||||
Color string `gorm:"column:color;not null" json:"color"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
}
|
||||
|
||||
// TableName PsAttribute's table name
|
||||
func (*PsAttribute) TableName() string {
|
||||
return TableNamePsAttribute
|
||||
}
|
||||
|
||||
var PsAttributeCols = struct {
|
||||
IDAttribute gormcol.Field
|
||||
IDAttributeGroup gormcol.Field
|
||||
Color gormcol.Field
|
||||
Position gormcol.Field
|
||||
}{
|
||||
IDAttribute: gormcol.Field{}.Set((&PsAttribute{}).TableName(), "id_attribute"),
|
||||
IDAttributeGroup: gormcol.Field{}.Set((&PsAttribute{}).TableName(), "id_attribute_group"),
|
||||
Color: gormcol.Field{}.Set((&PsAttribute{}).TableName(), "color"),
|
||||
Position: gormcol.Field{}.Set((&PsAttribute{}).TableName(), "position"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_attribute_group.go
Normal file
32
app/model/dbmodel/ps_attribute_group.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeGroup = "ps_attribute_group"
|
||||
|
||||
// PsAttributeGroup mapped from table <ps_attribute_group>
|
||||
type PsAttributeGroup struct {
|
||||
IDAttributeGroup int32 `gorm:"column:id_attribute_group;primaryKey;autoIncrement:true" json:"id_attribute_group"`
|
||||
IsColorGroup bool `gorm:"column:is_color_group;not null" json:"is_color_group"`
|
||||
GroupType string `gorm:"column:group_type;not null" json:"group_type"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeGroup's table name
|
||||
func (*PsAttributeGroup) TableName() string {
|
||||
return TableNamePsAttributeGroup
|
||||
}
|
||||
|
||||
var PsAttributeGroupCols = struct {
|
||||
IDAttributeGroup gormcol.Field
|
||||
IsColorGroup gormcol.Field
|
||||
GroupType gormcol.Field
|
||||
Position gormcol.Field
|
||||
}{
|
||||
IDAttributeGroup: gormcol.Field{}.Set((&PsAttributeGroup{}).TableName(), "id_attribute_group"),
|
||||
IsColorGroup: gormcol.Field{}.Set((&PsAttributeGroup{}).TableName(), "is_color_group"),
|
||||
GroupType: gormcol.Field{}.Set((&PsAttributeGroup{}).TableName(), "group_type"),
|
||||
Position: gormcol.Field{}.Set((&PsAttributeGroup{}).TableName(), "position"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_attribute_group_lang.go
Normal file
32
app/model/dbmodel/ps_attribute_group_lang.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeGroupLang = "ps_attribute_group_lang"
|
||||
|
||||
// PsAttributeGroupLang mapped from table <ps_attribute_group_lang>
|
||||
type PsAttributeGroupLang struct {
|
||||
IDAttributeGroup int32 `gorm:"column:id_attribute_group;primaryKey;index:IDX_4653726C67A664FB,priority:1" json:"id_attribute_group"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey;index:IDX_4653726CBA299860,priority:1" json:"id_lang"`
|
||||
Name string `gorm:"column:name;not null" json:"name"`
|
||||
PublicName string `gorm:"column:public_name;not null" json:"public_name"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeGroupLang's table name
|
||||
func (*PsAttributeGroupLang) TableName() string {
|
||||
return TableNamePsAttributeGroupLang
|
||||
}
|
||||
|
||||
var PsAttributeGroupLangCols = struct {
|
||||
IDAttributeGroup gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
PublicName gormcol.Field
|
||||
}{
|
||||
IDAttributeGroup: gormcol.Field{}.Set((&PsAttributeGroupLang{}).TableName(), "id_attribute_group"),
|
||||
IDLang: gormcol.Field{}.Set((&PsAttributeGroupLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsAttributeGroupLang{}).TableName(), "name"),
|
||||
PublicName: gormcol.Field{}.Set((&PsAttributeGroupLang{}).TableName(), "public_name"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_attribute_group_shop.go
Normal file
26
app/model/dbmodel/ps_attribute_group_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeGroupShop = "ps_attribute_group_shop"
|
||||
|
||||
// PsAttributeGroupShop mapped from table <ps_attribute_group_shop>
|
||||
type PsAttributeGroupShop struct {
|
||||
IDAttributeGroup int32 `gorm:"column:id_attribute_group;primaryKey;index:IDX_DB30BAAC67A664FB,priority:1" json:"id_attribute_group"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;index:IDX_DB30BAAC274A50A0,priority:1" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeGroupShop's table name
|
||||
func (*PsAttributeGroupShop) TableName() string {
|
||||
return TableNamePsAttributeGroupShop
|
||||
}
|
||||
|
||||
var PsAttributeGroupShopCols = struct {
|
||||
IDAttributeGroup gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDAttributeGroup: gormcol.Field{}.Set((&PsAttributeGroupShop{}).TableName(), "id_attribute_group"),
|
||||
IDShop: gormcol.Field{}.Set((&PsAttributeGroupShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_attribute_impact.go
Normal file
35
app/model/dbmodel/ps_attribute_impact.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeImpact = "ps_attribute_impact"
|
||||
|
||||
// PsAttributeImpact mapped from table <ps_attribute_impact>
|
||||
type PsAttributeImpact struct {
|
||||
IDAttributeImpact int32 `gorm:"column:id_attribute_impact;primaryKey;autoIncrement:true" json:"id_attribute_impact"`
|
||||
IDProduct int32 `gorm:"column:id_product;not null;uniqueIndex:id_product,priority:1" json:"id_product"`
|
||||
IDAttribute int32 `gorm:"column:id_attribute;not null;uniqueIndex:id_product,priority:2" json:"id_attribute"`
|
||||
Weight float64 `gorm:"column:weight;not null" json:"weight"`
|
||||
Price float64 `gorm:"column:price;not null" json:"price"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeImpact's table name
|
||||
func (*PsAttributeImpact) TableName() string {
|
||||
return TableNamePsAttributeImpact
|
||||
}
|
||||
|
||||
var PsAttributeImpactCols = struct {
|
||||
IDAttributeImpact gormcol.Field
|
||||
IDProduct gormcol.Field
|
||||
IDAttribute gormcol.Field
|
||||
Weight gormcol.Field
|
||||
Price gormcol.Field
|
||||
}{
|
||||
IDAttributeImpact: gormcol.Field{}.Set((&PsAttributeImpact{}).TableName(), "id_attribute_impact"),
|
||||
IDProduct: gormcol.Field{}.Set((&PsAttributeImpact{}).TableName(), "id_product"),
|
||||
IDAttribute: gormcol.Field{}.Set((&PsAttributeImpact{}).TableName(), "id_attribute"),
|
||||
Weight: gormcol.Field{}.Set((&PsAttributeImpact{}).TableName(), "weight"),
|
||||
Price: gormcol.Field{}.Set((&PsAttributeImpact{}).TableName(), "price"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_attribute_lang.go
Normal file
29
app/model/dbmodel/ps_attribute_lang.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeLang = "ps_attribute_lang"
|
||||
|
||||
// PsAttributeLang mapped from table <ps_attribute_lang>
|
||||
type PsAttributeLang struct {
|
||||
IDAttribute int32 `gorm:"column:id_attribute;primaryKey;index:IDX_3ABE46A77A4F53DC,priority:1" json:"id_attribute"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey;index:IDX_3ABE46A7BA299860,priority:1" json:"id_lang"`
|
||||
Name string `gorm:"column:name;not null" json:"name"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeLang's table name
|
||||
func (*PsAttributeLang) TableName() string {
|
||||
return TableNamePsAttributeLang
|
||||
}
|
||||
|
||||
var PsAttributeLangCols = struct {
|
||||
IDAttribute gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
}{
|
||||
IDAttribute: gormcol.Field{}.Set((&PsAttributeLang{}).TableName(), "id_attribute"),
|
||||
IDLang: gormcol.Field{}.Set((&PsAttributeLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsAttributeLang{}).TableName(), "name"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_attribute_shop.go
Normal file
26
app/model/dbmodel/ps_attribute_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAttributeShop = "ps_attribute_shop"
|
||||
|
||||
// PsAttributeShop mapped from table <ps_attribute_shop>
|
||||
type PsAttributeShop struct {
|
||||
IDAttribute int32 `gorm:"column:id_attribute;primaryKey;index:IDX_A7DD8E677A4F53DC,priority:1" json:"id_attribute"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;index:IDX_A7DD8E67274A50A0,priority:1" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsAttributeShop's table name
|
||||
func (*PsAttributeShop) TableName() string {
|
||||
return TableNamePsAttributeShop
|
||||
}
|
||||
|
||||
var PsAttributeShopCols = struct {
|
||||
IDAttribute gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDAttribute: gormcol.Field{}.Set((&PsAttributeShop{}).TableName(), "id_attribute"),
|
||||
IDShop: gormcol.Field{}.Set((&PsAttributeShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_authorization_role.go
Normal file
26
app/model/dbmodel/ps_authorization_role.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsAuthorizationRole = "ps_authorization_role"
|
||||
|
||||
// PsAuthorizationRole mapped from table <ps_authorization_role>
|
||||
type PsAuthorizationRole struct {
|
||||
IDAuthorizationRole int32 `gorm:"column:id_authorization_role;primaryKey;autoIncrement:true" json:"id_authorization_role"`
|
||||
Slug string `gorm:"column:slug;not null;uniqueIndex:slug,priority:1" json:"slug"`
|
||||
}
|
||||
|
||||
// TableName PsAuthorizationRole's table name
|
||||
func (*PsAuthorizationRole) TableName() string {
|
||||
return TableNamePsAuthorizationRole
|
||||
}
|
||||
|
||||
var PsAuthorizationRoleCols = struct {
|
||||
IDAuthorizationRole gormcol.Field
|
||||
Slug gormcol.Field
|
||||
}{
|
||||
IDAuthorizationRole: gormcol.Field{}.Set((&PsAuthorizationRole{}).TableName(), "id_authorization_role"),
|
||||
Slug: gormcol.Field{}.Set((&PsAuthorizationRole{}).TableName(), "slug"),
|
||||
}
|
||||
44
app/model/dbmodel/ps_badge.go
Normal file
44
app/model/dbmodel/ps_badge.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsBadge = "ps_badge"
|
||||
|
||||
// PsBadge mapped from table <ps_badge>
|
||||
type PsBadge struct {
|
||||
IDBadge int32 `gorm:"column:id_badge;primaryKey;autoIncrement:true" json:"id_badge"`
|
||||
IDPsBadge int32 `gorm:"column:id_ps_badge;not null" json:"id_ps_badge"`
|
||||
Type string `gorm:"column:type;not null" json:"type"`
|
||||
IDGroup int32 `gorm:"column:id_group;not null" json:"id_group"`
|
||||
GroupPosition int32 `gorm:"column:group_position;not null" json:"group_position"`
|
||||
Scoring int32 `gorm:"column:scoring;not null" json:"scoring"`
|
||||
Awb *int32 `gorm:"column:awb" json:"awb"`
|
||||
Validated bool `gorm:"column:validated;not null" json:"validated"`
|
||||
}
|
||||
|
||||
// TableName PsBadge's table name
|
||||
func (*PsBadge) TableName() string {
|
||||
return TableNamePsBadge
|
||||
}
|
||||
|
||||
var PsBadgeCols = struct {
|
||||
IDBadge gormcol.Field
|
||||
IDPsBadge gormcol.Field
|
||||
Type gormcol.Field
|
||||
IDGroup gormcol.Field
|
||||
GroupPosition gormcol.Field
|
||||
Scoring gormcol.Field
|
||||
Awb gormcol.Field
|
||||
Validated gormcol.Field
|
||||
}{
|
||||
IDBadge: gormcol.Field{}.Set((&PsBadge{}).TableName(), "id_badge"),
|
||||
IDPsBadge: gormcol.Field{}.Set((&PsBadge{}).TableName(), "id_ps_badge"),
|
||||
Type: gormcol.Field{}.Set((&PsBadge{}).TableName(), "type"),
|
||||
IDGroup: gormcol.Field{}.Set((&PsBadge{}).TableName(), "id_group"),
|
||||
GroupPosition: gormcol.Field{}.Set((&PsBadge{}).TableName(), "group_position"),
|
||||
Scoring: gormcol.Field{}.Set((&PsBadge{}).TableName(), "scoring"),
|
||||
Awb: gormcol.Field{}.Set((&PsBadge{}).TableName(), "awb"),
|
||||
Validated: gormcol.Field{}.Set((&PsBadge{}).TableName(), "validated"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_badge_lang.go
Normal file
35
app/model/dbmodel/ps_badge_lang.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsBadgeLang = "ps_badge_lang"
|
||||
|
||||
// PsBadgeLang mapped from table <ps_badge_lang>
|
||||
type PsBadgeLang struct {
|
||||
IDBadge int32 `gorm:"column:id_badge;primaryKey" json:"id_badge"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Name *string `gorm:"column:name" json:"name"`
|
||||
Description *string `gorm:"column:description" json:"description"`
|
||||
GroupName *string `gorm:"column:group_name" json:"group_name"`
|
||||
}
|
||||
|
||||
// TableName PsBadgeLang's table name
|
||||
func (*PsBadgeLang) TableName() string {
|
||||
return TableNamePsBadgeLang
|
||||
}
|
||||
|
||||
var PsBadgeLangCols = struct {
|
||||
IDBadge gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
Description gormcol.Field
|
||||
GroupName gormcol.Field
|
||||
}{
|
||||
IDBadge: gormcol.Field{}.Set((&PsBadgeLang{}).TableName(), "id_badge"),
|
||||
IDLang: gormcol.Field{}.Set((&PsBadgeLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsBadgeLang{}).TableName(), "name"),
|
||||
Description: gormcol.Field{}.Set((&PsBadgeLang{}).TableName(), "description"),
|
||||
GroupName: gormcol.Field{}.Set((&PsBadgeLang{}).TableName(), "group_name"),
|
||||
}
|
||||
83
app/model/dbmodel/ps_carrier.go
Normal file
83
app/model/dbmodel/ps_carrier.go
Normal file
@@ -0,0 +1,83 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrier = "ps_carrier"
|
||||
|
||||
// PsCarrier mapped from table <ps_carrier>
|
||||
type PsCarrier struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey;autoIncrement:true" json:"id_carrier"`
|
||||
IDReference int32 `gorm:"column:id_reference;not null;index:reference,priority:1" json:"id_reference"`
|
||||
IDTaxRulesGroup *int32 `gorm:"column:id_tax_rules_group;index:id_tax_rules_group,priority:1" json:"id_tax_rules_group"`
|
||||
Name string `gorm:"column:name;not null" json:"name"`
|
||||
URL *string `gorm:"column:url" json:"url"`
|
||||
Active bool `gorm:"column:active;not null;index:deleted,priority:2;index:reference,priority:3" json:"active"`
|
||||
Deleted bool `gorm:"column:deleted;not null;index:deleted,priority:1;index:reference,priority:2" json:"deleted"`
|
||||
ShippingHandling bool `gorm:"column:shipping_handling;not null;default:1" json:"shipping_handling"`
|
||||
RangeBehavior bool `gorm:"column:range_behavior;not null" json:"range_behavior"`
|
||||
IsModule bool `gorm:"column:is_module;not null" json:"is_module"`
|
||||
IsFree bool `gorm:"column:is_free;not null" json:"is_free"`
|
||||
ShippingExternal bool `gorm:"column:shipping_external;not null" json:"shipping_external"`
|
||||
NeedRange bool `gorm:"column:need_range;not null" json:"need_range"`
|
||||
ExternalModuleName *string `gorm:"column:external_module_name" json:"external_module_name"`
|
||||
ShippingMethod int32 `gorm:"column:shipping_method;not null" json:"shipping_method"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
MaxWidth *int32 `gorm:"column:max_width" json:"max_width"`
|
||||
MaxHeight *int32 `gorm:"column:max_height" json:"max_height"`
|
||||
MaxDepth *int32 `gorm:"column:max_depth" json:"max_depth"`
|
||||
MaxWeight *float64 `gorm:"column:max_weight;default:0.000000" json:"max_weight"`
|
||||
Grade *int32 `gorm:"column:grade" json:"grade"`
|
||||
}
|
||||
|
||||
// TableName PsCarrier's table name
|
||||
func (*PsCarrier) TableName() string {
|
||||
return TableNamePsCarrier
|
||||
}
|
||||
|
||||
var PsCarrierCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDReference gormcol.Field
|
||||
IDTaxRulesGroup gormcol.Field
|
||||
Name gormcol.Field
|
||||
URL gormcol.Field
|
||||
Active gormcol.Field
|
||||
Deleted gormcol.Field
|
||||
ShippingHandling gormcol.Field
|
||||
RangeBehavior gormcol.Field
|
||||
IsModule gormcol.Field
|
||||
IsFree gormcol.Field
|
||||
ShippingExternal gormcol.Field
|
||||
NeedRange gormcol.Field
|
||||
ExternalModuleName gormcol.Field
|
||||
ShippingMethod gormcol.Field
|
||||
Position gormcol.Field
|
||||
MaxWidth gormcol.Field
|
||||
MaxHeight gormcol.Field
|
||||
MaxDepth gormcol.Field
|
||||
MaxWeight gormcol.Field
|
||||
Grade gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "id_carrier"),
|
||||
IDReference: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "id_reference"),
|
||||
IDTaxRulesGroup: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "id_tax_rules_group"),
|
||||
Name: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "name"),
|
||||
URL: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "url"),
|
||||
Active: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "active"),
|
||||
Deleted: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "deleted"),
|
||||
ShippingHandling: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "shipping_handling"),
|
||||
RangeBehavior: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "range_behavior"),
|
||||
IsModule: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "is_module"),
|
||||
IsFree: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "is_free"),
|
||||
ShippingExternal: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "shipping_external"),
|
||||
NeedRange: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "need_range"),
|
||||
ExternalModuleName: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "external_module_name"),
|
||||
ShippingMethod: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "shipping_method"),
|
||||
Position: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "position"),
|
||||
MaxWidth: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "max_width"),
|
||||
MaxHeight: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "max_height"),
|
||||
MaxDepth: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "max_depth"),
|
||||
MaxWeight: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "max_weight"),
|
||||
Grade: gormcol.Field{}.Set((&PsCarrier{}).TableName(), "grade"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_carrier_group.go
Normal file
26
app/model/dbmodel/ps_carrier_group.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrierGroup = "ps_carrier_group"
|
||||
|
||||
// PsCarrierGroup mapped from table <ps_carrier_group>
|
||||
type PsCarrierGroup struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
IDGroup int32 `gorm:"column:id_group;primaryKey" json:"id_group"`
|
||||
}
|
||||
|
||||
// TableName PsCarrierGroup's table name
|
||||
func (*PsCarrierGroup) TableName() string {
|
||||
return TableNamePsCarrierGroup
|
||||
}
|
||||
|
||||
var PsCarrierGroupCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDGroup gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrierGroup{}).TableName(), "id_carrier"),
|
||||
IDGroup: gormcol.Field{}.Set((&PsCarrierGroup{}).TableName(), "id_group"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_carrier_lang.go
Normal file
32
app/model/dbmodel/ps_carrier_lang.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrierLang = "ps_carrier_lang"
|
||||
|
||||
// PsCarrierLang mapped from table <ps_carrier_lang>
|
||||
type PsCarrierLang struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;default:1" json:"id_shop"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Delay *string `gorm:"column:delay" json:"delay"`
|
||||
}
|
||||
|
||||
// TableName PsCarrierLang's table name
|
||||
func (*PsCarrierLang) TableName() string {
|
||||
return TableNamePsCarrierLang
|
||||
}
|
||||
|
||||
var PsCarrierLangCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Delay gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrierLang{}).TableName(), "id_carrier"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCarrierLang{}).TableName(), "id_shop"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCarrierLang{}).TableName(), "id_lang"),
|
||||
Delay: gormcol.Field{}.Set((&PsCarrierLang{}).TableName(), "delay"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_carrier_shop.go
Normal file
26
app/model/dbmodel/ps_carrier_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrierShop = "ps_carrier_shop"
|
||||
|
||||
// PsCarrierShop mapped from table <ps_carrier_shop>
|
||||
type PsCarrierShop struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;index:id_shop,priority:1" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsCarrierShop's table name
|
||||
func (*PsCarrierShop) TableName() string {
|
||||
return TableNamePsCarrierShop
|
||||
}
|
||||
|
||||
var PsCarrierShopCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrierShop{}).TableName(), "id_carrier"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCarrierShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_carrier_tax_rules_group_shop.go
Normal file
29
app/model/dbmodel/ps_carrier_tax_rules_group_shop.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrierTaxRulesGroupShop = "ps_carrier_tax_rules_group_shop"
|
||||
|
||||
// PsCarrierTaxRulesGroupShop mapped from table <ps_carrier_tax_rules_group_shop>
|
||||
type PsCarrierTaxRulesGroupShop struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
IDTaxRulesGroup int32 `gorm:"column:id_tax_rules_group;primaryKey" json:"id_tax_rules_group"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsCarrierTaxRulesGroupShop's table name
|
||||
func (*PsCarrierTaxRulesGroupShop) TableName() string {
|
||||
return TableNamePsCarrierTaxRulesGroupShop
|
||||
}
|
||||
|
||||
var PsCarrierTaxRulesGroupShopCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDTaxRulesGroup gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrierTaxRulesGroupShop{}).TableName(), "id_carrier"),
|
||||
IDTaxRulesGroup: gormcol.Field{}.Set((&PsCarrierTaxRulesGroupShop{}).TableName(), "id_tax_rules_group"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCarrierTaxRulesGroupShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_carrier_zone.go
Normal file
26
app/model/dbmodel/ps_carrier_zone.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCarrierZone = "ps_carrier_zone"
|
||||
|
||||
// PsCarrierZone mapped from table <ps_carrier_zone>
|
||||
type PsCarrierZone struct {
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
IDZone int32 `gorm:"column:id_zone;primaryKey" json:"id_zone"`
|
||||
}
|
||||
|
||||
// TableName PsCarrierZone's table name
|
||||
func (*PsCarrierZone) TableName() string {
|
||||
return TableNamePsCarrierZone
|
||||
}
|
||||
|
||||
var PsCarrierZoneCols = struct {
|
||||
IDCarrier gormcol.Field
|
||||
IDZone gormcol.Field
|
||||
}{
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCarrierZone{}).TableName(), "id_carrier"),
|
||||
IDZone: gormcol.Field{}.Set((&PsCarrierZone{}).TableName(), "id_zone"),
|
||||
}
|
||||
92
app/model/dbmodel/ps_cart.go
Normal file
92
app/model/dbmodel/ps_cart.go
Normal file
@@ -0,0 +1,92 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCart = "ps_cart"
|
||||
|
||||
// PsCart mapped from table <ps_cart>
|
||||
type PsCart struct {
|
||||
IDCart int32 `gorm:"column:id_cart;primaryKey;autoIncrement:true" json:"id_cart"`
|
||||
IDShopGroup int32 `gorm:"column:id_shop_group;not null;index:id_shop_group,priority:1;default:1" json:"id_shop_group"`
|
||||
IDShop int32 `gorm:"column:id_shop;not null;index:id_shop,priority:1;index:id_shop_2,priority:1;default:1" json:"id_shop"`
|
||||
IDCarrier int32 `gorm:"column:id_carrier;not null;index:id_carrier,priority:1" json:"id_carrier"`
|
||||
DeliveryOption string `gorm:"column:delivery_option;not null" json:"delivery_option"`
|
||||
IDLang int32 `gorm:"column:id_lang;not null;index:id_lang,priority:1" json:"id_lang"`
|
||||
IDAddressDelivery int32 `gorm:"column:id_address_delivery;not null;index:id_address_delivery,priority:1" json:"id_address_delivery"`
|
||||
IDAddressInvoice int32 `gorm:"column:id_address_invoice;not null;index:id_address_invoice,priority:1" json:"id_address_invoice"`
|
||||
IDCurrency int32 `gorm:"column:id_currency;not null;index:id_currency,priority:1" json:"id_currency"`
|
||||
IDCustomer int32 `gorm:"column:id_customer;not null;index:cart_customer,priority:1" json:"id_customer"`
|
||||
IDGuest int32 `gorm:"column:id_guest;not null;index:id_guest,priority:1" json:"id_guest"`
|
||||
SecureKey string `gorm:"column:secure_key;not null;default:-1" json:"secure_key"`
|
||||
Recyclable bool `gorm:"column:recyclable;not null;default:1" json:"recyclable"`
|
||||
Gift bool `gorm:"column:gift;not null" json:"gift"`
|
||||
GiftMessage *string `gorm:"column:gift_message" json:"gift_message"`
|
||||
MobileTheme bool `gorm:"column:mobile_theme;not null" json:"mobile_theme"`
|
||||
AllowSeperatedPackage bool `gorm:"column:allow_seperated_package;not null" json:"allow_seperated_package"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null;index:id_shop,priority:2" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null;index:id_shop_2,priority:2" json:"date_upd"`
|
||||
CheckoutSessionData *string `gorm:"column:checkout_session_data" json:"checkout_session_data"`
|
||||
CustomeShippingPriceNetto *float64 `gorm:"column:custome_shipping_price_netto" json:"custome_shipping_price_netto"`
|
||||
CustomeShippingPrice *float64 `gorm:"column:custome_shipping_price" json:"custome_shipping_price"`
|
||||
CustomeShippingTaxRate *float64 `gorm:"column:custome_shipping_tax_rate" json:"custome_shipping_tax_rate"`
|
||||
}
|
||||
|
||||
// TableName PsCart's table name
|
||||
func (*PsCart) TableName() string {
|
||||
return TableNamePsCart
|
||||
}
|
||||
|
||||
var PsCartCols = struct {
|
||||
IDCart gormcol.Field
|
||||
IDShopGroup gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
IDCarrier gormcol.Field
|
||||
DeliveryOption gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
IDAddressDelivery gormcol.Field
|
||||
IDAddressInvoice gormcol.Field
|
||||
IDCurrency gormcol.Field
|
||||
IDCustomer gormcol.Field
|
||||
IDGuest gormcol.Field
|
||||
SecureKey gormcol.Field
|
||||
Recyclable gormcol.Field
|
||||
Gift gormcol.Field
|
||||
GiftMessage gormcol.Field
|
||||
MobileTheme gormcol.Field
|
||||
AllowSeperatedPackage gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
CheckoutSessionData gormcol.Field
|
||||
CustomeShippingPriceNetto gormcol.Field
|
||||
CustomeShippingPrice gormcol.Field
|
||||
CustomeShippingTaxRate gormcol.Field
|
||||
}{
|
||||
IDCart: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_cart"),
|
||||
IDShopGroup: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_shop_group"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_shop"),
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_carrier"),
|
||||
DeliveryOption: gormcol.Field{}.Set((&PsCart{}).TableName(), "delivery_option"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_lang"),
|
||||
IDAddressDelivery: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_address_delivery"),
|
||||
IDAddressInvoice: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_address_invoice"),
|
||||
IDCurrency: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_currency"),
|
||||
IDCustomer: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_customer"),
|
||||
IDGuest: gormcol.Field{}.Set((&PsCart{}).TableName(), "id_guest"),
|
||||
SecureKey: gormcol.Field{}.Set((&PsCart{}).TableName(), "secure_key"),
|
||||
Recyclable: gormcol.Field{}.Set((&PsCart{}).TableName(), "recyclable"),
|
||||
Gift: gormcol.Field{}.Set((&PsCart{}).TableName(), "gift"),
|
||||
GiftMessage: gormcol.Field{}.Set((&PsCart{}).TableName(), "gift_message"),
|
||||
MobileTheme: gormcol.Field{}.Set((&PsCart{}).TableName(), "mobile_theme"),
|
||||
AllowSeperatedPackage: gormcol.Field{}.Set((&PsCart{}).TableName(), "allow_seperated_package"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCart{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsCart{}).TableName(), "date_upd"),
|
||||
CheckoutSessionData: gormcol.Field{}.Set((&PsCart{}).TableName(), "checkout_session_data"),
|
||||
CustomeShippingPriceNetto: gormcol.Field{}.Set((&PsCart{}).TableName(), "custome_shipping_price_netto"),
|
||||
CustomeShippingPrice: gormcol.Field{}.Set((&PsCart{}).TableName(), "custome_shipping_price"),
|
||||
CustomeShippingTaxRate: gormcol.Field{}.Set((&PsCart{}).TableName(), "custome_shipping_tax_rate"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_cart_rule.go
Normal file
26
app/model/dbmodel/ps_cart_cart_rule.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartCartRule = "ps_cart_cart_rule"
|
||||
|
||||
// PsCartCartRule mapped from table <ps_cart_cart_rule>
|
||||
type PsCartCartRule struct {
|
||||
IDCart int32 `gorm:"column:id_cart;primaryKey" json:"id_cart"`
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey;index:id_cart_rule,priority:1" json:"id_cart_rule"`
|
||||
}
|
||||
|
||||
// TableName PsCartCartRule's table name
|
||||
func (*PsCartCartRule) TableName() string {
|
||||
return TableNamePsCartCartRule
|
||||
}
|
||||
|
||||
var PsCartCartRuleCols = struct {
|
||||
IDCart gormcol.Field
|
||||
IDCartRule gormcol.Field
|
||||
}{
|
||||
IDCart: gormcol.Field{}.Set((&PsCartCartRule{}).TableName(), "id_cart"),
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartCartRule{}).TableName(), "id_cart_rule"),
|
||||
}
|
||||
47
app/model/dbmodel/ps_cart_product.go
Normal file
47
app/model/dbmodel/ps_cart_product.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCartProduct = "ps_cart_product"
|
||||
|
||||
// PsCartProduct mapped from table <ps_cart_product>
|
||||
type PsCartProduct struct {
|
||||
IDCart int32 `gorm:"column:id_cart;primaryKey;index:id_cart_order,priority:1" json:"id_cart"`
|
||||
IDProduct int32 `gorm:"column:id_product;primaryKey;index:id_cart_order,priority:3" json:"id_product"`
|
||||
IDAddressDelivery int32 `gorm:"column:id_address_delivery;primaryKey" json:"id_address_delivery"`
|
||||
IDShop int32 `gorm:"column:id_shop;not null;default:1" json:"id_shop"`
|
||||
IDProductAttribute int32 `gorm:"column:id_product_attribute;primaryKey;index:id_cart_order,priority:4;index:id_product_attribute,priority:1" json:"id_product_attribute"`
|
||||
IDCustomization int32 `gorm:"column:id_customization;primaryKey" json:"id_customization"`
|
||||
Quantity int32 `gorm:"column:quantity;not null" json:"quantity"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null;index:id_cart_order,priority:2" json:"date_add"`
|
||||
}
|
||||
|
||||
// TableName PsCartProduct's table name
|
||||
func (*PsCartProduct) TableName() string {
|
||||
return TableNamePsCartProduct
|
||||
}
|
||||
|
||||
var PsCartProductCols = struct {
|
||||
IDCart gormcol.Field
|
||||
IDProduct gormcol.Field
|
||||
IDAddressDelivery gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
IDProductAttribute gormcol.Field
|
||||
IDCustomization gormcol.Field
|
||||
Quantity gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
}{
|
||||
IDCart: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_cart"),
|
||||
IDProduct: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_product"),
|
||||
IDAddressDelivery: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_address_delivery"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_shop"),
|
||||
IDProductAttribute: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_product_attribute"),
|
||||
IDCustomization: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "id_customization"),
|
||||
Quantity: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "quantity"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCartProduct{}).TableName(), "date_add"),
|
||||
}
|
||||
122
app/model/dbmodel/ps_cart_rule.go
Normal file
122
app/model/dbmodel/ps_cart_rule.go
Normal file
@@ -0,0 +1,122 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCartRule = "ps_cart_rule"
|
||||
|
||||
// PsCartRule mapped from table <ps_cart_rule>
|
||||
type PsCartRule struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey;autoIncrement:true" json:"id_cart_rule"`
|
||||
IDCustomer int32 `gorm:"column:id_customer;not null;index:id_customer,priority:1;index:id_customer_2,priority:1" json:"id_customer"`
|
||||
DateFrom time.Time `gorm:"column:date_from;not null;index:date_from,priority:1" json:"date_from"`
|
||||
DateTo time.Time `gorm:"column:date_to;not null;index:date_to,priority:1;index:group_restriction,priority:3;index:group_restriction_2,priority:4;index:id_customer,priority:3;index:id_customer_2,priority:4" json:"date_to"`
|
||||
Description *string `gorm:"column:description" json:"description"`
|
||||
Quantity int32 `gorm:"column:quantity;not null" json:"quantity"`
|
||||
QuantityPerUser int32 `gorm:"column:quantity_per_user;not null" json:"quantity_per_user"`
|
||||
Priority int32 `gorm:"column:priority;not null;default:1" json:"priority"`
|
||||
PartialUse bool `gorm:"column:partial_use;not null" json:"partial_use"`
|
||||
Code string `gorm:"column:code;not null" json:"code"`
|
||||
MinimumAmount float64 `gorm:"column:minimum_amount;not null;default:0.00" json:"minimum_amount"`
|
||||
MinimumAmountTax bool `gorm:"column:minimum_amount_tax;not null" json:"minimum_amount_tax"`
|
||||
MinimumAmountCurrency int32 `gorm:"column:minimum_amount_currency;not null" json:"minimum_amount_currency"`
|
||||
MinimumAmountShipping bool `gorm:"column:minimum_amount_shipping;not null" json:"minimum_amount_shipping"`
|
||||
CountryRestriction bool `gorm:"column:country_restriction;not null" json:"country_restriction"`
|
||||
CarrierRestriction bool `gorm:"column:carrier_restriction;not null" json:"carrier_restriction"`
|
||||
GroupRestriction bool `gorm:"column:group_restriction;not null;index:group_restriction,priority:1;index:group_restriction_2,priority:1" json:"group_restriction"`
|
||||
CartRuleRestriction bool `gorm:"column:cart_rule_restriction;not null" json:"cart_rule_restriction"`
|
||||
ProductRestriction bool `gorm:"column:product_restriction;not null" json:"product_restriction"`
|
||||
ShopRestriction bool `gorm:"column:shop_restriction;not null" json:"shop_restriction"`
|
||||
FreeShipping bool `gorm:"column:free_shipping;not null" json:"free_shipping"`
|
||||
ReductionPercent float64 `gorm:"column:reduction_percent;not null;default:0.00" json:"reduction_percent"`
|
||||
ReductionAmount float64 `gorm:"column:reduction_amount;not null;default:0.00" json:"reduction_amount"`
|
||||
ReductionTax bool `gorm:"column:reduction_tax;not null" json:"reduction_tax"`
|
||||
ReductionCurrency int32 `gorm:"column:reduction_currency;not null" json:"reduction_currency"`
|
||||
ReductionProduct int32 `gorm:"column:reduction_product;not null" json:"reduction_product"`
|
||||
ReductionExcludeSpecial bool `gorm:"column:reduction_exclude_special;not null" json:"reduction_exclude_special"`
|
||||
GiftProduct int32 `gorm:"column:gift_product;not null" json:"gift_product"`
|
||||
GiftProductAttribute int32 `gorm:"column:gift_product_attribute;not null" json:"gift_product_attribute"`
|
||||
Highlight bool `gorm:"column:highlight;not null;index:group_restriction_2,priority:3;index:id_customer_2,priority:3" json:"highlight"`
|
||||
Active bool `gorm:"column:active;not null;index:group_restriction,priority:2;index:group_restriction_2,priority:2;index:id_customer,priority:2;index:id_customer_2,priority:2" json:"active"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsCartRule's table name
|
||||
func (*PsCartRule) TableName() string {
|
||||
return TableNamePsCartRule
|
||||
}
|
||||
|
||||
var PsCartRuleCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDCustomer gormcol.Field
|
||||
DateFrom gormcol.Field
|
||||
DateTo gormcol.Field
|
||||
Description gormcol.Field
|
||||
Quantity gormcol.Field
|
||||
QuantityPerUser gormcol.Field
|
||||
Priority gormcol.Field
|
||||
PartialUse gormcol.Field
|
||||
Code gormcol.Field
|
||||
MinimumAmount gormcol.Field
|
||||
MinimumAmountTax gormcol.Field
|
||||
MinimumAmountCurrency gormcol.Field
|
||||
MinimumAmountShipping gormcol.Field
|
||||
CountryRestriction gormcol.Field
|
||||
CarrierRestriction gormcol.Field
|
||||
GroupRestriction gormcol.Field
|
||||
CartRuleRestriction gormcol.Field
|
||||
ProductRestriction gormcol.Field
|
||||
ShopRestriction gormcol.Field
|
||||
FreeShipping gormcol.Field
|
||||
ReductionPercent gormcol.Field
|
||||
ReductionAmount gormcol.Field
|
||||
ReductionTax gormcol.Field
|
||||
ReductionCurrency gormcol.Field
|
||||
ReductionProduct gormcol.Field
|
||||
ReductionExcludeSpecial gormcol.Field
|
||||
GiftProduct gormcol.Field
|
||||
GiftProductAttribute gormcol.Field
|
||||
Highlight gormcol.Field
|
||||
Active gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "id_cart_rule"),
|
||||
IDCustomer: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "id_customer"),
|
||||
DateFrom: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "date_from"),
|
||||
DateTo: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "date_to"),
|
||||
Description: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "description"),
|
||||
Quantity: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "quantity"),
|
||||
QuantityPerUser: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "quantity_per_user"),
|
||||
Priority: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "priority"),
|
||||
PartialUse: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "partial_use"),
|
||||
Code: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "code"),
|
||||
MinimumAmount: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "minimum_amount"),
|
||||
MinimumAmountTax: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "minimum_amount_tax"),
|
||||
MinimumAmountCurrency: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "minimum_amount_currency"),
|
||||
MinimumAmountShipping: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "minimum_amount_shipping"),
|
||||
CountryRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "country_restriction"),
|
||||
CarrierRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "carrier_restriction"),
|
||||
GroupRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "group_restriction"),
|
||||
CartRuleRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "cart_rule_restriction"),
|
||||
ProductRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "product_restriction"),
|
||||
ShopRestriction: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "shop_restriction"),
|
||||
FreeShipping: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "free_shipping"),
|
||||
ReductionPercent: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_percent"),
|
||||
ReductionAmount: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_amount"),
|
||||
ReductionTax: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_tax"),
|
||||
ReductionCurrency: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_currency"),
|
||||
ReductionProduct: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_product"),
|
||||
ReductionExcludeSpecial: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "reduction_exclude_special"),
|
||||
GiftProduct: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "gift_product"),
|
||||
GiftProductAttribute: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "gift_product_attribute"),
|
||||
Highlight: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "highlight"),
|
||||
Active: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "active"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsCartRule{}).TableName(), "date_upd"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_carrier.go
Normal file
26
app/model/dbmodel/ps_cart_rule_carrier.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleCarrier = "ps_cart_rule_carrier"
|
||||
|
||||
// PsCartRuleCarrier mapped from table <ps_cart_rule_carrier>
|
||||
type PsCartRuleCarrier struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey" json:"id_cart_rule"`
|
||||
IDCarrier int32 `gorm:"column:id_carrier;primaryKey" json:"id_carrier"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleCarrier's table name
|
||||
func (*PsCartRuleCarrier) TableName() string {
|
||||
return TableNamePsCartRuleCarrier
|
||||
}
|
||||
|
||||
var PsCartRuleCarrierCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDCarrier gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleCarrier{}).TableName(), "id_cart_rule"),
|
||||
IDCarrier: gormcol.Field{}.Set((&PsCartRuleCarrier{}).TableName(), "id_carrier"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_combination.go
Normal file
26
app/model/dbmodel/ps_cart_rule_combination.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleCombination = "ps_cart_rule_combination"
|
||||
|
||||
// PsCartRuleCombination mapped from table <ps_cart_rule_combination>
|
||||
type PsCartRuleCombination struct {
|
||||
IDCartRule1 int32 `gorm:"column:id_cart_rule_1;primaryKey;index:id_cart_rule_1,priority:1" json:"id_cart_rule_1"`
|
||||
IDCartRule2 int32 `gorm:"column:id_cart_rule_2;primaryKey;index:id_cart_rule_2,priority:1" json:"id_cart_rule_2"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleCombination's table name
|
||||
func (*PsCartRuleCombination) TableName() string {
|
||||
return TableNamePsCartRuleCombination
|
||||
}
|
||||
|
||||
var PsCartRuleCombinationCols = struct {
|
||||
IDCartRule1 gormcol.Field
|
||||
IDCartRule2 gormcol.Field
|
||||
}{
|
||||
IDCartRule1: gormcol.Field{}.Set((&PsCartRuleCombination{}).TableName(), "id_cart_rule_1"),
|
||||
IDCartRule2: gormcol.Field{}.Set((&PsCartRuleCombination{}).TableName(), "id_cart_rule_2"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_country.go
Normal file
26
app/model/dbmodel/ps_cart_rule_country.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleCountry = "ps_cart_rule_country"
|
||||
|
||||
// PsCartRuleCountry mapped from table <ps_cart_rule_country>
|
||||
type PsCartRuleCountry struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey" json:"id_cart_rule"`
|
||||
IDCountry int32 `gorm:"column:id_country;primaryKey" json:"id_country"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleCountry's table name
|
||||
func (*PsCartRuleCountry) TableName() string {
|
||||
return TableNamePsCartRuleCountry
|
||||
}
|
||||
|
||||
var PsCartRuleCountryCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDCountry gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleCountry{}).TableName(), "id_cart_rule"),
|
||||
IDCountry: gormcol.Field{}.Set((&PsCartRuleCountry{}).TableName(), "id_country"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_group.go
Normal file
26
app/model/dbmodel/ps_cart_rule_group.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleGroup = "ps_cart_rule_group"
|
||||
|
||||
// PsCartRuleGroup mapped from table <ps_cart_rule_group>
|
||||
type PsCartRuleGroup struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey" json:"id_cart_rule"`
|
||||
IDGroup int32 `gorm:"column:id_group;primaryKey" json:"id_group"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleGroup's table name
|
||||
func (*PsCartRuleGroup) TableName() string {
|
||||
return TableNamePsCartRuleGroup
|
||||
}
|
||||
|
||||
var PsCartRuleGroupCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDGroup gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleGroup{}).TableName(), "id_cart_rule"),
|
||||
IDGroup: gormcol.Field{}.Set((&PsCartRuleGroup{}).TableName(), "id_group"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_cart_rule_lang.go
Normal file
29
app/model/dbmodel/ps_cart_rule_lang.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleLang = "ps_cart_rule_lang"
|
||||
|
||||
// PsCartRuleLang mapped from table <ps_cart_rule_lang>
|
||||
type PsCartRuleLang struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey" json:"id_cart_rule"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Name string `gorm:"column:name;not null" json:"name"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleLang's table name
|
||||
func (*PsCartRuleLang) TableName() string {
|
||||
return TableNamePsCartRuleLang
|
||||
}
|
||||
|
||||
var PsCartRuleLangCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleLang{}).TableName(), "id_cart_rule"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCartRuleLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsCartRuleLang{}).TableName(), "name"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_cart_rule_product_rule.go
Normal file
29
app/model/dbmodel/ps_cart_rule_product_rule.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleProductRule = "ps_cart_rule_product_rule"
|
||||
|
||||
// PsCartRuleProductRule mapped from table <ps_cart_rule_product_rule>
|
||||
type PsCartRuleProductRule struct {
|
||||
IDProductRule int32 `gorm:"column:id_product_rule;primaryKey;autoIncrement:true" json:"id_product_rule"`
|
||||
IDProductRuleGroup int32 `gorm:"column:id_product_rule_group;not null" json:"id_product_rule_group"`
|
||||
Type string `gorm:"column:type;not null" json:"type"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleProductRule's table name
|
||||
func (*PsCartRuleProductRule) TableName() string {
|
||||
return TableNamePsCartRuleProductRule
|
||||
}
|
||||
|
||||
var PsCartRuleProductRuleCols = struct {
|
||||
IDProductRule gormcol.Field
|
||||
IDProductRuleGroup gormcol.Field
|
||||
Type gormcol.Field
|
||||
}{
|
||||
IDProductRule: gormcol.Field{}.Set((&PsCartRuleProductRule{}).TableName(), "id_product_rule"),
|
||||
IDProductRuleGroup: gormcol.Field{}.Set((&PsCartRuleProductRule{}).TableName(), "id_product_rule_group"),
|
||||
Type: gormcol.Field{}.Set((&PsCartRuleProductRule{}).TableName(), "type"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_cart_rule_product_rule_group.go
Normal file
29
app/model/dbmodel/ps_cart_rule_product_rule_group.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleProductRuleGroup = "ps_cart_rule_product_rule_group"
|
||||
|
||||
// PsCartRuleProductRuleGroup mapped from table <ps_cart_rule_product_rule_group>
|
||||
type PsCartRuleProductRuleGroup struct {
|
||||
IDProductRuleGroup int32 `gorm:"column:id_product_rule_group;primaryKey;autoIncrement:true" json:"id_product_rule_group"`
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;not null" json:"id_cart_rule"`
|
||||
Quantity int32 `gorm:"column:quantity;not null;default:1" json:"quantity"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleProductRuleGroup's table name
|
||||
func (*PsCartRuleProductRuleGroup) TableName() string {
|
||||
return TableNamePsCartRuleProductRuleGroup
|
||||
}
|
||||
|
||||
var PsCartRuleProductRuleGroupCols = struct {
|
||||
IDProductRuleGroup gormcol.Field
|
||||
IDCartRule gormcol.Field
|
||||
Quantity gormcol.Field
|
||||
}{
|
||||
IDProductRuleGroup: gormcol.Field{}.Set((&PsCartRuleProductRuleGroup{}).TableName(), "id_product_rule_group"),
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleProductRuleGroup{}).TableName(), "id_cart_rule"),
|
||||
Quantity: gormcol.Field{}.Set((&PsCartRuleProductRuleGroup{}).TableName(), "quantity"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_product_rule_value.go
Normal file
26
app/model/dbmodel/ps_cart_rule_product_rule_value.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleProductRuleValue = "ps_cart_rule_product_rule_value"
|
||||
|
||||
// PsCartRuleProductRuleValue mapped from table <ps_cart_rule_product_rule_value>
|
||||
type PsCartRuleProductRuleValue struct {
|
||||
IDProductRule int32 `gorm:"column:id_product_rule;primaryKey" json:"id_product_rule"`
|
||||
IDItem int32 `gorm:"column:id_item;primaryKey" json:"id_item"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleProductRuleValue's table name
|
||||
func (*PsCartRuleProductRuleValue) TableName() string {
|
||||
return TableNamePsCartRuleProductRuleValue
|
||||
}
|
||||
|
||||
var PsCartRuleProductRuleValueCols = struct {
|
||||
IDProductRule gormcol.Field
|
||||
IDItem gormcol.Field
|
||||
}{
|
||||
IDProductRule: gormcol.Field{}.Set((&PsCartRuleProductRuleValue{}).TableName(), "id_product_rule"),
|
||||
IDItem: gormcol.Field{}.Set((&PsCartRuleProductRuleValue{}).TableName(), "id_item"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cart_rule_shop.go
Normal file
26
app/model/dbmodel/ps_cart_rule_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCartRuleShop = "ps_cart_rule_shop"
|
||||
|
||||
// PsCartRuleShop mapped from table <ps_cart_rule_shop>
|
||||
type PsCartRuleShop struct {
|
||||
IDCartRule int32 `gorm:"column:id_cart_rule;primaryKey" json:"id_cart_rule"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsCartRuleShop's table name
|
||||
func (*PsCartRuleShop) TableName() string {
|
||||
return TableNamePsCartRuleShop
|
||||
}
|
||||
|
||||
var PsCartRuleShopCols = struct {
|
||||
IDCartRule gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDCartRule: gormcol.Field{}.Set((&PsCartRuleShop{}).TableName(), "id_cart_rule"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCartRuleShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
56
app/model/dbmodel/ps_category.go
Normal file
56
app/model/dbmodel/ps_category.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCategory = "ps_category"
|
||||
|
||||
// PsCategory mapped from table <ps_category>
|
||||
type PsCategory struct {
|
||||
IDCategory int32 `gorm:"column:id_category;primaryKey;autoIncrement:true;index:idx_category,priority:1" json:"id_category"`
|
||||
IDParent int32 `gorm:"column:id_parent;not null;index:category_parent,priority:1" json:"id_parent"`
|
||||
IDShopDefault int32 `gorm:"column:id_shop_default;not null;default:1" json:"id_shop_default"`
|
||||
LevelDepth int32 `gorm:"column:level_depth;not null;index:level_depth,priority:1" json:"level_depth"`
|
||||
Nleft int32 `gorm:"column:nleft;not null;index:activenleft,priority:2;index:idx_category,priority:3;index:nleftrightactive,priority:1" json:"nleft"`
|
||||
Nright int32 `gorm:"column:nright;not null;index:activenright,priority:2;index:idx_category,priority:4;index:nleftrightactive,priority:2;index:nright,priority:1" json:"nright"`
|
||||
Active bool `gorm:"column:active;not null;index:activenleft,priority:1;index:activenright,priority:1;index:idx_category,priority:2;index:idx_ps_category_active,priority:1;index:nleftrightactive,priority:3" json:"active"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
IsRootCategory bool `gorm:"column:is_root_category;not null" json:"is_root_category"`
|
||||
}
|
||||
|
||||
// TableName PsCategory's table name
|
||||
func (*PsCategory) TableName() string {
|
||||
return TableNamePsCategory
|
||||
}
|
||||
|
||||
var PsCategoryCols = struct {
|
||||
IDCategory gormcol.Field
|
||||
IDParent gormcol.Field
|
||||
IDShopDefault gormcol.Field
|
||||
LevelDepth gormcol.Field
|
||||
Nleft gormcol.Field
|
||||
Nright gormcol.Field
|
||||
Active gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
Position gormcol.Field
|
||||
IsRootCategory gormcol.Field
|
||||
}{
|
||||
IDCategory: gormcol.Field{}.Set((&PsCategory{}).TableName(), "id_category"),
|
||||
IDParent: gormcol.Field{}.Set((&PsCategory{}).TableName(), "id_parent"),
|
||||
IDShopDefault: gormcol.Field{}.Set((&PsCategory{}).TableName(), "id_shop_default"),
|
||||
LevelDepth: gormcol.Field{}.Set((&PsCategory{}).TableName(), "level_depth"),
|
||||
Nleft: gormcol.Field{}.Set((&PsCategory{}).TableName(), "nleft"),
|
||||
Nright: gormcol.Field{}.Set((&PsCategory{}).TableName(), "nright"),
|
||||
Active: gormcol.Field{}.Set((&PsCategory{}).TableName(), "active"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCategory{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsCategory{}).TableName(), "date_upd"),
|
||||
Position: gormcol.Field{}.Set((&PsCategory{}).TableName(), "position"),
|
||||
IsRootCategory: gormcol.Field{}.Set((&PsCategory{}).TableName(), "is_root_category"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_category_group.go
Normal file
26
app/model/dbmodel/ps_category_group.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCategoryGroup = "ps_category_group"
|
||||
|
||||
// PsCategoryGroup mapped from table <ps_category_group>
|
||||
type PsCategoryGroup struct {
|
||||
IDCategory int32 `gorm:"column:id_category;primaryKey;index:id_category,priority:1" json:"id_category"`
|
||||
IDGroup int32 `gorm:"column:id_group;primaryKey;index:id_group,priority:1" json:"id_group"`
|
||||
}
|
||||
|
||||
// TableName PsCategoryGroup's table name
|
||||
func (*PsCategoryGroup) TableName() string {
|
||||
return TableNamePsCategoryGroup
|
||||
}
|
||||
|
||||
var PsCategoryGroupCols = struct {
|
||||
IDCategory gormcol.Field
|
||||
IDGroup gormcol.Field
|
||||
}{
|
||||
IDCategory: gormcol.Field{}.Set((&PsCategoryGroup{}).TableName(), "id_category"),
|
||||
IDGroup: gormcol.Field{}.Set((&PsCategoryGroup{}).TableName(), "id_group"),
|
||||
}
|
||||
47
app/model/dbmodel/ps_category_lang.go
Normal file
47
app/model/dbmodel/ps_category_lang.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCategoryLang = "ps_category_lang"
|
||||
|
||||
// PsCategoryLang mapped from table <ps_category_lang>
|
||||
type PsCategoryLang struct {
|
||||
IDCategory int32 `gorm:"column:id_category;primaryKey" json:"id_category"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;default:1" json:"id_shop"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Name string `gorm:"column:name;not null;index:category_name,priority:1" json:"name"`
|
||||
Description *string `gorm:"column:description" json:"description"`
|
||||
LinkRewrite string `gorm:"column:link_rewrite;not null" json:"link_rewrite"`
|
||||
MetaTitle *string `gorm:"column:meta_title" json:"meta_title"`
|
||||
MetaKeywords *string `gorm:"column:meta_keywords" json:"meta_keywords"`
|
||||
MetaDescription *string `gorm:"column:meta_description" json:"meta_description"`
|
||||
}
|
||||
|
||||
// TableName PsCategoryLang's table name
|
||||
func (*PsCategoryLang) TableName() string {
|
||||
return TableNamePsCategoryLang
|
||||
}
|
||||
|
||||
var PsCategoryLangCols = struct {
|
||||
IDCategory gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Name gormcol.Field
|
||||
Description gormcol.Field
|
||||
LinkRewrite gormcol.Field
|
||||
MetaTitle gormcol.Field
|
||||
MetaKeywords gormcol.Field
|
||||
MetaDescription gormcol.Field
|
||||
}{
|
||||
IDCategory: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "id_category"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "id_shop"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "id_lang"),
|
||||
Name: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "name"),
|
||||
Description: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "description"),
|
||||
LinkRewrite: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "link_rewrite"),
|
||||
MetaTitle: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "meta_title"),
|
||||
MetaKeywords: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "meta_keywords"),
|
||||
MetaDescription: gormcol.Field{}.Set((&PsCategoryLang{}).TableName(), "meta_description"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_category_product.go
Normal file
29
app/model/dbmodel/ps_category_product.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCategoryProduct = "ps_category_product"
|
||||
|
||||
// PsCategoryProduct mapped from table <ps_category_product>
|
||||
type PsCategoryProduct struct {
|
||||
IDCategory int32 `gorm:"column:id_category;primaryKey;index:idx_category_product,priority:2;index:id_category,priority:1" json:"id_category"`
|
||||
IDProduct int32 `gorm:"column:id_product;primaryKey;index:idx_category_product,priority:1;index:id_product,priority:1" json:"id_product"`
|
||||
Position int32 `gorm:"column:position;not null;index:id_category,priority:2" json:"position"`
|
||||
}
|
||||
|
||||
// TableName PsCategoryProduct's table name
|
||||
func (*PsCategoryProduct) TableName() string {
|
||||
return TableNamePsCategoryProduct
|
||||
}
|
||||
|
||||
var PsCategoryProductCols = struct {
|
||||
IDCategory gormcol.Field
|
||||
IDProduct gormcol.Field
|
||||
Position gormcol.Field
|
||||
}{
|
||||
IDCategory: gormcol.Field{}.Set((&PsCategoryProduct{}).TableName(), "id_category"),
|
||||
IDProduct: gormcol.Field{}.Set((&PsCategoryProduct{}).TableName(), "id_product"),
|
||||
Position: gormcol.Field{}.Set((&PsCategoryProduct{}).TableName(), "position"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_category_shop.go
Normal file
29
app/model/dbmodel/ps_category_shop.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCategoryShop = "ps_category_shop"
|
||||
|
||||
// PsCategoryShop mapped from table <ps_category_shop>
|
||||
type PsCategoryShop struct {
|
||||
IDCategory int32 `gorm:"column:id_category;primaryKey" json:"id_category"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey" json:"id_shop"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
}
|
||||
|
||||
// TableName PsCategoryShop's table name
|
||||
func (*PsCategoryShop) TableName() string {
|
||||
return TableNamePsCategoryShop
|
||||
}
|
||||
|
||||
var PsCategoryShopCols = struct {
|
||||
IDCategory gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
Position gormcol.Field
|
||||
}{
|
||||
IDCategory: gormcol.Field{}.Set((&PsCategoryShop{}).TableName(), "id_category"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCategoryShop{}).TableName(), "id_shop"),
|
||||
Position: gormcol.Field{}.Set((&PsCategoryShop{}).TableName(), "position"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_cms.go
Normal file
35
app/model/dbmodel/ps_cms.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCm = "ps_cms"
|
||||
|
||||
// PsCm mapped from table <ps_cms>
|
||||
type PsCm struct {
|
||||
IDCms int32 `gorm:"column:id_cms;primaryKey;autoIncrement:true" json:"id_cms"`
|
||||
IDCmsCategory int32 `gorm:"column:id_cms_category;not null" json:"id_cms_category"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
Active bool `gorm:"column:active;not null" json:"active"`
|
||||
Indexation bool `gorm:"column:indexation;not null;default:1" json:"indexation"`
|
||||
}
|
||||
|
||||
// TableName PsCm's table name
|
||||
func (*PsCm) TableName() string {
|
||||
return TableNamePsCm
|
||||
}
|
||||
|
||||
var PsCmCols = struct {
|
||||
IDCms gormcol.Field
|
||||
IDCmsCategory gormcol.Field
|
||||
Position gormcol.Field
|
||||
Active gormcol.Field
|
||||
Indexation gormcol.Field
|
||||
}{
|
||||
IDCms: gormcol.Field{}.Set((&PsCm{}).TableName(), "id_cms"),
|
||||
IDCmsCategory: gormcol.Field{}.Set((&PsCm{}).TableName(), "id_cms_category"),
|
||||
Position: gormcol.Field{}.Set((&PsCm{}).TableName(), "position"),
|
||||
Active: gormcol.Field{}.Set((&PsCm{}).TableName(), "active"),
|
||||
Indexation: gormcol.Field{}.Set((&PsCm{}).TableName(), "indexation"),
|
||||
}
|
||||
44
app/model/dbmodel/ps_cms_category.go
Normal file
44
app/model/dbmodel/ps_cms_category.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCmsCategory = "ps_cms_category"
|
||||
|
||||
// PsCmsCategory mapped from table <ps_cms_category>
|
||||
type PsCmsCategory struct {
|
||||
IDCmsCategory int32 `gorm:"column:id_cms_category;primaryKey;autoIncrement:true" json:"id_cms_category"`
|
||||
IDParent int32 `gorm:"column:id_parent;not null;index:category_parent,priority:1" json:"id_parent"`
|
||||
LevelDepth int32 `gorm:"column:level_depth;not null" json:"level_depth"`
|
||||
Active bool `gorm:"column:active;not null" json:"active"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
Position int32 `gorm:"column:position;not null" json:"position"`
|
||||
}
|
||||
|
||||
// TableName PsCmsCategory's table name
|
||||
func (*PsCmsCategory) TableName() string {
|
||||
return TableNamePsCmsCategory
|
||||
}
|
||||
|
||||
var PsCmsCategoryCols = struct {
|
||||
IDCmsCategory gormcol.Field
|
||||
IDParent gormcol.Field
|
||||
LevelDepth gormcol.Field
|
||||
Active gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
Position gormcol.Field
|
||||
}{
|
||||
IDCmsCategory: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "id_cms_category"),
|
||||
IDParent: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "id_parent"),
|
||||
LevelDepth: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "level_depth"),
|
||||
Active: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "active"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "date_upd"),
|
||||
Position: gormcol.Field{}.Set((&PsCmsCategory{}).TableName(), "position"),
|
||||
}
|
||||
47
app/model/dbmodel/ps_cms_category_lang.go
Normal file
47
app/model/dbmodel/ps_cms_category_lang.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsCategoryLang = "ps_cms_category_lang"
|
||||
|
||||
// PsCmsCategoryLang mapped from table <ps_cms_category_lang>
|
||||
type PsCmsCategoryLang struct {
|
||||
IDCmsCategory int32 `gorm:"column:id_cms_category;primaryKey" json:"id_cms_category"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;default:1" json:"id_shop"`
|
||||
Name string `gorm:"column:name;not null;index:category_name,priority:1" json:"name"`
|
||||
Description *string `gorm:"column:description" json:"description"`
|
||||
LinkRewrite string `gorm:"column:link_rewrite;not null" json:"link_rewrite"`
|
||||
MetaTitle *string `gorm:"column:meta_title" json:"meta_title"`
|
||||
MetaKeywords *string `gorm:"column:meta_keywords" json:"meta_keywords"`
|
||||
MetaDescription *string `gorm:"column:meta_description" json:"meta_description"`
|
||||
}
|
||||
|
||||
// TableName PsCmsCategoryLang's table name
|
||||
func (*PsCmsCategoryLang) TableName() string {
|
||||
return TableNamePsCmsCategoryLang
|
||||
}
|
||||
|
||||
var PsCmsCategoryLangCols = struct {
|
||||
IDCmsCategory gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
Name gormcol.Field
|
||||
Description gormcol.Field
|
||||
LinkRewrite gormcol.Field
|
||||
MetaTitle gormcol.Field
|
||||
MetaKeywords gormcol.Field
|
||||
MetaDescription gormcol.Field
|
||||
}{
|
||||
IDCmsCategory: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "id_cms_category"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "id_lang"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "id_shop"),
|
||||
Name: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "name"),
|
||||
Description: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "description"),
|
||||
LinkRewrite: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "link_rewrite"),
|
||||
MetaTitle: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "meta_title"),
|
||||
MetaKeywords: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "meta_keywords"),
|
||||
MetaDescription: gormcol.Field{}.Set((&PsCmsCategoryLang{}).TableName(), "meta_description"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cms_category_shop.go
Normal file
26
app/model/dbmodel/ps_cms_category_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsCategoryShop = "ps_cms_category_shop"
|
||||
|
||||
// PsCmsCategoryShop mapped from table <ps_cms_category_shop>
|
||||
type PsCmsCategoryShop struct {
|
||||
IDCmsCategory int32 `gorm:"column:id_cms_category;primaryKey;autoIncrement:true" json:"id_cms_category"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;index:id_shop,priority:1" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsCmsCategoryShop's table name
|
||||
func (*PsCmsCategoryShop) TableName() string {
|
||||
return TableNamePsCmsCategoryShop
|
||||
}
|
||||
|
||||
var PsCmsCategoryShopCols = struct {
|
||||
IDCmsCategory gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDCmsCategory: gormcol.Field{}.Set((&PsCmsCategoryShop{}).TableName(), "id_cms_category"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCmsCategoryShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
47
app/model/dbmodel/ps_cms_lang.go
Normal file
47
app/model/dbmodel/ps_cms_lang.go
Normal file
@@ -0,0 +1,47 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsLang = "ps_cms_lang"
|
||||
|
||||
// PsCmsLang mapped from table <ps_cms_lang>
|
||||
type PsCmsLang struct {
|
||||
IDCms int32 `gorm:"column:id_cms;primaryKey" json:"id_cms"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;default:1" json:"id_shop"`
|
||||
MetaTitle string `gorm:"column:meta_title;not null" json:"meta_title"`
|
||||
HeadSeoTitle *string `gorm:"column:head_seo_title" json:"head_seo_title"`
|
||||
MetaDescription *string `gorm:"column:meta_description" json:"meta_description"`
|
||||
MetaKeywords *string `gorm:"column:meta_keywords" json:"meta_keywords"`
|
||||
Content *string `gorm:"column:content" json:"content"`
|
||||
LinkRewrite string `gorm:"column:link_rewrite;not null" json:"link_rewrite"`
|
||||
}
|
||||
|
||||
// TableName PsCmsLang's table name
|
||||
func (*PsCmsLang) TableName() string {
|
||||
return TableNamePsCmsLang
|
||||
}
|
||||
|
||||
var PsCmsLangCols = struct {
|
||||
IDCms gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
MetaTitle gormcol.Field
|
||||
HeadSeoTitle gormcol.Field
|
||||
MetaDescription gormcol.Field
|
||||
MetaKeywords gormcol.Field
|
||||
Content gormcol.Field
|
||||
LinkRewrite gormcol.Field
|
||||
}{
|
||||
IDCms: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "id_cms"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "id_lang"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "id_shop"),
|
||||
MetaTitle: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "meta_title"),
|
||||
HeadSeoTitle: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "head_seo_title"),
|
||||
MetaDescription: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "meta_description"),
|
||||
MetaKeywords: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "meta_keywords"),
|
||||
Content: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "content"),
|
||||
LinkRewrite: gormcol.Field{}.Set((&PsCmsLang{}).TableName(), "link_rewrite"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_cms_role.go
Normal file
29
app/model/dbmodel/ps_cms_role.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsRole = "ps_cms_role"
|
||||
|
||||
// PsCmsRole mapped from table <ps_cms_role>
|
||||
type PsCmsRole struct {
|
||||
IDCmsRole int32 `gorm:"column:id_cms_role;primaryKey;autoIncrement:true" json:"id_cms_role"`
|
||||
Name string `gorm:"column:name;not null;uniqueIndex:name,priority:1" json:"name"`
|
||||
IDCms int32 `gorm:"column:id_cms;primaryKey" json:"id_cms"`
|
||||
}
|
||||
|
||||
// TableName PsCmsRole's table name
|
||||
func (*PsCmsRole) TableName() string {
|
||||
return TableNamePsCmsRole
|
||||
}
|
||||
|
||||
var PsCmsRoleCols = struct {
|
||||
IDCmsRole gormcol.Field
|
||||
Name gormcol.Field
|
||||
IDCms gormcol.Field
|
||||
}{
|
||||
IDCmsRole: gormcol.Field{}.Set((&PsCmsRole{}).TableName(), "id_cms_role"),
|
||||
Name: gormcol.Field{}.Set((&PsCmsRole{}).TableName(), "name"),
|
||||
IDCms: gormcol.Field{}.Set((&PsCmsRole{}).TableName(), "id_cms"),
|
||||
}
|
||||
32
app/model/dbmodel/ps_cms_role_lang.go
Normal file
32
app/model/dbmodel/ps_cms_role_lang.go
Normal file
@@ -0,0 +1,32 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsRoleLang = "ps_cms_role_lang"
|
||||
|
||||
// PsCmsRoleLang mapped from table <ps_cms_role_lang>
|
||||
type PsCmsRoleLang struct {
|
||||
IDCmsRole int32 `gorm:"column:id_cms_role;primaryKey" json:"id_cms_role"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey" json:"id_shop"`
|
||||
Name *string `gorm:"column:name" json:"name"`
|
||||
}
|
||||
|
||||
// TableName PsCmsRoleLang's table name
|
||||
func (*PsCmsRoleLang) TableName() string {
|
||||
return TableNamePsCmsRoleLang
|
||||
}
|
||||
|
||||
var PsCmsRoleLangCols = struct {
|
||||
IDCmsRole gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
Name gormcol.Field
|
||||
}{
|
||||
IDCmsRole: gormcol.Field{}.Set((&PsCmsRoleLang{}).TableName(), "id_cms_role"),
|
||||
IDLang: gormcol.Field{}.Set((&PsCmsRoleLang{}).TableName(), "id_lang"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCmsRoleLang{}).TableName(), "id_shop"),
|
||||
Name: gormcol.Field{}.Set((&PsCmsRoleLang{}).TableName(), "name"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_cms_shop.go
Normal file
26
app/model/dbmodel/ps_cms_shop.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsCmsShop = "ps_cms_shop"
|
||||
|
||||
// PsCmsShop mapped from table <ps_cms_shop>
|
||||
type PsCmsShop struct {
|
||||
IDCms int32 `gorm:"column:id_cms;primaryKey" json:"id_cms"`
|
||||
IDShop int32 `gorm:"column:id_shop;primaryKey;index:id_shop,priority:1" json:"id_shop"`
|
||||
}
|
||||
|
||||
// TableName PsCmsShop's table name
|
||||
func (*PsCmsShop) TableName() string {
|
||||
return TableNamePsCmsShop
|
||||
}
|
||||
|
||||
var PsCmsShopCols = struct {
|
||||
IDCms gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
}{
|
||||
IDCms: gormcol.Field{}.Set((&PsCmsShop{}).TableName(), "id_cms"),
|
||||
IDShop: gormcol.Field{}.Set((&PsCmsShop{}).TableName(), "id_shop"),
|
||||
}
|
||||
59
app/model/dbmodel/ps_condition.go
Normal file
59
app/model/dbmodel/ps_condition.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsCondition = "ps_condition"
|
||||
|
||||
// PsCondition mapped from table <ps_condition>
|
||||
type PsCondition struct {
|
||||
IDCondition int32 `gorm:"column:id_condition;primaryKey;autoIncrement:true" json:"id_condition"`
|
||||
IDPsCondition int32 `gorm:"column:id_ps_condition;primaryKey" json:"id_ps_condition"`
|
||||
Type string `gorm:"column:type;not null" json:"type"`
|
||||
Request *string `gorm:"column:request" json:"request"`
|
||||
Operator *string `gorm:"column:operator" json:"operator"`
|
||||
Value *string `gorm:"column:value" json:"value"`
|
||||
Result *string `gorm:"column:result" json:"result"`
|
||||
CalculationType *string `gorm:"column:calculation_type" json:"calculation_type"`
|
||||
CalculationDetail *string `gorm:"column:calculation_detail" json:"calculation_detail"`
|
||||
Validated bool `gorm:"column:validated;not null" json:"validated"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsCondition's table name
|
||||
func (*PsCondition) TableName() string {
|
||||
return TableNamePsCondition
|
||||
}
|
||||
|
||||
var PsConditionCols = struct {
|
||||
IDCondition gormcol.Field
|
||||
IDPsCondition gormcol.Field
|
||||
Type gormcol.Field
|
||||
Request gormcol.Field
|
||||
Operator gormcol.Field
|
||||
Value gormcol.Field
|
||||
Result gormcol.Field
|
||||
CalculationType gormcol.Field
|
||||
CalculationDetail gormcol.Field
|
||||
Validated gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDCondition: gormcol.Field{}.Set((&PsCondition{}).TableName(), "id_condition"),
|
||||
IDPsCondition: gormcol.Field{}.Set((&PsCondition{}).TableName(), "id_ps_condition"),
|
||||
Type: gormcol.Field{}.Set((&PsCondition{}).TableName(), "type"),
|
||||
Request: gormcol.Field{}.Set((&PsCondition{}).TableName(), "request"),
|
||||
Operator: gormcol.Field{}.Set((&PsCondition{}).TableName(), "operator"),
|
||||
Value: gormcol.Field{}.Set((&PsCondition{}).TableName(), "value"),
|
||||
Result: gormcol.Field{}.Set((&PsCondition{}).TableName(), "result"),
|
||||
CalculationType: gormcol.Field{}.Set((&PsCondition{}).TableName(), "calculation_type"),
|
||||
CalculationDetail: gormcol.Field{}.Set((&PsCondition{}).TableName(), "calculation_detail"),
|
||||
Validated: gormcol.Field{}.Set((&PsCondition{}).TableName(), "validated"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsCondition{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsCondition{}).TableName(), "date_upd"),
|
||||
}
|
||||
29
app/model/dbmodel/ps_condition_advice.go
Normal file
29
app/model/dbmodel/ps_condition_advice.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsConditionAdvice = "ps_condition_advice"
|
||||
|
||||
// PsConditionAdvice mapped from table <ps_condition_advice>
|
||||
type PsConditionAdvice struct {
|
||||
IDCondition int32 `gorm:"column:id_condition;primaryKey" json:"id_condition"`
|
||||
IDAdvice int32 `gorm:"column:id_advice;primaryKey" json:"id_advice"`
|
||||
Display bool `gorm:"column:display;not null" json:"display"`
|
||||
}
|
||||
|
||||
// TableName PsConditionAdvice's table name
|
||||
func (*PsConditionAdvice) TableName() string {
|
||||
return TableNamePsConditionAdvice
|
||||
}
|
||||
|
||||
var PsConditionAdviceCols = struct {
|
||||
IDCondition gormcol.Field
|
||||
IDAdvice gormcol.Field
|
||||
Display gormcol.Field
|
||||
}{
|
||||
IDCondition: gormcol.Field{}.Set((&PsConditionAdvice{}).TableName(), "id_condition"),
|
||||
IDAdvice: gormcol.Field{}.Set((&PsConditionAdvice{}).TableName(), "id_advice"),
|
||||
Display: gormcol.Field{}.Set((&PsConditionAdvice{}).TableName(), "display"),
|
||||
}
|
||||
26
app/model/dbmodel/ps_condition_badge.go
Normal file
26
app/model/dbmodel/ps_condition_badge.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import "git.ma-al.com/goc_marek/gormcol"
|
||||
|
||||
const TableNamePsConditionBadge = "ps_condition_badge"
|
||||
|
||||
// PsConditionBadge mapped from table <ps_condition_badge>
|
||||
type PsConditionBadge struct {
|
||||
IDCondition int32 `gorm:"column:id_condition;primaryKey" json:"id_condition"`
|
||||
IDBadge int32 `gorm:"column:id_badge;primaryKey" json:"id_badge"`
|
||||
}
|
||||
|
||||
// TableName PsConditionBadge's table name
|
||||
func (*PsConditionBadge) TableName() string {
|
||||
return TableNamePsConditionBadge
|
||||
}
|
||||
|
||||
var PsConditionBadgeCols = struct {
|
||||
IDCondition gormcol.Field
|
||||
IDBadge gormcol.Field
|
||||
}{
|
||||
IDCondition: gormcol.Field{}.Set((&PsConditionBadge{}).TableName(), "id_condition"),
|
||||
IDBadge: gormcol.Field{}.Set((&PsConditionBadge{}).TableName(), "id_badge"),
|
||||
}
|
||||
44
app/model/dbmodel/ps_configuration.go
Normal file
44
app/model/dbmodel/ps_configuration.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsConfiguration = "ps_configuration"
|
||||
|
||||
// PsConfiguration mapped from table <ps_configuration>
|
||||
type PsConfiguration struct {
|
||||
IDConfiguration int32 `gorm:"column:id_configuration;primaryKey;autoIncrement:true" json:"id_configuration"`
|
||||
IDShopGroup *int32 `gorm:"column:id_shop_group;index:id_shop_group,priority:1" json:"id_shop_group"`
|
||||
IDShop *int32 `gorm:"column:id_shop;index:id_shop,priority:1" json:"id_shop"`
|
||||
Name string `gorm:"column:name;not null;index:name,priority:1" json:"name"`
|
||||
Value *string `gorm:"column:value" json:"value"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsConfiguration's table name
|
||||
func (*PsConfiguration) TableName() string {
|
||||
return TableNamePsConfiguration
|
||||
}
|
||||
|
||||
var PsConfigurationCols = struct {
|
||||
IDConfiguration gormcol.Field
|
||||
IDShopGroup gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
Name gormcol.Field
|
||||
Value gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDConfiguration: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "id_configuration"),
|
||||
IDShopGroup: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "id_shop_group"),
|
||||
IDShop: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "id_shop"),
|
||||
Name: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "name"),
|
||||
Value: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "value"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsConfiguration{}).TableName(), "date_upd"),
|
||||
}
|
||||
44
app/model/dbmodel/ps_configuration_kpi.go
Normal file
44
app/model/dbmodel/ps_configuration_kpi.go
Normal file
@@ -0,0 +1,44 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsConfigurationKpi = "ps_configuration_kpi"
|
||||
|
||||
// PsConfigurationKpi mapped from table <ps_configuration_kpi>
|
||||
type PsConfigurationKpi struct {
|
||||
IDConfigurationKpi int32 `gorm:"column:id_configuration_kpi;primaryKey;autoIncrement:true" json:"id_configuration_kpi"`
|
||||
IDShopGroup *int32 `gorm:"column:id_shop_group;index:id_shop_group,priority:1" json:"id_shop_group"`
|
||||
IDShop *int32 `gorm:"column:id_shop;index:id_shop,priority:1" json:"id_shop"`
|
||||
Name string `gorm:"column:name;not null;index:name,priority:1" json:"name"`
|
||||
Value *string `gorm:"column:value" json:"value"`
|
||||
DateAdd time.Time `gorm:"column:date_add;not null" json:"date_add"`
|
||||
DateUpd time.Time `gorm:"column:date_upd;not null" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsConfigurationKpi's table name
|
||||
func (*PsConfigurationKpi) TableName() string {
|
||||
return TableNamePsConfigurationKpi
|
||||
}
|
||||
|
||||
var PsConfigurationKpiCols = struct {
|
||||
IDConfigurationKpi gormcol.Field
|
||||
IDShopGroup gormcol.Field
|
||||
IDShop gormcol.Field
|
||||
Name gormcol.Field
|
||||
Value gormcol.Field
|
||||
DateAdd gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDConfigurationKpi: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "id_configuration_kpi"),
|
||||
IDShopGroup: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "id_shop_group"),
|
||||
IDShop: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "id_shop"),
|
||||
Name: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "name"),
|
||||
Value: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "value"),
|
||||
DateAdd: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "date_add"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsConfigurationKpi{}).TableName(), "date_upd"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_configuration_kpi_lang.go
Normal file
35
app/model/dbmodel/ps_configuration_kpi_lang.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsConfigurationKpiLang = "ps_configuration_kpi_lang"
|
||||
|
||||
// PsConfigurationKpiLang mapped from table <ps_configuration_kpi_lang>
|
||||
type PsConfigurationKpiLang struct {
|
||||
IDConfigurationKpi int32 `gorm:"column:id_configuration_kpi;primaryKey" json:"id_configuration_kpi"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Value *string `gorm:"column:value" json:"value"`
|
||||
DateUpd *time.Time `gorm:"column:date_upd" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsConfigurationKpiLang's table name
|
||||
func (*PsConfigurationKpiLang) TableName() string {
|
||||
return TableNamePsConfigurationKpiLang
|
||||
}
|
||||
|
||||
var PsConfigurationKpiLangCols = struct {
|
||||
IDConfigurationKpi gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Value gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDConfigurationKpi: gormcol.Field{}.Set((&PsConfigurationKpiLang{}).TableName(), "id_configuration_kpi"),
|
||||
IDLang: gormcol.Field{}.Set((&PsConfigurationKpiLang{}).TableName(), "id_lang"),
|
||||
Value: gormcol.Field{}.Set((&PsConfigurationKpiLang{}).TableName(), "value"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsConfigurationKpiLang{}).TableName(), "date_upd"),
|
||||
}
|
||||
35
app/model/dbmodel/ps_configuration_lang.go
Normal file
35
app/model/dbmodel/ps_configuration_lang.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// Code generated by gormcol. DO NOT EDIT.
|
||||
|
||||
package dbmodel
|
||||
|
||||
import (
|
||||
"git.ma-al.com/goc_marek/gormcol"
|
||||
"time"
|
||||
)
|
||||
|
||||
const TableNamePsConfigurationLang = "ps_configuration_lang"
|
||||
|
||||
// PsConfigurationLang mapped from table <ps_configuration_lang>
|
||||
type PsConfigurationLang struct {
|
||||
IDConfiguration int32 `gorm:"column:id_configuration;primaryKey" json:"id_configuration"`
|
||||
IDLang int32 `gorm:"column:id_lang;primaryKey" json:"id_lang"`
|
||||
Value *string `gorm:"column:value" json:"value"`
|
||||
DateUpd *time.Time `gorm:"column:date_upd" json:"date_upd"`
|
||||
}
|
||||
|
||||
// TableName PsConfigurationLang's table name
|
||||
func (*PsConfigurationLang) TableName() string {
|
||||
return TableNamePsConfigurationLang
|
||||
}
|
||||
|
||||
var PsConfigurationLangCols = struct {
|
||||
IDConfiguration gormcol.Field
|
||||
IDLang gormcol.Field
|
||||
Value gormcol.Field
|
||||
DateUpd gormcol.Field
|
||||
}{
|
||||
IDConfiguration: gormcol.Field{}.Set((&PsConfigurationLang{}).TableName(), "id_configuration"),
|
||||
IDLang: gormcol.Field{}.Set((&PsConfigurationLang{}).TableName(), "id_lang"),
|
||||
Value: gormcol.Field{}.Set((&PsConfigurationLang{}).TableName(), "value"),
|
||||
DateUpd: gormcol.Field{}.Set((&PsConfigurationLang{}).TableName(), "date_upd"),
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user