Compare commits
11 Commits
payment-ga
...
visamaster
| Author | SHA1 | Date | |
|---|---|---|---|
| 742e078090 | |||
| 570d4c6d20 | |||
| d7e5d1f989 | |||
| 78e1976e53 | |||
| f1337706f0 | |||
| 72a5ac52b0 | |||
| c6540a658b | |||
| f067872cd7 | |||
| 6dd6110914 | |||
| a3cbb52f4b | |||
| ef3a1baee2 |
21
app.go
21
app.go
@@ -21,12 +21,9 @@ import (
|
|||||||
|
|
||||||
// @title Service APIs
|
// @title Service APIs
|
||||||
// @version 1.0
|
// @version 1.0
|
||||||
// @description Online payment system admin API.
|
// @description Online payment system admin API. Localized fields ({en, ru, tm} objects) come back as a plain string in the language of the `lang` query parameter: tm, ru or en (default tm), falling back to tm, ru, en when that translation is empty. lang=all returns the full {en, ru, tm} objects (for edit forms); any other value is 400.
|
||||||
// @host localhost:5005
|
// @host localhost:5005
|
||||||
// @BasePath /api/admin
|
// @BasePath /api/admin
|
||||||
// @securityDefinitions.apikey BearerAuth
|
|
||||||
// @in header
|
|
||||||
// @name Authorization
|
|
||||||
// @schemes http
|
// @schemes http
|
||||||
// @tag.name auth
|
// @tag.name auth
|
||||||
// @tag.description Authentication
|
// @tag.description Authentication
|
||||||
@@ -50,19 +47,29 @@ import (
|
|||||||
// @tag.description Card rekwizit (card details) orders
|
// @tag.description Card rekwizit (card details) orders
|
||||||
// @tag.name activity-logs
|
// @tag.name activity-logs
|
||||||
// @tag.description User activity audit trail
|
// @tag.description User activity audit trail
|
||||||
// @tag.name visa-master-payment-orders
|
// @tag.name visa-master-orders
|
||||||
// @tag.description Visa/Master student-transfer payment orders
|
// @tag.description Visa/Master and Sber student-transfer orders: list, view, create, edit, delete
|
||||||
|
// @tag.name visa-master-payment
|
||||||
|
// @tag.description Paying a Visa/Master or Sber order through GBÜS (HALKBANK): quote, pay, status re-check, bank callback
|
||||||
|
// @tag.name payment-history
|
||||||
|
// @tag.description Visa/Master we Sber töleg synanyşyklarynyň taryhy. Ulanylyş tertibi: 1) GET /payment-history - ähli tölegler; 2) GET /payment-history/{id} - bir sargydyň tölegleri; 3) GET /payment-history/payments/{id} - bir tölegiň jikme-jikligi; 4) GET /payment-history/{id}/gateway - sargydyň tölegleri GBÜS jogaplary bilen; 5) GET /payment-history/{id}/logs - sargydyň ädimme-ädim töleg loglary
|
||||||
// @tag.name backups
|
// @tag.name backups
|
||||||
// @tag.description Database SQL backups
|
// @tag.description Database SQL backups
|
||||||
// @tag.name currencies
|
// @tag.name currencies
|
||||||
// @tag.description Currency exchange rates
|
// @tag.description Currency exchange rates
|
||||||
|
//
|
||||||
|
// Security definitions go last: swag reads every line after one as its
|
||||||
|
// attributes, so anything declared below it (tags, schemes) is dropped.
|
||||||
|
// @securityDefinitions.apikey BearerAuth
|
||||||
|
// @in header
|
||||||
|
// @name Authorization
|
||||||
func main() {
|
func main() {
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
logger := logging.GetLogger()
|
logger := logging.GetLogger()
|
||||||
|
|
||||||
docs.SwaggerInfo.Title = "Service APIs"
|
docs.SwaggerInfo.Title = "Service APIs"
|
||||||
docs.SwaggerInfo.Version = "1.0"
|
docs.SwaggerInfo.Version = "1.0"
|
||||||
docs.SwaggerInfo.Description = "Online payment system admin API."
|
docs.SwaggerInfo.Description = "Online payment system admin API. Localized fields ({en, ru, tm} objects) come back as a plain string in the language of the `lang` query parameter: tm, ru or en (default tm), falling back to tm, ru, en when that translation is empty. lang=all returns the full {en, ru, tm} objects (for edit forms); any other value is 400."
|
||||||
docs.SwaggerInfo.Host = "localhost:" + cfg.Listen.Port
|
docs.SwaggerInfo.Host = "localhost:" + cfg.Listen.Port
|
||||||
docs.SwaggerInfo.BasePath = "/api/admin"
|
docs.SwaggerInfo.BasePath = "/api/admin"
|
||||||
docs.SwaggerInfo.Schemes = []string{"http"}
|
docs.SwaggerInfo.Schemes = []string{"http"}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP INDEX IF EXISTS visa_master_payment_logs_order_step_idx;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- payment-history reads each attempt's register/callback log rows
|
||||||
|
-- (formUrl, returnUrl, first callback) by order and step; without this
|
||||||
|
-- every row of a page scans all of its order's logs.
|
||||||
|
CREATE INDEX IF NOT EXISTS visa_master_payment_logs_order_step_idx
|
||||||
|
ON visa_master_payment_logs (order_id, step);
|
||||||
2188
docs/docs.go
2188
docs/docs.go
File diff suppressed because it is too large
Load Diff
2189
docs/swagger.json
2189
docs/swagger.json
File diff suppressed because it is too large
Load Diff
1868
docs/swagger.yaml
1868
docs/swagger.yaml
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -86,6 +87,7 @@ func (h *handler) finance(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) backlog(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -136,6 +139,7 @@ func (h *handler) branches(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -161,6 +165,7 @@ func (h *handler) products(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -187,6 +192,7 @@ func (h *handler) customers(c *gin.Context) {
|
|||||||
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
|
||||||
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
|
||||||
// @Param operator_limit query int false "Number of operators to return" default(10)
|
// @Param operator_limit query int false "Number of operators to return" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
|||||||
230
internal/appresult/lang.go
Normal file
230
internal/appresult/lang.go
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
package appresult
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DefaultLang is the language localized fields collapse to when the caller
|
||||||
|
// passes no ?lang=.
|
||||||
|
const DefaultLang = "tm"
|
||||||
|
|
||||||
|
// LangAll keeps every localized field as its full {en, ru, tm} object - what
|
||||||
|
// admin edit forms need to fill all three inputs.
|
||||||
|
const LangAll = "all"
|
||||||
|
|
||||||
|
// langFallback is the order empty translations are filled from.
|
||||||
|
var langFallback = []string{"tm", "ru", "en"}
|
||||||
|
|
||||||
|
// Localize collapses every {"en", "ru", "tm"} object (shared.LocalizedText)
|
||||||
|
// in a JSON response into the plain string for ?lang= (tm, ru or en;
|
||||||
|
// default tm), so clients only download the language they show. ?lang=all
|
||||||
|
// leaves responses untouched. It rewrites the encoded body rather than the
|
||||||
|
// DTOs, so every module gets it without knowing about it; non-JSON
|
||||||
|
// responses (files, images) are streamed through as-is.
|
||||||
|
func Localize() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
lang := strings.ToLower(strings.TrimSpace(c.Query("lang")))
|
||||||
|
switch lang {
|
||||||
|
case "":
|
||||||
|
lang = DefaultLang
|
||||||
|
case "tm", "ru", "en":
|
||||||
|
case LangAll:
|
||||||
|
c.Next()
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w := &localizeWriter{ResponseWriter: c.Writer}
|
||||||
|
c.Writer = w
|
||||||
|
c.Next()
|
||||||
|
c.Writer = w.ResponseWriter
|
||||||
|
w.flush(lang)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// localizeWriter buffers JSON bodies until the handler is done, so they can
|
||||||
|
// be rewritten as a whole; anything else goes straight to the client.
|
||||||
|
type localizeWriter struct {
|
||||||
|
gin.ResponseWriter
|
||||||
|
decided bool
|
||||||
|
buffer bool
|
||||||
|
body bytes.Buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *localizeWriter) Write(data []byte) (int, error) {
|
||||||
|
if !w.decided {
|
||||||
|
w.decided = true
|
||||||
|
w.buffer = strings.HasPrefix(w.Header().Get("Content-Type"), "application/json")
|
||||||
|
}
|
||||||
|
if !w.buffer {
|
||||||
|
return w.ResponseWriter.Write(data)
|
||||||
|
}
|
||||||
|
return w.body.Write(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *localizeWriter) WriteString(s string) (int, error) {
|
||||||
|
return w.Write([]byte(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *localizeWriter) flush(lang string) {
|
||||||
|
if w.body.Len() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
out, err := localizeJSON(w.body.Bytes(), lang)
|
||||||
|
if err != nil {
|
||||||
|
out = w.body.Bytes()
|
||||||
|
}
|
||||||
|
w.ResponseWriter.Write(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
// localizeJSON re-encodes data token by token - keeping key order and
|
||||||
|
// number precision - with localized objects replaced by their lang string.
|
||||||
|
func localizeJSON(data []byte, lang string) ([]byte, error) {
|
||||||
|
dec := json.NewDecoder(bytes.NewReader(data))
|
||||||
|
dec.UseNumber()
|
||||||
|
var out bytes.Buffer
|
||||||
|
if err := localizeValue(dec, &out, lang); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out.Bytes(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func localizeValue(dec *json.Decoder, out *bytes.Buffer, lang string) error {
|
||||||
|
tok, err := dec.Token()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch t := tok.(type) {
|
||||||
|
case json.Delim:
|
||||||
|
if t == '[' {
|
||||||
|
return localizeArray(dec, out, lang)
|
||||||
|
}
|
||||||
|
return localizeObject(dec, out, lang)
|
||||||
|
case string:
|
||||||
|
return writeString(out, t)
|
||||||
|
case json.Number:
|
||||||
|
out.WriteString(t.String())
|
||||||
|
case bool:
|
||||||
|
if t {
|
||||||
|
out.WriteString("true")
|
||||||
|
} else {
|
||||||
|
out.WriteString("false")
|
||||||
|
}
|
||||||
|
case nil:
|
||||||
|
out.WriteString("null")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func localizeArray(dec *json.Decoder, out *bytes.Buffer, lang string) error {
|
||||||
|
out.WriteByte('[')
|
||||||
|
for i := 0; dec.More(); i++ {
|
||||||
|
if i > 0 {
|
||||||
|
out.WriteByte(',')
|
||||||
|
}
|
||||||
|
if err := localizeValue(dec, out, lang); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := dec.Token(); err != nil { // ']'
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
out.WriteByte(']')
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type jsonField struct {
|
||||||
|
key string
|
||||||
|
value []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func localizeObject(dec *json.Decoder, out *bytes.Buffer, lang string) error {
|
||||||
|
var fields []jsonField
|
||||||
|
for dec.More() {
|
||||||
|
keyTok, err := dec.Token()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var value bytes.Buffer
|
||||||
|
if err := localizeValue(dec, &value, lang); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fields = append(fields, jsonField{key: keyTok.(string), value: value.Bytes()})
|
||||||
|
}
|
||||||
|
if _, err := dec.Token(); err != nil { // '}'
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if text, ok := pickLocalized(fields, lang); ok {
|
||||||
|
return writeString(out, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
out.WriteByte('{')
|
||||||
|
for i, f := range fields {
|
||||||
|
if i > 0 {
|
||||||
|
out.WriteByte(',')
|
||||||
|
}
|
||||||
|
if err := writeString(out, f.key); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
out.WriteByte(':')
|
||||||
|
out.Write(f.value)
|
||||||
|
}
|
||||||
|
out.WriteByte('}')
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// pickLocalized reports whether fields is exactly a {en, ru, tm} object of
|
||||||
|
// strings/nulls and, if so, returns lang's text - falling back through
|
||||||
|
// langFallback when it's empty.
|
||||||
|
func pickLocalized(fields []jsonField, lang string) (string, bool) {
|
||||||
|
if len(fields) != 3 {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
texts := make(map[string]string, 3)
|
||||||
|
for _, f := range fields {
|
||||||
|
if f.key != "en" && f.key != "ru" && f.key != "tm" {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
if _, dup := texts[f.key]; dup {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
var text *string
|
||||||
|
if err := json.Unmarshal(f.value, &text); err != nil {
|
||||||
|
return "", false
|
||||||
|
}
|
||||||
|
texts[f.key] = ""
|
||||||
|
if text != nil {
|
||||||
|
texts[f.key] = *text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if text := texts[lang]; text != "" {
|
||||||
|
return text, true
|
||||||
|
}
|
||||||
|
for _, l := range langFallback {
|
||||||
|
if text := texts[l]; text != "" {
|
||||||
|
return text, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "", true
|
||||||
|
}
|
||||||
|
|
||||||
|
// writeString encodes s the way gin's c.JSON does (json.Marshal, HTML
|
||||||
|
// escaped), so rewritten bodies match untouched ones byte for byte.
|
||||||
|
func writeString(out *bytes.Buffer, s string) error {
|
||||||
|
encoded, err := json.Marshal(s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
out.Write(encoded)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
106
internal/appresult/lang_test.go
Normal file
106
internal/appresult/lang_test.go
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
package appresult
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func serve(t *testing.T, query string, handler gin.HandlerFunc) *httptest.ResponseRecorder {
|
||||||
|
t.Helper()
|
||||||
|
gin.SetMode(gin.TestMode)
|
||||||
|
router := gin.New()
|
||||||
|
router.Use(Localize())
|
||||||
|
router.GET("/x", handler)
|
||||||
|
|
||||||
|
rec := httptest.NewRecorder()
|
||||||
|
router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/x"+query, nil))
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
|
||||||
|
func jsonHandler(body string) gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
c.Data(http.StatusOK, "application/json; charset=utf-8", []byte(body))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const branchBody = `{"id":1,"name":{"en":"Branch","ru":"Филиал","tm":"Şahamça"}}`
|
||||||
|
|
||||||
|
func TestLocalizeLanguages(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
query string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"", `{"id":1,"name":"Şahamça"}`},
|
||||||
|
{"?lang=tm", `{"id":1,"name":"Şahamça"}`},
|
||||||
|
{"?lang=ru", `{"id":1,"name":"Филиал"}`},
|
||||||
|
{"?lang=EN", `{"id":1,"name":"Branch"}`},
|
||||||
|
{"?lang=all", branchBody},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
rec := serve(t, tt.query, jsonHandler(branchBody))
|
||||||
|
if rec.Code != http.StatusOK || rec.Body.String() != tt.want {
|
||||||
|
t.Errorf("%q: got %d %s, want %s", tt.query, rec.Code, rec.Body.String(), tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalizeRejectsUnknownLang(t *testing.T) {
|
||||||
|
called := false
|
||||||
|
rec := serve(t, "?lang=xx", func(c *gin.Context) { called = true })
|
||||||
|
if rec.Code != http.StatusBadRequest || called {
|
||||||
|
t.Fatalf("got %d (handler called: %v), want 400 without calling the handler", rec.Code, called)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalizeFallback(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
body string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{`{"tm":"","ru":"Филиал","en":"Branch"}`, `"Филиал"`},
|
||||||
|
{`{"tm":null,"ru":"","en":"Branch"}`, `"Branch"`},
|
||||||
|
{`{"tm":"","ru":"","en":""}`, `""`},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := serve(t, "", jsonHandler(tt.body)).Body.String(); got != tt.want {
|
||||||
|
t.Errorf("%s: got %s, want %s", tt.body, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalizeKeepsStructure(t *testing.T) {
|
||||||
|
body := `{"z":9007199254740993,"a":[{"b":{"en":"E","ru":"R","tm":"T"},"f":1.10}],` +
|
||||||
|
`"extra":{"en":"E","ru":"R","tm":"T","id":2},"partial":{"en":"E","ru":"R"},` +
|
||||||
|
`"nested":{"en":{"x":1},"ru":"R","tm":"T"},"ok":true,"none":null,"html":"<a&b>"}`
|
||||||
|
want := `{"z":9007199254740993,"a":[{"b":"T","f":1.10}],` +
|
||||||
|
`"extra":{"en":"E","ru":"R","tm":"T","id":2},"partial":{"en":"E","ru":"R"},` +
|
||||||
|
`"nested":{"en":{"x":1},"ru":"R","tm":"T"},"ok":true,"none":null,"html":` + "\"\\u003ca\\u0026b\\u003e\"}"
|
||||||
|
if got := serve(t, "", jsonHandler(body)).Body.String(); got != want {
|
||||||
|
t.Fatalf("got %s\nwant %s", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalizeMatchesGinJSON(t *testing.T) {
|
||||||
|
rec := serve(t, "?lang=ru", func(c *gin.Context) {
|
||||||
|
c.JSON(http.StatusCreated, SuccessWithData(map[string]interface{}{
|
||||||
|
"name": map[string]string{"en": "Branch", "ru": "Филиал", "tm": "Şahamça"},
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
want := `{"status":true,"message":"Request completed successfully.","code":"SS-10000","data":{"name":"Филиал"}}`
|
||||||
|
if rec.Code != http.StatusCreated || rec.Body.String() != want {
|
||||||
|
t.Fatalf("got %d %s, want 201 %s", rec.Code, rec.Body.String(), want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLocalizeSkipsNonJSON(t *testing.T) {
|
||||||
|
body := `{"en":"E","ru":"R","tm":"T"}`
|
||||||
|
rec := serve(t, "", func(c *gin.Context) {
|
||||||
|
c.Data(http.StatusOK, "text/plain", []byte(body))
|
||||||
|
})
|
||||||
|
if rec.Body.String() != body {
|
||||||
|
t.Fatalf("got %s, want body untouched", rec.Body.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param status query string false "Filter by status (pending, completed, failed)"
|
// @Param status query string false "Filter by status (pending, completed, failed)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -106,6 +108,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Tags backups
|
// @Tags backups
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /backups [post]
|
// @Router /backups [post]
|
||||||
@@ -127,6 +130,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Produce application/sql
|
// @Produce application/sql
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {file} file
|
// @Success 200 {file} file
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -168,6 +172,7 @@ func (h *handler) download(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Backup ID"
|
// @Param id path int true "Backup ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param created_by query int false "Filter by creator user ID"
|
// @Param created_by query int false "Filter by creator user ID"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardBalanceDTO true "Card balance payload"
|
// @Param body body CreateCardBalanceDTO true "Card balance payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -141,6 +144,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
// @Param body body UpdateCardBalanceDTO true "Card balance payload"
|
// @Param body body UpdateCardBalanceDTO true "Card balance payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card balance ID"
|
// @Param id path int true "Card balance ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -77,6 +78,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -114,6 +116,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardOrderDTO true "Card order payload"
|
// @Param body body CreateCardOrderDTO true "Card order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
// @Param body body UpdateCardOrderDTO true "Card order payload"
|
// @Param body body UpdateCardOrderDTO true "Card order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -189,6 +193,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card order ID"
|
// @Param id path int true "Card order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardPinOrderDTO true "Card pin order payload"
|
// @Param body body CreateCardPinOrderDTO true "Card pin order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
// @Param body body UpdateCardPinOrderDTO true "Card pin order payload"
|
// @Param body body UpdateCardPinOrderDTO true "Card pin order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -186,6 +190,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card pin order ID"
|
// @Param id path int true "Card pin order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
// @Param body body CreateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
// @Param body body UpdateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
// @Param body body UpdateCardRekwizitOrderDTO true "Card rekwizit order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -186,6 +190,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card rekwizit order ID"
|
// @Param id path int true "Card rekwizit order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param type query string false "Filter by card type"
|
// @Param type query string false "Filter by card type"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -73,6 +74,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -117,6 +119,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCardDTO true "Card payload"
|
// @Param body body CreateCardDTO true "Card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -147,6 +150,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
// @Param body body UpdateCardDTO true "Card payload"
|
// @Param body body UpdateCardDTO true "Card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -190,6 +194,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Card ID"
|
// @Param id path int true "Card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active"
|
// @Param active query bool false "Filter by active"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -109,6 +111,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreatePaymentCardDTO true "Payment card payload"
|
// @Param body body CreatePaymentCardDTO true "Payment card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -139,6 +142,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
// @Param body body UpdatePaymentCardDTO true "Payment card payload"
|
// @Param body body UpdatePaymentCardDTO true "Payment card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -180,6 +184,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
// @Param body body UpdatePaymentCardActiveDTO true "Active payload"
|
// @Param body body UpdatePaymentCardActiveDTO true "Active payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -219,6 +224,7 @@ func (h *handler) updateActive(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment card ID"
|
// @Param id path int true "Payment card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param reason_name query string false "Filter by title (en, ru, tm)"
|
// @Param reason_name query string false "Filter by title (en, ru, tm)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -72,6 +73,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -106,6 +108,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateReasonCardDTO true "Reason card payload"
|
// @Param body body CreateReasonCardDTO true "Reason card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -136,6 +139,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
// @Param body body UpdateReasonCardDTO true "Reason card payload"
|
// @Param body body UpdateReasonCardDTO true "Reason card payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -175,6 +179,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Reason card ID"
|
// @Param id path int true "Reason card ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// list godoc
|
// list godoc
|
||||||
// @Summary List visa/master payment orders
|
// @Summary List visa/master payment orders
|
||||||
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
|
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param name query string false "Filter by passport name or surname"
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
@@ -54,6 +54,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -71,7 +72,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// listSber godoc
|
// listSber godoc
|
||||||
// @Summary List sber payment orders
|
// @Summary List sber payment orders
|
||||||
// @Description Returns paginated payment orders of type sber
|
// @Description Returns paginated payment orders of type sber
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param name query string false "Filter by passport name or surname"
|
// @Param name query string false "Filter by passport name or surname"
|
||||||
@@ -81,6 +82,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -109,10 +111,11 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
|
|||||||
// getByID godoc
|
// getByID godoc
|
||||||
// @Summary Get visa/master payment order by ID
|
// @Summary Get visa/master payment order by ID
|
||||||
// @Description Returns a single visa/master payment order with branch and user details
|
// @Description Returns a single visa/master payment order with branch and user details
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -145,11 +148,12 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// create godoc
|
// create godoc
|
||||||
// @Summary Create visa/master payment order
|
// @Summary Create visa/master payment order
|
||||||
// @Description Creates a new visa/master payment order
|
// @Description Creates a new visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
// @Param body body CreateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -174,12 +178,13 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// update godoc
|
// update godoc
|
||||||
// @Summary Update visa/master payment order
|
// @Summary Update visa/master payment order
|
||||||
// @Description Updates an existing visa/master payment order
|
// @Description Updates an existing visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
// @Param body body UpdateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
// @Param body body UpdateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -219,10 +224,11 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// delete godoc
|
// delete godoc
|
||||||
// @Summary Delete visa/master payment order
|
// @Summary Delete visa/master payment order
|
||||||
// @Description Deletes a visa/master payment order
|
// @Description Deletes a visa/master payment order
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-orders
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param currency_to query string false "Filter by target currency"
|
// @Param currency_to query string false "Filter by target currency"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListCurrencyDTO
|
// @Success 200 {object} ListCurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CurrencyDTO
|
// @Success 200 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateCurrencyDTO true "Currency rate payload"
|
// @Param body body CreateCurrencyDTO true "Currency rate payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} CurrencyDTO
|
// @Success 201 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -147,6 +150,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
// @Param body body UpdateCurrencyDTO true "Currency rate payload"
|
// @Param body body UpdateCurrencyDTO true "Currency rate payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CurrencyDTO
|
// @Success 200 {object} CurrencyDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -193,6 +197,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Currency ID"
|
// @Param id path int true "Currency ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param year query int false "Year for the monthly trend chart" default(current year)
|
// @Param year query int false "Year for the monthly trend chart" default(current year)
|
||||||
// @Param recent_limit query int false "Number of recent activity items to return" default(10)
|
// @Param recent_limit query int false "Number of recent activity items to return" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) overview(c *gin.Context) {
|
|||||||
// @Tags dashboard
|
// @Tags dashboard
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess{data=sysstats.Stats}
|
// @Success 200 {object} appresult.AppSuccess{data=sysstats.Stats}
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /dashboard/server-stats [get]
|
// @Router /dashboard/server-stats [get]
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"online-back/internal/analytics"
|
"online-back/internal/analytics"
|
||||||
analyticsdb "online-back/internal/analytics/db"
|
analyticsdb "online-back/internal/analytics/db"
|
||||||
|
"online-back/internal/appresult"
|
||||||
"online-back/internal/backup"
|
"online-back/internal/backup"
|
||||||
backupdb "online-back/internal/backup/db"
|
backupdb "online-back/internal/backup/db"
|
||||||
"online-back/internal/cards"
|
"online-back/internal/cards"
|
||||||
@@ -65,6 +66,8 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
adminGroup := router.Group(adminAPIPrefix)
|
adminGroup := router.Group(adminAPIPrefix)
|
||||||
|
// First, so it sees every admin response; /swagger stays outside it.
|
||||||
|
adminGroup.Use(appresult.Localize())
|
||||||
adminGroup.Use(activitylog.Record(activitylogdb.NewRepository(client, logger), logger))
|
adminGroup.Use(activitylog.Record(activitylogdb.NewRepository(client, logger), logger))
|
||||||
if err := perm.Sync(context.Background(), client); err != nil {
|
if err := perm.Sync(context.Background(), client); err != nil {
|
||||||
logger.Fatalf("rbac: sync permission catalog: %v", err)
|
logger.Fatalf("rbac: sync permission catalog: %v", err)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param action query string false "Filter by action (create, update, delete)"
|
// @Param action query string false "Filter by action (create, update, delete)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -75,6 +76,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Activity log ID"
|
// @Param id path int true "Activity log ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"online-back/internal/shared"
|
||||||
|
)
|
||||||
|
|
||||||
type LoginDTO struct {
|
type LoginDTO struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
@@ -12,12 +16,6 @@ type RefreshTokenDTO struct {
|
|||||||
RefreshToken string `json:"refreshToken" binding:"required"`
|
RefreshToken string `json:"refreshToken" binding:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LocalizedText struct {
|
|
||||||
En string `json:"en"`
|
|
||||||
Ru string `json:"ru"`
|
|
||||||
Tm string `json:"tm"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileRoleDTO struct {
|
type ProfileRoleDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
@@ -27,9 +25,9 @@ type ProfileRoleDTO struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ProfileBranchDTO struct {
|
type ProfileBranchDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
UniqueCode string `json:"uniqueCode"`
|
UniqueCode string `json:"uniqueCode"`
|
||||||
Name LocalizedText `json:"name"`
|
Name shared.LocalizedText `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProfilePermissionDTO is one module the caller can open; the front-end
|
// ProfilePermissionDTO is one module the caller can open; the front-end
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body LoginDTO true "Login payload"
|
// @Param body body LoginDTO true "Login payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -91,6 +92,7 @@ func (h *handler) login(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body RegisterDTO true "Registration payload"
|
// @Param body body RegisterDTO true "Registration payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -118,6 +120,7 @@ func (h *handler) register(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body VerifyDTO true "Verification payload"
|
// @Param body body VerifyDTO true "Verification payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 409 {object} appresult.AppError
|
// @Failure 409 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) verify(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body ForgotPasswordDTO true "Forgot password payload"
|
// @Param body body ForgotPasswordDTO true "Forgot password payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -172,6 +176,7 @@ func (h *handler) forgotPassword(c *gin.Context) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body ResetPasswordDTO true "Reset password payload"
|
// @Param body body ResetPasswordDTO true "Reset password payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -217,6 +222,7 @@ func (h *handler) respondRegisterError(c *gin.Context, err error) {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body RefreshTokenDTO true "Refresh token payload"
|
// @Param body body RefreshTokenDTO true "Refresh token payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -247,6 +253,7 @@ func (h *handler) refreshToken(c *gin.Context) {
|
|||||||
// @Tags auth
|
// @Tags auth
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
@@ -277,6 +284,7 @@ func (h *handler) getProfile(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body UpdateProfileDTO true "Profile payload"
|
// @Param body body UpdateProfileDTO true "Profile payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 401 {object} appresult.AppError
|
// @Failure 401 {object} appresult.AppError
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Tags permission
|
// @Tags permission
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Router /permissions [get]
|
// @Router /permissions [get]
|
||||||
func (h *handler) list(c *gin.Context) {
|
func (h *handler) list(c *gin.Context) {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param role_name query string false "Filter by name or code"
|
// @Param role_name query string false "Filter by name or code"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateRoleDTO true "Role payload"
|
// @Param body body CreateRoleDTO true "Role payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -151,6 +154,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
// @Param body body UpdateRoleDTO true "Role payload"
|
// @Param body body UpdateRoleDTO true "Role payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -202,6 +206,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Role ID"
|
// @Param id path int true "Role ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
type LocalizedText struct {
|
"online-back/internal/shared"
|
||||||
En string `json:"en"`
|
)
|
||||||
Ru string `json:"ru"`
|
|
||||||
Tm string `json:"tm"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type StaffBranchDTO struct {
|
type StaffBranchDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
UniqueCode string `json:"uniqueCode"`
|
UniqueCode string `json:"uniqueCode"`
|
||||||
Name LocalizedText `json:"name"`
|
Name shared.LocalizedText `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserPermissionDTO struct {
|
type UserPermissionDTO struct {
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ func (h *handler) RegisterPublic(engine *gin.Engine) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -106,6 +107,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -137,6 +139,7 @@ func (h *handler) listClients(c *gin.Context) {
|
|||||||
// @Param username query string false "Alias for search"
|
// @Param username query string false "Alias for search"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -166,6 +169,7 @@ func (h *handler) listStaff(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -203,6 +207,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateUserDTO true "User payload"
|
// @Param body body CreateUserDTO true "User payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -242,6 +247,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
// @Param body body UpdateUserDTO true "User payload"
|
// @Param body body UpdateUserDTO true "User payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -303,6 +309,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
// @Param body body SetUserRoleDTO true "Role"
|
// @Param body body SetUserRoleDTO true "Role"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -364,6 +371,7 @@ func (h *handler) setRole(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "User ID"
|
// @Param id path int true "User ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -547,6 +555,7 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
|
|||||||
// @Param file formData file true "this is a test file"
|
// @Param file formData file true "this is a test file"
|
||||||
//
|
//
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -589,6 +598,7 @@ func (h *handler) fileUpload(c *gin.Context) {
|
|||||||
// @Tags file-upload
|
// @Tags file-upload
|
||||||
// @Produce octet-stream
|
// @Produce octet-stream
|
||||||
// @Param file_name path string true "object name"
|
// @Param file_name path string true "object name"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {file} binary
|
// @Success 200 {file} binary
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -631,6 +641,7 @@ func (h *handler) getFile(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param id path string true "object name"
|
// @Param id path string true "object name"
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /file/{id} [delete]
|
// @Router /file/{id} [delete]
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
package userbranch
|
package userbranch
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
type LocalizedText struct {
|
"online-back/internal/shared"
|
||||||
En string `json:"en"`
|
)
|
||||||
Ru string `json:"ru"`
|
|
||||||
Tm string `json:"tm"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserBranchDTO struct {
|
type UserBranchDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
UserId int64 `json:"userId"`
|
UserId int64 `json:"userId"`
|
||||||
UserName string `json:"userName"`
|
UserName string `json:"userName"`
|
||||||
BranchId int64 `json:"branchId"`
|
BranchId int64 `json:"branchId"`
|
||||||
BranchName LocalizedText `json:"branchName"`
|
BranchName shared.LocalizedText `json:"branchName"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateUserBranchDTO struct {
|
type CreateUserBranchDTO struct {
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateUserBranchDTO true "Branch-user payload"
|
// @Param body body CreateUserBranchDTO true "Branch-user payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -72,6 +73,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch-user ID"
|
// @Param id path int true "Branch-user ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -145,6 +148,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanOrderDTO true "Loan order payload"
|
// @Param body body CreateLoanOrderDTO true "Loan order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -179,6 +183,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
// @Param body body UpdateLoanOrderDTO true "Loan order payload"
|
// @Param body body UpdateLoanOrderDTO true "Loan order payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -222,6 +227,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan order ID"
|
// @Param id path int true "Loan order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param region query string false "Filter by region"
|
// @Param region query string false "Filter by region"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -80,6 +81,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param province_id query int true "Province ID"
|
// @Param province_id query int true "Province ID"
|
||||||
// @Param active query bool false "Only active branches" default(true)
|
// @Param active query bool false "Only active branches" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -118,6 +120,7 @@ func (h *handler) listBranchesByProvince(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -155,6 +158,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
|
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -185,6 +189,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
|
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -228,6 +233,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan paid off letter ID"
|
// @Param id path int true "Loan paid off letter ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active"
|
// @Param active query bool false "Filter by active"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -76,6 +77,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanDocumentDTO true "Loan document payload"
|
// @Param body body CreateLoanDocumentDTO true "Loan document payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -140,6 +143,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
// @Param body body UpdateLoanDocumentDTO true "Loan document payload"
|
// @Param body body UpdateLoanDocumentDTO true "Loan document payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -181,6 +185,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
// @Param body body UpdateLoanDocumentActiveDTO true "Active payload"
|
// @Param body body UpdateLoanDocumentActiveDTO true "Active payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -220,6 +225,7 @@ func (h *handler) updateActive(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan document ID"
|
// @Param id path int true "Loan document ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param passport_id query string false "Filter by passport ID"
|
// @Param passport_id query string false "Filter by passport ID"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -111,6 +113,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
|
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -141,6 +144,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
|
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan repayment ID"
|
// @Param id path int true "Loan repayment ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param loan_type_name query string false "Filter by title (en, ru, tm)"
|
// @Param loan_type_name query string false "Filter by title (en, ru, tm)"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -74,6 +75,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -108,6 +110,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateLoanTypeDTO true "Loan type payload"
|
// @Param body body CreateLoanTypeDTO true "Loan type payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -138,6 +141,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
// @Param body body UpdateLoanTypeDTO true "Loan type payload"
|
// @Param body body UpdateLoanTypeDTO true "Loan type payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -177,6 +181,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Loan type ID"
|
// @Param id path int true "Loan type ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ func (r *repository) ensureProvince(ctx context.Context, provinceID *int64) erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalBranchJSON(name, address branches.LocalizedText) ([]byte, []byte, error) {
|
func marshalBranchJSON(name, address shared.LocalizedText) ([]byte, []byte, error) {
|
||||||
nameJSON, err := json.Marshal(name)
|
nameJSON, err := json.Marshal(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|||||||
@@ -1,64 +1,60 @@
|
|||||||
package branches
|
package branches
|
||||||
|
|
||||||
type LocalizedText struct {
|
import "online-back/internal/shared"
|
||||||
En string `json:"en"`
|
|
||||||
Ru string `json:"ru"`
|
|
||||||
Tm string `json:"tm"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type BranchDTO struct {
|
type BranchDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
UniqueCode string `json:"uniqueCode"`
|
UniqueCode string `json:"uniqueCode"`
|
||||||
Name LocalizedText `json:"name"`
|
Name shared.LocalizedText `json:"name"`
|
||||||
Address LocalizedText `json:"address"`
|
Address shared.LocalizedText `json:"address"`
|
||||||
Region string `json:"region"`
|
Region string `json:"region"`
|
||||||
ProvinceId *int64 `json:"provinceId"`
|
ProvinceId *int64 `json:"provinceId"`
|
||||||
ProvinceName LocalizedText `json:"provinceName"`
|
ProvinceName shared.LocalizedText `json:"provinceName"`
|
||||||
PhoneNumbers string `json:"phoneNumbers"`
|
PhoneNumbers string `json:"phoneNumbers"`
|
||||||
BillingUsername string `json:"billingUsername"`
|
BillingUsername string `json:"billingUsername"`
|
||||||
BillingPassword string `json:"billingPassword"`
|
BillingPassword string `json:"billingPassword"`
|
||||||
BillingSberUsername string `json:"billingSberUsername"`
|
BillingSberUsername string `json:"billingSberUsername"`
|
||||||
BillingSberPassword string `json:"billingSberPassword"`
|
BillingSberPassword string `json:"billingSberPassword"`
|
||||||
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
||||||
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
||||||
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
||||||
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateBranchDTO struct {
|
type CreateBranchDTO struct {
|
||||||
UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"`
|
UniqueCode string `json:"uniqueCode" binding:"required,numeric,len=4"`
|
||||||
Name LocalizedText `json:"name" binding:"required"`
|
Name shared.LocalizedText `json:"name" binding:"required"`
|
||||||
Address LocalizedText `json:"address" binding:"required"`
|
Address shared.LocalizedText `json:"address" binding:"required"`
|
||||||
Region string `json:"region" binding:"required"`
|
Region string `json:"region" binding:"required"`
|
||||||
ProvinceId *int64 `json:"provinceId"`
|
ProvinceId *int64 `json:"provinceId"`
|
||||||
PhoneNumbers string `json:"phoneNumbers"`
|
PhoneNumbers string `json:"phoneNumbers"`
|
||||||
BillingUsername string `json:"billingUsername"`
|
BillingUsername string `json:"billingUsername"`
|
||||||
BillingPassword string `json:"billingPassword"`
|
BillingPassword string `json:"billingPassword"`
|
||||||
BillingSberUsername string `json:"billingSberUsername"`
|
BillingSberUsername string `json:"billingSberUsername"`
|
||||||
BillingSberPassword string `json:"billingSberPassword"`
|
BillingSberPassword string `json:"billingSberPassword"`
|
||||||
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
||||||
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
||||||
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
||||||
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
||||||
Active *bool `json:"active"`
|
Active *bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateBranchDTO struct {
|
type UpdateBranchDTO struct {
|
||||||
Name LocalizedText `json:"name" binding:"required"`
|
Name shared.LocalizedText `json:"name" binding:"required"`
|
||||||
Address LocalizedText `json:"address" binding:"required"`
|
Address shared.LocalizedText `json:"address" binding:"required"`
|
||||||
Region string `json:"region" binding:"required"`
|
Region string `json:"region" binding:"required"`
|
||||||
ProvinceId *int64 `json:"provinceId"`
|
ProvinceId *int64 `json:"provinceId"`
|
||||||
PhoneNumbers string `json:"phoneNumbers"`
|
PhoneNumbers string `json:"phoneNumbers"`
|
||||||
BillingUsername string `json:"billingUsername"`
|
BillingUsername string `json:"billingUsername"`
|
||||||
BillingPassword string `json:"billingPassword"`
|
BillingPassword string `json:"billingPassword"`
|
||||||
BillingSberUsername string `json:"billingSberUsername"`
|
BillingSberUsername string `json:"billingSberUsername"`
|
||||||
BillingSberPassword string `json:"billingSberPassword"`
|
BillingSberPassword string `json:"billingSberPassword"`
|
||||||
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
BillingVisaMasterUsername string `json:"billingVisaMasterUsername"`
|
||||||
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
BillingVisaMasterPassword string `json:"billingVisaMasterPassword"`
|
||||||
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
BillingSwiftUsername string `json:"billingSwiftUsername"`
|
||||||
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
BillingSwiftPassword string `json:"billingSwiftPassword"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListFilter struct {
|
type ListFilter struct {
|
||||||
@@ -74,12 +70,12 @@ type ListFilter struct {
|
|||||||
// BranchListItemDTO is the list row; address, region and billing credentials
|
// BranchListItemDTO is the list row; address, region and billing credentials
|
||||||
// come from GET /branches/:id.
|
// come from GET /branches/:id.
|
||||||
type BranchListItemDTO struct {
|
type BranchListItemDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
UniqueCode string `json:"uniqueCode"`
|
UniqueCode string `json:"uniqueCode"`
|
||||||
Name LocalizedText `json:"name"`
|
Name shared.LocalizedText `json:"name"`
|
||||||
ProvinceName LocalizedText `json:"provinceName"`
|
ProvinceName shared.LocalizedText `json:"provinceName"`
|
||||||
PhoneNumbers string `json:"phoneNumbers"`
|
PhoneNumbers string `json:"phoneNumbers"`
|
||||||
Active bool `json:"active"`
|
Active bool `json:"active"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListBranchDTO struct {
|
type ListBranchDTO struct {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param unique_code query string false "Filter by unique code"
|
// @Param unique_code query string false "Filter by unique code"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -81,6 +82,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param active query bool false "Only active provinces" default(true)
|
// @Param active query bool false "Only active provinces" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -110,6 +112,7 @@ func (h *handler) listRegions(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param region query string true "Region name (en, ru or tm)"
|
// @Param region query string true "Region name (en, ru or tm)"
|
||||||
// @Param active query bool false "Only active etraps" default(true)
|
// @Param active query bool false "Only active etraps" default(true)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -144,6 +147,7 @@ func (h *handler) listEtraps(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -184,6 +188,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateBranchDTO true "Branch payload"
|
// @Param body body CreateBranchDTO true "Branch payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -218,6 +223,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
// @Param body body UpdateBranchDTO true "Branch payload"
|
// @Param body body UpdateBranchDTO true "Branch payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -261,6 +267,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Branch ID"
|
// @Param id path int true "Branch ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Param active query bool false "Filter by active status"
|
// @Param active query bool false "Filter by active status"
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Page number" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Items per page" default(10)
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -79,6 +80,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -113,6 +115,7 @@ func (h *handler) getByID(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body CreateProvinceDTO true "Province payload"
|
// @Param body body CreateProvinceDTO true "Province payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 201 {object} appresult.AppSuccess
|
// @Success 201 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -143,6 +146,7 @@ func (h *handler) create(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
// @Param body body UpdateProvinceDTO true "Province payload"
|
// @Param body body UpdateProvinceDTO true "Province payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -182,6 +186,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Province ID"
|
// @Param id path int true "Province ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -36,9 +36,16 @@ LEFT JOIN users u ON u.id = p.created_by`
|
|||||||
// isSberSQL mirrors visamasterpay's isSber for the order joined as o.
|
// isSberSQL mirrors visamasterpay's isSber for the order joined as o.
|
||||||
const isSberSQL = `LOWER(TRIM(COALESCE(o.type, ''))) = 'sber'`
|
const isSberSQL = `LOWER(TRIM(COALESCE(o.type, ''))) = 'sber'`
|
||||||
|
|
||||||
|
// paymentLogSQL selects from the order's visa_master_payment_logs rows of
|
||||||
|
// one step (served by visa_master_payment_logs_order_step_idx).
|
||||||
|
const paymentLogSQL = `FROM visa_master_payment_logs l WHERE l.order_id = p.order_id AND l.step = `
|
||||||
|
|
||||||
// historySelectColumns pulls only the handful of gateway_response fields a
|
// historySelectColumns pulls only the handful of gateway_response fields a
|
||||||
// row needs (formUrl, cardAuthInfo) out in SQL rather than shipping every
|
// row needs (formUrl, cardAuthInfo) out in SQL rather than shipping every
|
||||||
// row's whole jsonb blob to Go and decoding it there.
|
// row's whole jsonb blob to Go and decoding it there. formUrl falls back to
|
||||||
|
// the register.do response logged for the attempt (gateway_response drops
|
||||||
|
// it once finalized), successUrl is the returnUrl logged with register.do,
|
||||||
|
// and the callback columns come from its first callback_received log.
|
||||||
const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), COALESCE(o.unique_id, ''), COALESCE(o.type, ''),
|
const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), COALESCE(o.unique_id, ''), COALESCE(o.type, ''),
|
||||||
o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id,
|
o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id,
|
||||||
p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt,
|
p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt,
|
||||||
@@ -47,10 +54,15 @@ const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), CO
|
|||||||
p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period,
|
p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period,
|
||||||
p.gateway_status, p.gateway_reference,
|
p.gateway_status, p.gateway_reference,
|
||||||
CASE WHEN ` + isSberSQL + ` THEN COALESCE(b.billing_sber_username, '') ELSE COALESCE(b.billing_visa_master_username, '') END,
|
CASE WHEN ` + isSberSQL + ` THEN COALESCE(b.billing_sber_username, '') ELSE COALESCE(b.billing_visa_master_username, '') END,
|
||||||
|
CASE WHEN ` + isSberSQL + ` THEN 'billing_sber_username' ELSE 'billing_visa_master_username' END,
|
||||||
CASE WHEN ` + isSberSQL + ` THEN 'Sber tölegi' ELSE 'Visa/Master tölegi' END,
|
CASE WHEN ` + isSberSQL + ` THEN 'Sber tölegi' ELSE 'Visa/Master tölegi' END,
|
||||||
NULLIF(p.gateway_response->'cardAuthInfo'->>'cardholderName', ''),
|
NULLIF(p.gateway_response->'cardAuthInfo'->>'cardholderName', ''),
|
||||||
NULLIF(COALESCE(p.gateway_response->'cardAuthInfo'->>'maskedPan', p.gateway_response->'cardAuthInfo'->>'pan'), ''),
|
NULLIF(COALESCE(p.gateway_response->'cardAuthInfo'->>'maskedPan', p.gateway_response->'cardAuthInfo'->>'pan'), ''),
|
||||||
NULLIF(p.gateway_response->>'formUrl', ''),
|
COALESCE(NULLIF(p.gateway_response->>'formUrl', ''), (SELECT NULLIF(l.detail->>'formUrl', '') ` + paymentLogSQL + `'register_response'
|
||||||
|
AND l.detail->>'gbusOrderId' = p.gateway_reference ORDER BY l.id DESC LIMIT 1)),
|
||||||
|
(SELECT NULLIF(l.detail->>'returnUrl', '') ` + paymentLogSQL + `'register_request'
|
||||||
|
AND l.detail->>'paymentId' = p.id::text ORDER BY l.id DESC LIMIT 1),
|
||||||
|
(SELECT MIN(l.created_at) ` + paymentLogSQL + `'callback_received' AND l.detail->>'paymentId' = p.id::text),
|
||||||
p.created_by, ` + shared.UserDisplaySQL + `,
|
p.created_by, ` + shared.UserDisplaySQL + `,
|
||||||
p.created_at, p.updated_at`
|
p.created_at, p.updated_at`
|
||||||
|
|
||||||
@@ -130,6 +142,33 @@ func (r *repository) OrderPayments(ctx context.Context, orderID int64) ([]paymen
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *repository) OrderPaymentDetails(ctx context.Context, orderID int64) ([]paymenthistory.PaymentHistoryDetailDTO, error) {
|
||||||
|
whereClause, args := buildListQuery(paymenthistory.ListFilter{OrderId: &orderID})
|
||||||
|
query := `SELECT ` + historySelectColumns + `, p.gateway_response` + historyFromClause + whereClause + ` ORDER BY p.id DESC`
|
||||||
|
|
||||||
|
rows, err := r.client.Query(ctx, query, args...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
details := []paymenthistory.PaymentHistoryDetailDTO{}
|
||||||
|
for rows.Next() {
|
||||||
|
var detail paymenthistory.PaymentHistoryDetailDTO
|
||||||
|
item, err := r.scanHistoryItem(rows, &detail.GatewayResponse)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
detail.PaymentHistoryItemDTO = item
|
||||||
|
details = append(details, detail)
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return details, nil
|
||||||
|
}
|
||||||
|
|
||||||
// OwnerInfo returns orderID's owning user/branch, so the handler can run
|
// OwnerInfo returns orderID's owning user/branch, so the handler can run
|
||||||
// rbac.GuardOrder before returning its logs to a branch/own-scoped caller.
|
// rbac.GuardOrder before returning its logs to a branch/own-scoped caller.
|
||||||
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
||||||
@@ -227,7 +266,6 @@ func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args
|
|||||||
func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (paymenthistory.PaymentHistoryItemDTO, error) {
|
func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (paymenthistory.PaymentHistoryItemDTO, error) {
|
||||||
var item paymenthistory.PaymentHistoryItemDTO
|
var item paymenthistory.PaymentHistoryItemDTO
|
||||||
var branchNameJSON []byte
|
var branchNameJSON []byte
|
||||||
var formURL *string
|
|
||||||
dest := []interface{}{
|
dest := []interface{}{
|
||||||
&item.Id, &item.OrderId, &item.OrderNumber, &item.OrderUniqueId, &item.Type,
|
&item.Id, &item.OrderId, &item.OrderNumber, &item.OrderUniqueId, &item.Type,
|
||||||
&item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId,
|
&item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId,
|
||||||
@@ -235,8 +273,8 @@ func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (payment
|
|||||||
&item.AmountMinor, &item.AmountUsd,
|
&item.AmountMinor, &item.AmountUsd,
|
||||||
&item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod,
|
&item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod,
|
||||||
&item.GatewayStatus, &item.GatewayReference,
|
&item.GatewayStatus, &item.GatewayReference,
|
||||||
&item.ApiClient, &item.Description,
|
&item.ApiClient, &item.ApiClientName, &item.Description,
|
||||||
&item.CardholderName, &item.MaskedPan, &formURL,
|
&item.CardholderName, &item.MaskedPan, &item.FormUrl, &item.SuccessUrl, &item.CallbackAt,
|
||||||
&item.CreatedById, &item.CreatedByName,
|
&item.CreatedById, &item.CreatedByName,
|
||||||
&item.CreatedAt, &item.UpdatedAt,
|
&item.CreatedAt, &item.UpdatedAt,
|
||||||
}
|
}
|
||||||
@@ -248,13 +286,17 @@ func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (payment
|
|||||||
}
|
}
|
||||||
item.Paid = item.GatewayStatus == "success"
|
item.Paid = item.GatewayStatus == "success"
|
||||||
|
|
||||||
// formUrl only survives in gateway_response while the attempt is still
|
if item.CallbackAt != nil {
|
||||||
// pending - once finalized, gateway_response is overwritten with the
|
received := paymenthistory.CallbackReceived
|
||||||
// status-check response, which has no formUrl, so there's nothing to
|
item.CallbackStatus = &received
|
||||||
// resume for a paid/failed row. SuccessUrl must match the ReturnURL
|
}
|
||||||
// visamasterpay registered with GBÜS (see its Pay).
|
|
||||||
if formURL != nil {
|
// A returnUrl only matters for an attempt GBÜS registered (has a
|
||||||
item.FormUrl = formURL
|
// formUrl). Ones registered before register_request logged its
|
||||||
|
// returnUrl fall back to the ReturnURL visamasterpay's Pay uses.
|
||||||
|
if item.FormUrl == nil {
|
||||||
|
item.SuccessUrl = nil
|
||||||
|
} else if item.SuccessUrl == nil {
|
||||||
successURL := r.publicBaseURL + "/online/visa-master"
|
successURL := r.publicBaseURL + "/online/visa-master"
|
||||||
item.SuccessUrl = &successURL
|
item.SuccessUrl = &successURL
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,28 +45,39 @@ type PaymentHistoryItemDTO struct {
|
|||||||
GatewayStatus string `json:"gatewayStatus"`
|
GatewayStatus string `json:"gatewayStatus"`
|
||||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||||
// ApiClient is the branch's GBÜS merchant username for this order type
|
// ApiClient is the branch's GBÜS merchant username for this order type
|
||||||
// (visa/master or sber) and Description the text sent with register.do -
|
// (visa/master or sber), ApiClientName the branch setting it comes from
|
||||||
// both as visamasterpay's Pay picks them.
|
// (billing_visa_master_username or billing_sber_username), and
|
||||||
ApiClient string `json:"apiClient"`
|
// Description the text sent with register.do - all as visamasterpay's
|
||||||
Description string `json:"description"`
|
// Pay picks them.
|
||||||
|
ApiClient string `json:"apiClient"`
|
||||||
|
ApiClientName string `json:"apiClientName"`
|
||||||
|
Description string `json:"description"`
|
||||||
// CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
// CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
||||||
// cardAuthInfo, so they're only known once an attempt has been
|
// cardAuthInfo, so they're only known once an attempt has been
|
||||||
// finalized by the callback/status check (unset while pending, and for
|
// finalized by the callback/status check (unset while pending, and for
|
||||||
// attempts that never reached the card form).
|
// attempts that never reached the card form).
|
||||||
CardholderName *string `json:"cardholderName,omitempty"`
|
CardholderName *string `json:"cardholderName,omitempty"`
|
||||||
MaskedPan *string `json:"maskedPan,omitempty"`
|
MaskedPan *string `json:"maskedPan,omitempty"`
|
||||||
// FormUrl/SuccessUrl are only set while the attempt is still pending
|
// FormUrl is GBÜS's hosted payment page and SuccessUrl the returnUrl it
|
||||||
// (awaiting the customer to finish paying on GBÜS's hosted page) - once
|
// was registered with - set for every attempt register.do accepted,
|
||||||
// an attempt is finalized (success/failed), gateway_response no longer
|
// finalized ones included (unset if registration failed).
|
||||||
// holds a formUrl, so there's nothing left to resume.
|
FormUrl *string `json:"formUrl,omitempty"`
|
||||||
FormUrl *string `json:"formUrl,omitempty"`
|
SuccessUrl *string `json:"successUrl,omitempty"`
|
||||||
SuccessUrl *string `json:"successUrl,omitempty"`
|
// CallbackStatus is CallbackReceived once GBÜS's redirect reached the
|
||||||
CreatedById *int64 `json:"createdById,omitempty"`
|
// callback for this attempt, at CallbackAt (its first time); both are
|
||||||
CreatedByName string `json:"createdByName,omitempty"`
|
// unset if it never did (e.g. finalized by a /status check instead).
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
CallbackStatus *string `json:"callbackStatus,omitempty"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CallbackAt *time.Time `json:"callbackAt,omitempty"`
|
||||||
|
CreatedById *int64 `json:"createdById,omitempty"`
|
||||||
|
CreatedByName string `json:"createdByName,omitempty"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CallbackReceived is PaymentHistoryItemDTO.CallbackStatus once the GBÜS
|
||||||
|
// callback reached an attempt.
|
||||||
|
const CallbackReceived = "received"
|
||||||
|
|
||||||
// PaymentHistoryDetailDTO is a single payout attempt with the raw GBÜS
|
// PaymentHistoryDetailDTO is a single payout attempt with the raw GBÜS
|
||||||
// response kept alongside it - the list deliberately leaves the jsonb out
|
// response kept alongside it - the list deliberately leaves the jsonb out
|
||||||
// so pages stay small.
|
// so pages stay small.
|
||||||
|
|||||||
@@ -31,26 +31,27 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
|
||||||
group.GET("", h.list)
|
group.GET("", h.list)
|
||||||
group.GET("/payments/:id", h.get)
|
group.GET("/payments/:id", h.get)
|
||||||
group.GET("/payments/:id/gateway", h.gateway)
|
group.GET("/:id/gateway", h.gateway)
|
||||||
group.GET("/:id", h.orderPayments)
|
group.GET("/:id", h.orderPayments)
|
||||||
group.GET("/:id/logs", h.logs)
|
group.GET("/:id/logs", h.logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// list godoc
|
// list godoc
|
||||||
// @Summary List payment history
|
// @Summary Tölegleriň taryhy
|
||||||
// @Description Returns a paginated, branch-scoped audit trail of visa/master/sber payout attempts (paid, failed, or pending), across orders
|
// @Description Ähli sargytlaryň Visa/Master we Sber töleg synanyşyklaryny (tölenen, şowsuz, garaşylýan) sahypalap gaýtarýar. Tertip: sort/order boýunça (adaty ýagdaýda iň täzesi birinji). Bellik: diňe ulanyjynyň öz şahamçasynyň tölegleri görünýär.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param order_id query int false "Filter by order ID"
|
// @Param order_id query int false "Sargyt ID-si boýunça süzmek"
|
||||||
// @Param branch_id query int false "Filter by branch ID"
|
// @Param branch_id query int false "Şahamça ID-si boýunça süzmek"
|
||||||
// @Param user_id query int false "Filter by order owner (client) user ID"
|
// @Param user_id query int false "Sargyt eýesiniň (müşderiniň) ulanyjy ID-si boýunça süzmek"
|
||||||
// @Param status query string false "Filter by gateway status (pending, success, failed)"
|
// @Param status query string false "GBÜS statusy boýunça süzmek (pending, success, failed)"
|
||||||
// @Param search query string false "Filter by passport name/surname or order unique ID"
|
// @Param search query string false "Pasport ady/familiýasy ýa-da sargydyň unique ID-si boýunça gözlemek"
|
||||||
// @Param sort query string false "Sort column" Enums(id, created_at, status, amount) default(id)
|
// @Param sort query string false "Tertiplenýän sütün" Enums(id, created_at, status, amount) default(id)
|
||||||
// @Param order query string false "Sort direction" Enums(asc, desc) default(desc)
|
// @Param order query string false "Tertip ugry" Enums(asc, desc) default(desc)
|
||||||
// @Param page query int false "Page number" default(1)
|
// @Param page query int false "Sahypa belgisi" default(1)
|
||||||
// @Param limit query int false "Items per page" default(10)
|
// @Param limit query int false "Bir sahypadaky ýazgy sany" default(10)
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListPaymentHistoryDTO
|
// @Success 200 {object} ListPaymentHistoryDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -73,12 +74,13 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get godoc
|
// get godoc
|
||||||
// @Summary Get a single payment attempt
|
// @Summary Bir tölegiň jikme-jikligi
|
||||||
// @Description Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row
|
// @Description Töleg ID-si boýunça bir Visa/Master ýa-da Sber töleg synanyşygyny GBÜS-iň soňky jogaby (gatewayResponse) bilen gaýtarýar. Tertip: ýeke ýazgy. Bellik: taryh sanawyndaky bir setiriň jikme-jik görnüşi.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment ID"
|
// @Param id path int true "Töleg ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentHistoryDetailDTO
|
// @Success 200 {object} PaymentHistoryDetailDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -86,67 +88,76 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-history/payments/{id} [get]
|
// @Router /payment-history/payments/{id} [get]
|
||||||
func (h *handler) get(c *gin.Context) {
|
func (h *handler) get(c *gin.Context) {
|
||||||
result, ok := h.loadPayment(c)
|
paymentID, ok := shared.ParseID(c.Param("id"))
|
||||||
if !ok {
|
if !ok {
|
||||||
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := h.repository.Get(c.Request.Context(), paymentID)
|
||||||
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
|
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
h.logger.Errorf("get payment history failed (payment %d): %v", paymentID, err)
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if !h.guardOrder(c, result.OrderId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
// gateway godoc
|
// gateway godoc
|
||||||
// @Summary Get a payment with its HALKBANK response
|
// @Summary Sargydyň tölegleri GBÜS jogaplary bilen
|
||||||
// @Description Returns one payment the way the per-order payment table shows it - paid or not, the card it was paid from (cardholderName/maskedPan, null until GBÜS reports them), its time (createdAt), payment year/month, amounts and reference (orderNumber) - together with the last GBÜS (HALKBANK) response stored for it (gatewayResponse, null if GBÜS never answered). Backs the table's storage icon.
|
// @Description Bir sargydyň ähli tölegini her biriniň GBÜS (HALKBANK) soňky jogaby (gatewayResponse) bilen gaýtarýar: tölendimi, haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt), töleg ýyly/aýy, mukdarlary we belgisi (orderNumber). Tertip: iň täzesi birinji. Bellik: GBÜS kart maglumatyny habar berýänçä cardholderName/maskedPan null, GBÜS asla jogap bermedik bolsa gatewayResponse null; tablisadaky ammar nyşany şu endpoint-den işleýär.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Payment ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
// @Success 200 {object} PaymentGatewayDTO
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
|
// @Success 200 {array} PaymentGatewayDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-history/payments/{id}/gateway [get]
|
// @Router /payment-history/{id}/gateway [get]
|
||||||
func (h *handler) gateway(c *gin.Context) {
|
func (h *handler) gateway(c *gin.Context) {
|
||||||
result, ok := h.loadPayment(c)
|
orderID, ok := shared.ParseID(c.Param("id"))
|
||||||
if !ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, appresult.SuccessWithData(NewPaymentGatewayDTO(result)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// loadPayment loads the :id payment and runs the order guard on it,
|
|
||||||
// answering the request itself when that fails.
|
|
||||||
func (h *handler) loadPayment(c *gin.Context) (PaymentHistoryDetailDTO, bool) {
|
|
||||||
paymentID, ok := shared.ParseID(c.Param("id"))
|
|
||||||
if !ok {
|
if !ok {
|
||||||
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
|
||||||
return PaymentHistoryDetailDTO{}, false
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := h.repository.Get(c.Request.Context(), paymentID)
|
if !h.guardOrder(c, orderID) {
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
return
|
||||||
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
|
|
||||||
return PaymentHistoryDetailDTO{}, false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
details, err := h.repository.OrderPaymentDetails(c.Request.Context(), orderID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Errorf("get payment history failed (payment %d): %v", paymentID, err)
|
h.logger.Errorf("list order payment gateway responses failed (order %d): %v", orderID, err)
|
||||||
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
return PaymentHistoryDetailDTO{}, false
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !h.guardOrder(c, result.OrderId) {
|
result := make([]PaymentGatewayDTO, 0, len(details))
|
||||||
return PaymentHistoryDetailDTO{}, false
|
for _, detail := range details {
|
||||||
|
result = append(result, NewPaymentGatewayDTO(detail))
|
||||||
}
|
}
|
||||||
return result, true
|
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
|
||||||
}
|
}
|
||||||
|
|
||||||
// orderPayments godoc
|
// orderPayments godoc
|
||||||
// @Summary List an order's payments
|
// @Summary Sargydyň tölegleri
|
||||||
// @Description Returns every visa/master/sber payout attempt of one order, newest first - one row per payment with whether it was paid (paid/gatewayStatus), the card it was paid from (cardholderName/maskedPan, once GBÜS reports them), its time (createdAt) and period (paymentPeriod). The raw GBÜS response of a row is at /payment-history/payments/{id}; the step-by-step logs are at /payment-history/{id}/logs.
|
// @Description Bir sargydyň ähli Visa/Master we Sber töleg synanyşyklaryny gaýtarýar: her töleg üçin bir setir - tölendimi (paid/gatewayStatus), haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt) we döwri (paymentPeriod). Tertip: iň täzesi birinji. Bellik: bir tölegiň GBÜS jogaby /payment-history/payments/{id}, ähli tölegleriňki /payment-history/{id}/gateway, ädimme-ädim loglar /payment-history/{id}/logs salgysynda.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Order ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {array} PaymentHistoryItemDTO
|
// @Success 200 {array} PaymentHistoryItemDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
@@ -175,12 +186,13 @@ func (h *handler) orderPayments(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// logs godoc
|
// logs godoc
|
||||||
// @Summary Get payment logs for an order
|
// @Summary Sargydyň töleg loglary
|
||||||
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout, newest first - evidence of what actually happened, independent of the summary rows returned by /payment-history/{id}
|
// @Description Sargydyň tölegi işlenende ýazylan ähli ädimleri (visa_master_payment_logs) gaýtarýar. Tertip: iň täzesi birinji. Bellik: /payment-history/{id} setirlerinden garaşsyz, hakykatda näme bolandygynyň subutnamasy.
|
||||||
// @Tags payment-history
|
// @Tags payment-history
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Order ID"
|
// @Param id path int true "Sargyt ID-si"
|
||||||
|
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {array} PaymentLogDTO
|
// @Success 200 {array} PaymentLogDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
|
|||||||
@@ -12,20 +12,15 @@ import (
|
|||||||
"online-back/pkg/logging"
|
"online-back/pkg/logging"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/jackc/pgx/v4"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeRepository struct {
|
type fakeRepository struct {
|
||||||
Repository
|
Repository
|
||||||
payments map[int64]PaymentHistoryDetailDTO
|
orders map[int64][]PaymentHistoryDetailDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f fakeRepository) Get(_ context.Context, paymentID int64) (PaymentHistoryDetailDTO, error) {
|
func (f fakeRepository) OrderPaymentDetails(_ context.Context, orderID int64) ([]PaymentHistoryDetailDTO, error) {
|
||||||
p, ok := f.payments[paymentID]
|
return append([]PaymentHistoryDetailDTO{}, f.orders[orderID]...), nil
|
||||||
if !ok {
|
|
||||||
return PaymentHistoryDetailDTO{}, pgx.ErrNoRows
|
|
||||||
}
|
|
||||||
return p, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func strPtr(s string) *string { return &s }
|
func strPtr(s string) *string { return &s }
|
||||||
@@ -40,14 +35,14 @@ func gatewayRequest(t *testing.T, repo Repository, path string) *httptest.Respon
|
|||||||
router.Use(func(c *gin.Context) {
|
router.Use(func(c *gin.Context) {
|
||||||
c.Set("rbacPrincipal", &rbac.Principal{UserID: 1, Scope: rbac.ScopeAll})
|
c.Set("rbacPrincipal", &rbac.Principal{UserID: 1, Scope: rbac.ScopeAll})
|
||||||
})
|
})
|
||||||
router.GET("/payment-history/payments/:id/gateway", h.gateway)
|
router.GET("/payment-history/:id/gateway", h.gateway)
|
||||||
|
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/payment-history/payments/"+path, nil))
|
router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/payment-history/"+path, nil))
|
||||||
return rec
|
return rec
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayReturnsTableRowWithHalkbankJSON(t *testing.T) {
|
func TestGatewayReturnsOrderPaymentsWithHalkbankJSON(t *testing.T) {
|
||||||
created := time.Date(2026, 10, 22, 8, 19, 57, 0, time.UTC)
|
created := time.Date(2026, 10, 22, 8, 19, 57, 0, time.UTC)
|
||||||
paid := PaymentHistoryDetailDTO{
|
paid := PaymentHistoryDetailDTO{
|
||||||
PaymentHistoryItemDTO: PaymentHistoryItemDTO{
|
PaymentHistoryItemDTO: PaymentHistoryItemDTO{
|
||||||
@@ -59,57 +54,80 @@ func TestGatewayReturnsTableRowWithHalkbankJSON(t *testing.T) {
|
|||||||
},
|
},
|
||||||
GatewayResponse: json.RawMessage(`{"orderStatus":2,"actionCode":0}`),
|
GatewayResponse: json.RawMessage(`{"orderStatus":2,"actionCode":0}`),
|
||||||
}
|
}
|
||||||
repo := fakeRepository{payments: map[int64]PaymentHistoryDetailDTO{2922: paid}}
|
failed := PaymentHistoryDetailDTO{PaymentHistoryItemDTO: PaymentHistoryItemDTO{Id: 2921, OrderId: 9437, GatewayStatus: "failed"}}
|
||||||
|
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{9437: {paid, failed}}}
|
||||||
|
|
||||||
rec := gatewayRequest(t, repo, "2922/gateway")
|
rec := gatewayRequest(t, repo, "9437/gateway")
|
||||||
if rec.Code != http.StatusOK {
|
if rec.Code != http.StatusOK {
|
||||||
t.Fatalf("got %d %s", rec.Code, rec.Body.String())
|
t.Fatalf("got %d %s", rec.Code, rec.Body.String())
|
||||||
}
|
}
|
||||||
var body struct {
|
var body struct {
|
||||||
Data map[string]json.RawMessage `json:"data"`
|
Data []map[string]json.RawMessage `json:"data"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if len(body.Data) != 2 {
|
||||||
|
t.Fatalf("got %d payments, want 2", len(body.Data))
|
||||||
|
}
|
||||||
|
if got := string(body.Data[1]["id"]); got != "2921" {
|
||||||
|
t.Errorf("second payment id: got %s, want 2921", got)
|
||||||
|
}
|
||||||
want := map[string]string{
|
want := map[string]string{
|
||||||
"id": `2922`, "orderId": `9437`, "cardholderName": `"Amanowa guljemal"`, "maskedPan": `"993404**2453"`,
|
"id": `2922`, "orderId": `9437`, "cardholderName": `"Amanowa guljemal"`, "maskedPan": `"993404**2453"`,
|
||||||
"paymentYear": `2026`, "paymentMonth": `10`, "createdAt": `"2026-10-22T08:19:57Z"`,
|
"paymentYear": `2026`, "paymentMonth": `10`, "createdAt": `"2026-10-22T08:19:57Z"`,
|
||||||
"amountUsd": `250`, "amountTmt": `1063.44`, "orderNumber": `"221026131957"`,
|
"amountUsd": `250`, "amountTmt": `1063.44`, "orderNumber": `"221026131957"`,
|
||||||
"paid": `true`, "gatewayStatus": `"success"`, "gatewayResponse": `{"orderStatus":2,"actionCode":0}`,
|
"paid": `true`, "gatewayStatus": `"success"`, "gatewayResponse": `{"orderStatus":2,"actionCode":0}`,
|
||||||
}
|
}
|
||||||
if len(body.Data) != len(want) {
|
if len(body.Data[0]) != len(want) {
|
||||||
t.Errorf("got fields %v, want exactly %d", body.Data, len(want))
|
t.Errorf("got fields %v, want exactly %d", body.Data[0], len(want))
|
||||||
}
|
}
|
||||||
for key, value := range want {
|
for key, value := range want {
|
||||||
if got := string(body.Data[key]); got != value {
|
if got := string(body.Data[0][key]); got != value {
|
||||||
t.Errorf("%s: got %s, want %s", key, got, value)
|
t.Errorf("%s: got %s, want %s", key, got, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayNullsWhenHalkbankNeverAnswered(t *testing.T) {
|
func TestGatewayNullsWhenHalkbankNeverAnswered(t *testing.T) {
|
||||||
repo := fakeRepository{payments: map[int64]PaymentHistoryDetailDTO{
|
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{
|
||||||
7: {PaymentHistoryItemDTO: PaymentHistoryItemDTO{Id: 7, GatewayStatus: "failed"}},
|
3: {{PaymentHistoryItemDTO: PaymentHistoryItemDTO{Id: 7, OrderId: 3, GatewayStatus: "failed"}}},
|
||||||
}}
|
}}
|
||||||
rec := gatewayRequest(t, repo, "7/gateway")
|
rec := gatewayRequest(t, repo, "3/gateway")
|
||||||
var body struct {
|
var body struct {
|
||||||
Data map[string]json.RawMessage `json:"data"`
|
Data []map[string]json.RawMessage `json:"data"`
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if len(body.Data) != 1 {
|
||||||
|
t.Fatalf("got %d payments, want 1", len(body.Data))
|
||||||
|
}
|
||||||
for _, key := range []string{"cardholderName", "maskedPan", "gatewayResponse"} {
|
for _, key := range []string{"cardholderName", "maskedPan", "gatewayResponse"} {
|
||||||
if got := string(body.Data[key]); got != "null" {
|
if got := string(body.Data[0][key]); got != "null" {
|
||||||
t.Errorf("%s: got %q, want null", key, got)
|
t.Errorf("%s: got %q, want null", key, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayErrors(t *testing.T) {
|
func TestGatewayEmptyOrderAndBadID(t *testing.T) {
|
||||||
repo := fakeRepository{payments: map[int64]PaymentHistoryDetailDTO{}}
|
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{}}
|
||||||
for path, want := range map[string]int{"abc/gateway": http.StatusBadRequest, "999/gateway": http.StatusNotFound} {
|
|
||||||
if rec := gatewayRequest(t, repo, path); rec.Code != want {
|
rec := gatewayRequest(t, repo, "999/gateway")
|
||||||
t.Errorf("%s: got %d, want %d", path, rec.Code, want)
|
if rec.Code != http.StatusOK {
|
||||||
}
|
t.Fatalf("got %d %s", rec.Code, rec.Body.String())
|
||||||
|
}
|
||||||
|
var body struct {
|
||||||
|
Data json.RawMessage `json:"data"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if got := string(body.Data); got != "[]" {
|
||||||
|
t.Errorf("data: got %s, want []", got)
|
||||||
|
}
|
||||||
|
|
||||||
|
if rec := gatewayRequest(t, repo, "abc/gateway"); rec.Code != http.StatusBadRequest {
|
||||||
|
t.Errorf("abc/gateway: got %d, want %d", rec.Code, http.StatusBadRequest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ type Repository interface {
|
|||||||
// OrderPayments returns every payout attempt of a single order, newest
|
// OrderPayments returns every payout attempt of a single order, newest
|
||||||
// first - the per-order payment table, without paging.
|
// first - the per-order payment table, without paging.
|
||||||
OrderPayments(ctx context.Context, orderID int64) ([]PaymentHistoryItemDTO, error)
|
OrderPayments(ctx context.Context, orderID int64) ([]PaymentHistoryItemDTO, error)
|
||||||
|
// OrderPaymentDetails is OrderPayments with each attempt's raw GBÜS
|
||||||
|
// response kept alongside it.
|
||||||
|
OrderPaymentDetails(ctx context.Context, orderID int64) ([]PaymentHistoryDetailDTO, error)
|
||||||
// Logs returns the full visa_master_payment_logs audit trail for a
|
// Logs returns the full visa_master_payment_logs audit trail for a
|
||||||
// single order, newest first.
|
// single order, newest first.
|
||||||
Logs(ctx context.Context, orderID int64) ([]PaymentLogDTO, error)
|
Logs(ctx context.Context, orderID int64) ([]PaymentLogDTO, error)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Tags payment-settings
|
// @Tags payment-settings
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentSettingsDTO
|
// @Success 200 {object} PaymentSettingsDTO
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-settings [get]
|
// @Router /payment-settings [get]
|
||||||
@@ -58,6 +59,7 @@ func (h *handler) get(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param body body UpdatePaymentSettingsDTO true "Payment settings payload"
|
// @Param body body UpdatePaymentSettingsDTO true "Payment settings payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentSettingsDTO
|
// @Success 200 {object} PaymentSettingsDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param search query string false "Filter by code, name or text"
|
// @Param search query string false "Filter by code, name or text"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} ListPaymentTextDTO
|
// @Success 200 {object} ListPaymentTextDTO
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
// @Router /payment-texts [get]
|
// @Router /payment-texts [get]
|
||||||
@@ -77,6 +78,7 @@ func (h *handler) list(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentTextDTO
|
// @Success 200 {object} PaymentTextDTO
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
// @Failure 500 {object} appresult.AppError
|
// @Failure 500 {object} appresult.AppError
|
||||||
@@ -119,6 +121,7 @@ func (h *handler) getByCode(c *gin.Context) {
|
|||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
// @Param body body UpdatePaymentTextDTO true "Payment text payload"
|
// @Param body body UpdatePaymentTextDTO true "Payment text payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentTextDTO
|
// @Success 200 {object} PaymentTextDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -156,6 +159,7 @@ func (h *handler) update(c *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param code path string true "Text code"
|
// @Param code path string true "Text code"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} appresult.AppSuccess
|
// @Success 200 {object} appresult.AppSuccess
|
||||||
// @Failure 403 {object} appresult.AppError
|
// @Failure 403 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const orderTypeSber = "sber"
|
|||||||
|
|
||||||
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt,
|
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt,
|
||||||
bank_fee_tmt, gbus_fee_tmt, tveb_fee_usd, tveb_fee_tmt, total_amount_tmt,
|
bank_fee_tmt, gbus_fee_tmt, tveb_fee_usd, tveb_fee_tmt, total_amount_tmt,
|
||||||
gateway_status, gateway_reference, created_at, updated_at`
|
gateway_status, gateway_reference, gateway_response, created_at, updated_at`
|
||||||
|
|
||||||
type repository struct {
|
type repository struct {
|
||||||
client postgresql.Client
|
client postgresql.Client
|
||||||
@@ -306,10 +306,17 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
var gatewayStatus string
|
var gatewayStatus string
|
||||||
var gatewayReference *string
|
var gatewayReference *string
|
||||||
var createdBy *int64
|
var createdBy *int64
|
||||||
|
// staleFailure flags a row finalized as failed while GBÜS still reported
|
||||||
|
// it in progress (checked before the card was even entered, by code
|
||||||
|
// predating StatusResult.InProgress) - it is re-checked like a pending one.
|
||||||
|
var staleFailure bool
|
||||||
err := r.client.QueryRow(ctx,
|
err := r.client.QueryRow(ctx,
|
||||||
`SELECT order_id, gateway_status, gateway_reference, created_by FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
|
`SELECT order_id, gateway_status, gateway_reference, created_by,
|
||||||
|
COALESCE(gateway_status = 'failed' AND gateway_response->>'orderStatus' IN ('0', '1', '5')
|
||||||
|
AND COALESCE(gateway_response->>'errorCode', '0') IN ('', '0'), false)
|
||||||
|
FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
|
||||||
paymentID,
|
paymentID,
|
||||||
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy)
|
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy, &staleFailure)
|
||||||
if errors.Is(err, pgx.ErrNoRows) {
|
if errors.Is(err, pgx.ErrNoRows) {
|
||||||
// Unknown payment id: there's no order to attach a log row to.
|
// Unknown payment id: there's no order to attach a log row to.
|
||||||
return visamasterpay.PaymentResultDTO{}, visamasterpay.ErrPaymentNotFound
|
return visamasterpay.PaymentResultDTO{}, visamasterpay.ErrPaymentNotFound
|
||||||
@@ -354,7 +361,7 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
if gatewayStatus != "pending" {
|
if gatewayStatus != "pending" && !staleFailure {
|
||||||
item, err := fetchPaymentByID(ctx, r.client, paymentID)
|
item, err := fetchPaymentByID(ctx, r.client, paymentID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fail("load_payment", err)
|
fail("load_payment", err)
|
||||||
@@ -428,6 +435,17 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
fail("finalize_commit", err)
|
fail("finalize_commit", err)
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
} else if status.InProgress() {
|
||||||
|
// Not paid yet but not over either (e.g. checked before the card was
|
||||||
|
// entered): keep it pending so a later callback/Status re-checks it,
|
||||||
|
// storing the response so the card shows up once GBÜS reports it.
|
||||||
|
item, err = updatePaymentStatus(ctx, r.client, paymentID, "pending", status.RawResponse)
|
||||||
|
if err != nil {
|
||||||
|
fail("save_payment_status", err)
|
||||||
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
|
}
|
||||||
|
step("payment_still_pending", map[string]interface{}{"orderStatus": status.OrderStatus, "actionCode": status.ActionCode})
|
||||||
|
return finish(item), nil
|
||||||
} else {
|
} else {
|
||||||
item, err = updatePaymentStatus(ctx, r.client, paymentID, "failed", status.RawResponse)
|
item, err = updatePaymentStatus(ctx, r.client, paymentID, "failed", status.RawResponse)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -446,7 +464,8 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
|
|||||||
// HandleCallback does - for when the frontend can't rely on GBÜS's redirect
|
// HandleCallback does - for when the frontend can't rely on GBÜS's redirect
|
||||||
// having reached the callback (e.g. the user closed the hosted payment page
|
// having reached the callback (e.g. the user closed the hosted payment page
|
||||||
// first). Safe to call repeatedly: it only hits GBÜS while the attempt is
|
// first). Safe to call repeatedly: it only hits GBÜS while the attempt is
|
||||||
// still "pending" and otherwise just returns the already-finalized row.
|
// still "pending" (or a stale failure, see verifyPayment) and otherwise
|
||||||
|
// just returns the already-finalized row.
|
||||||
func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int64) (visamasterpay.PaymentResultDTO, error) {
|
func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int64) (visamasterpay.PaymentResultDTO, error) {
|
||||||
var paymentID int64
|
var paymentID int64
|
||||||
err := r.client.QueryRow(ctx,
|
err := r.client.QueryRow(ctx,
|
||||||
@@ -643,8 +662,9 @@ func updatePaymentGatewayResult(ctx context.Context, q execer, paymentID int64,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// updatePaymentStatus records the verified final outcome (from
|
// updatePaymentStatus records a verified getOrderStatusExtended.do outcome
|
||||||
// HandleCallback) and returns the updated row.
|
// (from HandleCallback/Status) - final, or still pending - and returns the
|
||||||
|
// updated row.
|
||||||
func updatePaymentStatus(ctx context.Context, q querier, paymentID int64, status string, response []byte) (visamasterpay.PaymentResultDTO, error) {
|
func updatePaymentStatus(ctx context.Context, q querier, paymentID int64, status string, response []byte) (visamasterpay.PaymentResultDTO, error) {
|
||||||
query := `
|
query := `
|
||||||
UPDATE visa_master_order_payments SET gateway_status = $1, gateway_response = $2,
|
UPDATE visa_master_order_payments SET gateway_status = $1, gateway_response = $2,
|
||||||
@@ -665,10 +685,13 @@ func scanPayment(row pgx.Row) (visamasterpay.PaymentResultDTO, error) {
|
|||||||
if err := row.Scan(
|
if err := row.Scan(
|
||||||
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt,
|
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt,
|
||||||
&item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
&item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
|
||||||
&item.GatewayStatus, &item.GatewayReference, &item.CreatedAt, &item.UpdatedAt,
|
&item.GatewayStatus, &item.GatewayReference, &item.GatewayResponse, &item.CreatedAt, &item.UpdatedAt,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return visamasterpay.PaymentResultDTO{}, err
|
return visamasterpay.PaymentResultDTO{}, err
|
||||||
}
|
}
|
||||||
|
if len(item.GatewayResponse) == 0 {
|
||||||
|
item.GatewayResponse = json.RawMessage("null")
|
||||||
|
}
|
||||||
return item, nil
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package visamasterpay
|
package visamasterpay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"online-back/internal/shared"
|
"online-back/internal/shared"
|
||||||
@@ -69,25 +70,28 @@ type CallbackResultDTO struct {
|
|||||||
// as its own row in visa_master_order_payments (a full audit trail -
|
// as its own row in visa_master_order_payments (a full audit trail -
|
||||||
// failed attempts are kept, not overwritten by a retry) - deliberately not
|
// failed attempts are kept, not overwritten by a retry) - deliberately not
|
||||||
// the full order+branch+user DTO owned by cards/visamaster (fetch that
|
// the full order+branch+user DTO owned by cards/visamaster (fetch that
|
||||||
// separately via GET /visa-master-payment-orders/:id).
|
// separately via GET /visa-master-payment-orders/:id). GatewayResponse is
|
||||||
|
// the last GBÜS response stored for the attempt (null if GBÜS never
|
||||||
|
// answered).
|
||||||
type PaymentResultDTO struct {
|
type PaymentResultDTO struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
OrderId int64 `json:"orderId"`
|
OrderId int64 `json:"orderId"`
|
||||||
OrderNumber string `json:"orderNumber"`
|
OrderNumber string `json:"orderNumber"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Paid bool `json:"paid"`
|
Paid bool `json:"paid"`
|
||||||
AmountUsd float64 `json:"amountUsd"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||||
AmountTmt float64 `json:"amountTmt"`
|
AmountTmt float64 `json:"amountTmt"`
|
||||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||||
PaymentPeriod time.Time `json:"paymentPeriod"`
|
PaymentPeriod time.Time `json:"paymentPeriod"`
|
||||||
GatewayStatus string `json:"gatewayStatus"`
|
GatewayStatus string `json:"gatewayStatus"`
|
||||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
// quote godoc
|
// quote godoc
|
||||||
// @Summary Quote a visa/master/sber payment
|
// @Summary Quote a visa/master/sber payment
|
||||||
// @Description Returns the current rate, configured fees, and max payable amount for an order's payout
|
// @Description Returns the current rate, configured fees, and max payable amount for an order's payout
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentQuoteDTO
|
// @Success 200 {object} PaymentQuoteDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -71,12 +72,13 @@ func (h *handler) quote(c *gin.Context) {
|
|||||||
// pay godoc
|
// pay godoc
|
||||||
// @Summary Start a visa/master/sber payout
|
// @Summary Start a visa/master/sber payout
|
||||||
// @Description Registers the payment with GBÜS and returns the hosted-payment-page URL to complete it on. The final outcome is only known once GBÜS redirects back to the callback, which verifies and finalizes it.
|
// @Description Registers the payment with GBÜS and returns the hosted-payment-page URL to complete it on. The final outcome is only known once GBÜS redirects back to the callback, which verifies and finalizes it.
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
// @Param body body PayOrderDTO true "Payment payload"
|
// @Param body body PayOrderDTO true "Payment payload"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentInitResultDTO
|
// @Success 200 {object} PaymentInitResultDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -112,11 +114,12 @@ func (h *handler) pay(c *gin.Context) {
|
|||||||
|
|
||||||
// status godoc
|
// status godoc
|
||||||
// @Summary Re-check a visa/master/sber order's latest payment attempt
|
// @Summary Re-check a visa/master/sber order's latest payment attempt
|
||||||
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. Safe to call repeatedly.
|
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. gatewayResponse is GBÜS's last stored response for the attempt (null if GBÜS never answered). Safe to call repeatedly.
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security BearerAuth
|
// @Security BearerAuth
|
||||||
// @Param id path int true "Visa/master payment order ID"
|
// @Param id path int true "Visa/master payment order ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} PaymentResultDTO
|
// @Success 200 {object} PaymentResultDTO
|
||||||
// @Failure 400 {object} appresult.AppError
|
// @Failure 400 {object} appresult.AppError
|
||||||
// @Failure 404 {object} appresult.AppError
|
// @Failure 404 {object} appresult.AppError
|
||||||
@@ -149,9 +152,10 @@ func (h *handler) status(c *gin.Context) {
|
|||||||
// callback godoc
|
// callback godoc
|
||||||
// @Summary GBÜS payment callback
|
// @Summary GBÜS payment callback
|
||||||
// @Description GBÜS redirects the browser here after payment; the real outcome is verified server-to-server before anything is finalized
|
// @Description GBÜS redirects the browser here after payment; the real outcome is verified server-to-server before anything is finalized
|
||||||
// @Tags visa-master-payment-orders
|
// @Tags visa-master-payment
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param paymentId query int true "Payment attempt ID"
|
// @Param paymentId query int true "Payment attempt ID"
|
||||||
|
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
|
||||||
// @Success 200 {object} CallbackResultDTO
|
// @Success 200 {object} CallbackResultDTO
|
||||||
// @Router /visa-master-payment-orders/callback [get]
|
// @Router /visa-master-payment-orders/callback [get]
|
||||||
func (h *handler) callback(c *gin.Context) {
|
func (h *handler) callback(c *gin.Context) {
|
||||||
|
|||||||
@@ -58,6 +58,17 @@ type StatusResult struct {
|
|||||||
RawResponse []byte
|
RawResponse []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InProgress reports an unpaid order GBÜS may still complete - registered
|
||||||
|
// but not attempted yet (0), pre-authorized (1) or in 3-D Secure (5) - so
|
||||||
|
// it must stay re-checkable instead of being finalized as failed. Reversed
|
||||||
|
// (3), refunded (4), declined (6) or any gateway error are final.
|
||||||
|
func (r StatusResult) InProgress() bool {
|
||||||
|
if r.ErrorCode != "" && r.ErrorCode != "0" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return r.OrderStatus == 0 || r.OrderStatus == 1 || r.OrderStatus == 5
|
||||||
|
}
|
||||||
|
|
||||||
// Client is the gateway contract. Plug a real HTTPClient in once
|
// Client is the gateway contract. Plug a real HTTPClient in once
|
||||||
// credentials are configured; LogClient is a stand-in for local/dev use.
|
// credentials are configured; LogClient is a stand-in for local/dev use.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
|
|||||||
@@ -27,6 +27,27 @@ func TestRegisterResultSuccess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStatusResultInProgress(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
name string
|
||||||
|
r StatusResult
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"registered, not attempted", StatusResult{OrderStatus: 0, ErrorCode: "0"}, true},
|
||||||
|
{"pre-authorized", StatusResult{OrderStatus: 1}, true},
|
||||||
|
{"3-D Secure", StatusResult{OrderStatus: 5, ErrorCode: "0"}, true},
|
||||||
|
{"paid", StatusResult{Paid: true, OrderStatus: 2}, false},
|
||||||
|
{"reversed", StatusResult{OrderStatus: 3}, false},
|
||||||
|
{"declined", StatusResult{OrderStatus: 6, ErrorCode: "0"}, false},
|
||||||
|
{"gateway error", StatusResult{OrderStatus: 0, ErrorCode: "6"}, false},
|
||||||
|
}
|
||||||
|
for _, c := range cases {
|
||||||
|
if got := c.r.InProgress(); got != c.want {
|
||||||
|
t.Errorf("%s: InProgress()=%v want %v", c.name, got, c.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLogClientAlwaysPaid(t *testing.T) {
|
func TestLogClientAlwaysPaid(t *testing.T) {
|
||||||
c := NewLogClient(nil)
|
c := NewLogClient(nil)
|
||||||
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
|
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
|
||||||
@@ -74,8 +95,8 @@ func TestHTTPClientCheckStatusPaidMapping(t *testing.T) {
|
|||||||
body string
|
body string
|
||||||
paid bool
|
paid bool
|
||||||
}{
|
}{
|
||||||
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
|
||||||
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
|
||||||
{`{"orderStatus":6,"actionCode":"declined"}`, false},
|
{`{"orderStatus":6,"actionCode":"declined"}`, false},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|||||||
Reference in New Issue
Block a user