forked from ebhomengo/niki
fix(niki): internal, validator and structure refactor
This commit is contained in:
parent
f82c85b455
commit
705adda09b
|
@ -9,6 +9,7 @@ niki
|
|||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
activate.mise.toml
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
@ -17,11 +18,13 @@ niki
|
|||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
vendor/
|
||||
.idea
|
||||
bin
|
||||
|
||||
#.env
|
||||
*.env
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
mise.log
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package kavenegar
|
||||
|
||||
import "github.com/kavenegar/kavenegar-go"
|
||||
|
||||
type Config struct {
|
||||
APIKey string `koanf:"api_key"`
|
||||
Sender string `koanf:"sender"`
|
||||
}
|
||||
|
||||
type Adapter struct {
|
||||
config Config
|
||||
adapter *kavenegar.Kavenegar
|
||||
}
|
||||
|
||||
func New(config Config) *Adapter {
|
||||
return &Adapter{config: config, adapter: kavenegar.New(config.APIKey)}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package kavenegarnotification
|
||||
package kavenegar
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -6,11 +6,11 @@ import (
|
|||
"github.com/kavenegar/kavenegar-go"
|
||||
)
|
||||
|
||||
func (a *Adapter) Send(phoneNumber, message string) {
|
||||
func (a Adapter) Send(phoneNumber, message string) {
|
||||
const op = "kavenegarnotification.Send"
|
||||
|
||||
var params *kavenegar.MessageSendParam
|
||||
if _, err := a.adapter.Client().Message.Send(a.adapter.Config().Sender, []string{phoneNumber}, message, params); err != nil {
|
||||
if _, err := a.adapter.Message.Send(a.config.Sender, []string{phoneNumber}, message, params); err != nil {
|
||||
//nolint
|
||||
switch err := err.(type) {
|
||||
case *kavenegar.APIError:
|
|
@ -17,16 +17,16 @@ type Adapter struct {
|
|||
client *redis.Client
|
||||
}
|
||||
|
||||
func New(config Config) Adapter {
|
||||
func New(config Config) *Adapter {
|
||||
rdb := redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", config.Host, config.Port),
|
||||
Password: config.Password,
|
||||
DB: config.DB,
|
||||
})
|
||||
|
||||
return Adapter{client: rdb}
|
||||
return &Adapter{client: rdb}
|
||||
}
|
||||
|
||||
func (a Adapter) Client() *redis.Client {
|
||||
func (a *Adapter) Client() *redis.Client {
|
||||
return a.client
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package kavenegar
|
||||
|
||||
import "github.com/kavenegar/kavenegar-go"
|
||||
|
||||
type Config struct {
|
||||
APIKey string `koanf:"api_key"`
|
||||
Sender string `koanf:"sender"`
|
||||
OtpTemplateNewUser string `koanf:"otp_template_new_user"`
|
||||
OtpTemplateRegisteredUser string `koanf:"otp_template_registered_user"`
|
||||
}
|
||||
|
||||
type Adapter struct {
|
||||
config Config
|
||||
api *kavenegar.Kavenegar
|
||||
}
|
||||
|
||||
func New(config Config) *Adapter {
|
||||
return &Adapter{config: config, api: kavenegar.New(config.APIKey)}
|
||||
}
|
||||
|
||||
func (a Adapter) Client() *kavenegar.Kavenegar {
|
||||
return a.api
|
||||
}
|
||||
|
||||
func (a Adapter) Config() Config {
|
||||
return a.config
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package kavenegarnotification
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar"
|
||||
|
||||
type Adapter struct {
|
||||
adapter *kavenegar.Adapter
|
||||
}
|
||||
|
||||
func New(adapter *kavenegar.Adapter) *Adapter {
|
||||
return &Adapter{adapter: adapter}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package kavenegarotp
|
||||
|
||||
import (
|
||||
smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar"
|
||||
)
|
||||
|
||||
type Adapter struct {
|
||||
adapter *smsprovider.Adapter
|
||||
}
|
||||
|
||||
func New(conn *smsprovider.Adapter) *Adapter {
|
||||
return &Adapter{adapter: conn}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package kavenegarotp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
"github.com/kavenegar/kavenegar-go"
|
||||
)
|
||||
|
||||
func (a Adapter) SendForNewUser(phoneNumber, code string) {
|
||||
const op = richerror.Op("kavenegarotp.Send")
|
||||
|
||||
params := &kavenegar.VerifyLookupParam{}
|
||||
if _, err := a.adapter.Client().Verify.Lookup(phoneNumber, a.adapter.Config().OtpTemplateNewUser, code, params); err != nil {
|
||||
//nolint
|
||||
switch err := err.(type) {
|
||||
case *kavenegar.APIError:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
case *kavenegar.HTTPError:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
default:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
}
|
||||
}
|
||||
// TODO - log res res.Status
|
||||
}
|
||||
|
||||
func (a Adapter) SendForRegisteredUser(phoneNumber, code string) {
|
||||
const op = richerror.Op("kavenegarotp.Send")
|
||||
|
||||
params := &kavenegar.VerifyLookupParam{}
|
||||
if _, err := a.adapter.Client().Verify.Lookup(phoneNumber, a.adapter.Config().OtpTemplateRegisteredUser, code, params); err != nil {
|
||||
//nolint
|
||||
switch err := err.(type) {
|
||||
case *kavenegar.APIError:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
case *kavenegar.HTTPError:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
default:
|
||||
// log error
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, err))
|
||||
}
|
||||
}
|
||||
// TODO - log res res.Status
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
type: yml
|
||||
|
||||
auth:
|
||||
benefactor_auth:
|
||||
sign_key: jwt_secret_test_nik
|
||||
|
||||
http_server:
|
||||
|
@ -30,8 +30,6 @@ benefactor_service:
|
|||
kavenegar_sms_provider:
|
||||
api_key: insert_your_api_key
|
||||
sender: insert_sender_number
|
||||
otp_template_new_user: ebhomeverify
|
||||
otp_template_registered_user: ebhomeverify
|
||||
|
||||
admin_auth:
|
||||
sign_key: admin-jwt_secret_test_nik
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/kavenegar"
|
||||
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
|
||||
smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
||||
|
@ -15,7 +15,7 @@ type HTTPServer struct {
|
|||
type Config struct {
|
||||
HTTPServer HTTPServer `koanf:"http_server"`
|
||||
Mysql mysql.Config `koanf:"mariadb"`
|
||||
Auth authservice.Config `koanf:"auth"`
|
||||
BenefactorAuth authservice.Config `koanf:"benefactor_auth"`
|
||||
AdminAuth authservice.Config `koanf:"admin_auth"`
|
||||
Redis redis.Config `koanf:"redis"`
|
||||
KavenegarSmsProvider smsprovider.Config `koanf:"kavenegar_sms_provider"`
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
func Default() Config {
|
||||
cfx := Config{
|
||||
Auth: authservice.Config{
|
||||
BenefactorAuth: authservice.Config{
|
||||
AccessExpirationTime: AccessTokenExpireDuration,
|
||||
RefreshExpirationTime: RefreshTokenExpireDuration,
|
||||
AccessSubject: AccessTokenSubject,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package smscontract
|
||||
|
||||
type SmsAdapter interface {
|
||||
Send(phoneNumber string, message string)
|
||||
}
|
|
@ -4,26 +4,21 @@ import (
|
|||
adminservice "git.gocasts.ir/ebhomengo/niki/service/admin/admin"
|
||||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
adminauthservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig adminauthservice.Config
|
||||
authSvc adminauthservice.Service
|
||||
adminSvc adminservice.Service
|
||||
adminVld adminvalidator.Validator
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
}
|
||||
|
||||
func New(authConfig adminauthservice.Config, authSvc adminauthservice.Service,
|
||||
adminSvc adminservice.Service, adminVld adminvalidator.Validator,
|
||||
func New(authSvc adminauthservice.Service,
|
||||
adminSvc adminservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
adminSvc: adminSvc,
|
||||
adminVld: adminVld,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,17 +24,15 @@ func (h Handler) LoginByPhoneNumber(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminVld.ValidateLoginWithPhoneNumberRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.adminSvc.LoginWithPhoneNumber(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -25,17 +25,15 @@ func (h Handler) Register(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminVld.ValidateRegisterRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.adminSvc.Register(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -11,9 +11,8 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
|
||||
//nolint:gocritic
|
||||
//r.POST("/", h.Add).Name = "admin-addkindboxreq"
|
||||
r.POST("/register", h.Register, middleware.Auth(h.authSvc, h.authConfig), middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminAdminRegisterPermission))
|
||||
r.POST("/register", h.Register, middleware.Auth(h.authSvc), middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminAdminRegisterPermission))
|
||||
r.POST("/login-by-phone", h.LoginByPhoneNumber)
|
||||
//nolint:gocritic
|
||||
//r.PATCH("/:id", h.Update).Name = "admin-updatekindboxreq"
|
||||
r.GET("/agents", h.GetAllAgent, middleware.Auth(h.authSvc, h.authConfig), middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminAdminGetAllAgentPermission))
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package adminhandler
|
||||
package adminagenthandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
adminagentparam "git.gocasts.ir/ebhomengo/niki/param/admin/agent"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
@ -12,12 +13,13 @@ import (
|
|||
// @Tags Admin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} adminserviceparam.GetAllAgentResponse
|
||||
// @Success 200 {object} adminagentparam.GetAllAgentResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/agents [get].
|
||||
func (h Handler) GetAllAgent(c echo.Context) error {
|
||||
resp, sErr := h.adminSvc.GetAllAgent(c.Request().Context())
|
||||
var resp adminagentparam.GetAllAgentResponse
|
||||
resp, sErr := h.agentSvc.GetAllAgent(c.Request().Context())
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package adminagenthandler
|
||||
|
||||
import (
|
||||
agentservice "git.gocasts.ir/ebhomengo/niki/service/admin/agent"
|
||||
authorizeservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authSvc authservice.Service
|
||||
agentSvc agentservice.Service
|
||||
authorizeSvc authorizeservice.Service
|
||||
}
|
||||
|
||||
func New(authSvc authservice.Service,
|
||||
agentSvc agentservice.Service,
|
||||
authorizeSvc authorizeservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authSvc: authSvc,
|
||||
agentSvc: agentSvc,
|
||||
authorizeSvc: authorizeSvc,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package adminagenthandler
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/middleware"
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/admins")
|
||||
|
||||
r.GET("/agents", h.GetAllAgent, middleware.Auth(h.authSvc), middleware.AdminAuthorization(h.authorizeSvc, entity.AdminAdminGetAllAgentPermission))
|
||||
}
|
|
@ -26,19 +26,16 @@ func (h Handler) AssignReceiverAgent(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxVld.ValidateAssignReceiverAgent(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
sErr := h.adminKindBoxSvc.AssignReceiverAgent(c.Request().Context(), req)
|
||||
resp, sErr := h.adminKindBoxSvc.AssignReceiverAgent(c.Request().Context(), req)
|
||||
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -30,22 +30,19 @@ func (h Handler) Enumerate(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxVld.ValidateEnumerate(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
sErr := h.adminKindBoxSvc.Enumerate(c.Request().Context(), req)
|
||||
resp, sErr := h.adminKindBoxSvc.Enumerate(c.Request().Context(), req)
|
||||
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusNoContent, nil)
|
||||
return c.JSON(http.StatusNoContent, resp)
|
||||
}
|
||||
|
|
|
@ -24,17 +24,16 @@ func (h Handler) Get(c echo.Context) error {
|
|||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
if fieldErrors, err := h.adminKindBoxVld.ValidateGetRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.adminKindBoxSvc.Get(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -48,18 +48,16 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.adminKindBoxVld.ValidateGetAll(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxSvc.GetAll(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -4,26 +4,21 @@ import (
|
|||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
adminKindBoxSvc adminkindboxservice.Service
|
||||
adminKindBoxVld adminkindboxvalidator.Validator
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config, authSvc authservice.Service,
|
||||
adminKindBoxSvc adminkindboxservice.Service, adminKindBoxVld adminkindboxvalidator.Validator,
|
||||
func New(authSvc authservice.Service,
|
||||
adminKindBoxSvc adminkindboxservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
adminKindBoxSvc: adminKindBoxSvc,
|
||||
adminKindBoxVld: adminKindBoxVld,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/admin/kindboxes")
|
||||
|
||||
r.Use(middleware.Auth(h.authSvc, h.authConfig))
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
|
||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetPermission))
|
||||
r.PATCH("/assign-receiver-agent/:id", h.AssignReceiverAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxAssignReceiverAgentPermission))
|
||||
|
|
|
@ -32,18 +32,16 @@ func (h Handler) Accept(c echo.Context) error {
|
|||
return c.JSON(http.StatusBadRequest, errmsg.ErrorMsgInvalidInput)
|
||||
}
|
||||
req.ID = uint(num)
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateAcceptRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxReqSvc.Accept(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -24,18 +24,16 @@ func (h Handler) AddKindBoxReq(c echo.Context) error {
|
|||
if err := c.Bind(&req); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, errmsg.ErrBadRequest)
|
||||
}
|
||||
result := h.adminKindBoxReqVld.ValidateAddRequest(req)
|
||||
if result != nil {
|
||||
msg, code := httpmsg.Error(result.Err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": result.Fields,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.adminKindBoxReqSvc.Add(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -36,19 +36,16 @@ func (h Handler) AssignSenderAgent(c echo.Context) error {
|
|||
|
||||
req.KindBoxReqID = uint(id)
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateAssignSenderAgent(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxReqSvc.AssignSenderAgent(c.Request().Context(), req)
|
||||
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -29,24 +29,21 @@ func (h Handler) Deliver(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateDeliver(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
q := querier.GetQuerierFromContextOrNew(c.Request().Context()).Begin()
|
||||
ctx := context.WithValue(c.Request().Context(), querier.QuerierContextKey, q)
|
||||
resp, sErr := h.adminKindBoxReqSvc.Deliver(ctx, req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
rErr := q.Rollback()
|
||||
if rErr != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, errmsg.ErrorMsgSomethingWentWrong)
|
||||
}
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -28,18 +28,15 @@ func (h Handler) Get(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := h.adminKindBoxReqSvc.Get(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -46,18 +46,16 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetAll(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, err := h.adminKindBoxReqSvc.GetAll(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -39,22 +39,18 @@ func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
|||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetAllAwaitingDelivery(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus.String()
|
||||
|
||||
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
|
||||
resp, sErr := h.adminKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -28,18 +28,15 @@ func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.AgentID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetAwaitingDeliveryRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -5,27 +5,22 @@ import (
|
|||
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
"git.gocasts.ir/ebhomengo/niki/service/notification"
|
||||
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
adminKindBoxReqSvc adminkindboxreqservice.Service
|
||||
adminKindBoxReqVld adminkindboxreqvalidator.Validator
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
notificationSvc notification.Service
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config, authSvc authservice.Service,
|
||||
adminKindBoxReqSvc adminkindboxreqservice.Service, adminKindBoxReqVld adminkindboxreqvalidator.Validator,
|
||||
func New(authSvc authservice.Service,
|
||||
adminKindBoxReqSvc adminkindboxreqservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service, notificationSvc notification.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
adminKindBoxReqSvc: adminKindBoxReqSvc,
|
||||
adminKindBoxReqVld: adminKindBoxReqVld,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
notificationSvc: notificationSvc,
|
||||
}
|
||||
|
|
|
@ -31,18 +31,16 @@ func (h Handler) Reject(c echo.Context) error {
|
|||
return c.JSON(http.StatusBadRequest, errmsg.ErrorMsgInvalidInput)
|
||||
}
|
||||
req.ID = uint(num)
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateRejectRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxReqSvc.Reject(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/admins/kindboxreqs")
|
||||
|
||||
r.Use(middleware.Auth(h.authSvc, h.authConfig))
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
r.POST("", h.AddKindBoxReq, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAddPermission))
|
||||
r.PATCH("/accept-kind-box-req/:id", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
|
||||
r.PATCH("/reject-kind-box-req/:id", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
|
||||
|
|
|
@ -25,18 +25,15 @@ func (h Handler) Update(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if fieldErrors, err := h.adminKindBoxReqVld.ValidateUpdateRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
sErr := h.adminKindBoxReqSvc.Update(c.Request().Context(), req)
|
||||
resp, sErr := h.adminKindBoxReqSvc.Update(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -32,18 +32,15 @@ func (h Handler) Get(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.AgentID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.agentKindBoxVld.ValidateGetRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.agentKindBoxSvc.Get(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -44,20 +44,18 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.agentKindBoxVld.ValidateGetAll(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: fieldErrors,
|
||||
})
|
||||
}
|
||||
req.Filter["receiver_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Filter["status"] = entity.KindBoxAssignedReceiverAgentStatus.String()
|
||||
req.Filter["status"] = entity.KindBoxAssignedReceiverAgentStatus
|
||||
|
||||
resp, err := h.agentKindBoxSvc.GetAll(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -4,26 +4,21 @@ import (
|
|||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
agentkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
agentKindBoxSvc agentkindboxservice.Service
|
||||
agentKindBoxVld agentkindboxvalidator.Validator
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config, authSvc authservice.Service,
|
||||
agentKindBoxSvc agentkindboxservice.Service, agentKindBoxVld agentkindboxvalidator.Validator,
|
||||
func New(authSvc authservice.Service,
|
||||
agentKindBoxSvc agentkindboxservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
agentKindBoxSvc: agentKindBoxSvc,
|
||||
agentKindBoxVld: agentKindBoxVld,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,19 +33,16 @@ func (h Handler) Return(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.AgentID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.agentKindBoxVld.ValidateReturn(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
resp, sErr := h.agentKindBoxSvc.Return(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, httpmsg.ErrorResponse{
|
||||
Message: msg,
|
||||
Errors: fieldErrors,
|
||||
Errors: resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
err := h.agentKindBoxSvc.Return(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/agents/kindboxes")
|
||||
|
||||
r.Use(middleware.Auth(h.authSvc, h.authConfig))
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
|
||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
|
||||
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
|
||||
|
|
|
@ -28,18 +28,16 @@ func (h Handler) AddAddress(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.addressVld.ValidateAddAddress(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.addressSvc.Add(c.Request().Context(), req)
|
||||
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -26,17 +26,16 @@ func (h Handler) DeleteAddress(c echo.Context) error {
|
|||
}
|
||||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
if fieldErrors, err := h.addressVld.ValidateDeleteRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
dErr := h.addressSvc.Delete(c.Request().Context(), req)
|
||||
resp, dErr := h.addressSvc.Delete(c.Request().Context(), req)
|
||||
if dErr != nil {
|
||||
msg, code := httpmsg.Error(dErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -27,17 +27,15 @@ func (h Handler) GetAddress(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.addressVld.ValidateGetAddress(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.addressSvc.Get(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -3,26 +3,19 @@ package benefactoraddresshandler
|
|||
import (
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
||||
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
addressSvc benefactoraddressservice.Service
|
||||
addressVld benefactoraddressvalidator.Validator
|
||||
}
|
||||
|
||||
func New(
|
||||
authConfig authservice.Config,
|
||||
authSvc authservice.Service,
|
||||
addressSvc benefactoraddressservice.Service,
|
||||
addressVld benefactoraddressvalidator.Validator,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
addressSvc: addressSvc,
|
||||
addressVld: addressVld,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
|
||||
r.GET("/provinces", h.GetAllProvinces)
|
||||
r.GET("/cities", h.GetAllCities)
|
||||
r.POST("/", h.AddAddress, middleware.Auth(h.authSvc, h.authConfig),
|
||||
r.POST("/", h.AddAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.GET("/:id", h.GetAddress, middleware.Auth(h.authSvc, h.authConfig),
|
||||
r.GET("/:id", h.GetAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.GET("/", h.GetAddresses, middleware.Auth(h.authSvc, h.authConfig),
|
||||
r.GET("/", h.GetAddresses, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.DELETE("/:id", h.DeleteAddress, middleware.Auth(h.authSvc, h.authConfig),
|
||||
r.DELETE("/:id", h.DeleteAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.PATCH("/:id", h.UpdateAddress, middleware.Auth(h.authSvc, h.authConfig),
|
||||
r.PATCH("/:id", h.UpdateAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
}
|
||||
|
|
|
@ -33,18 +33,15 @@ func (h Handler) UpdateAddress(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.addressVld.ValidateUpdateAddress(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
sErr := h.addressSvc.Update(c.Request().Context(), req)
|
||||
|
||||
resp, sErr := h.addressSvc.Update(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -3,25 +3,19 @@ package benefactorhandler
|
|||
import (
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
||||
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
benefactorSvc benefactorservice.Service
|
||||
benefactorVld benefactorvalidator.Validator
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config,
|
||||
func New(
|
||||
authSvc authservice.Service,
|
||||
benefactorSvc benefactorservice.Service,
|
||||
benefactorVld benefactorvalidator.Validator,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
benefactorSvc: benefactorSvc,
|
||||
benefactorVld: benefactorVld,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package benefactorhandler
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
benefactoreparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactore"
|
||||
benefactoreparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
@ -24,17 +24,16 @@ func (h Handler) loginOrRegister(c echo.Context) error {
|
|||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
if fieldErrors, err := h.benefactorVld.ValidateLoginRegisterRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.benefactorSvc.LoginOrRegister(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package benefactorhandler
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
benefactoreparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactore"
|
||||
benefactoreparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
@ -24,17 +24,15 @@ func (h Handler) SendOtp(c echo.Context) error {
|
|||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
if fieldErrors, err := h.benefactorVld.ValidateSendOtpRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.benefactorSvc.SendOtp(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -24,17 +24,16 @@ func (h Handler) Get(c echo.Context) error {
|
|||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
if fieldErrors, err := h.benefactorKindBoxVld.ValidateGetRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.benefactorKindBoxSvc.Get(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -49,18 +49,16 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.benefactorKindBoxVld.ValidateGetAll(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
req.Filter["benefactor_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
resp, sErr := h.benefactorKindBoxSvc.GetAll(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -3,23 +3,18 @@ package benefactorkindboxhandler
|
|||
import (
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box"
|
||||
benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
benefactorKindBoxSvc benefactorkindboxservice.Service
|
||||
benefactorKindBoxVld benefactorkindboxvalidator.Validator
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config, authSvc authservice.Service,
|
||||
benefactorKindBoxSvc benefactorkindboxservice.Service, benefactorKindBoxVld benefactorkindboxvalidator.Validator,
|
||||
func New(authSvc authservice.Service,
|
||||
benefactorKindBoxSvc benefactorkindboxservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
benefactorKindBoxSvc: benefactorKindBoxSvc,
|
||||
benefactorKindBoxVld: benefactorKindBoxVld,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,17 +29,15 @@ func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.benefactorKindBoxVld.ValidateRegisterEmptyingRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
sErr := h.benefactorKindBoxSvc.RegisterEmptyingRequest(c.Request().Context(), req)
|
||||
resp, sErr := h.benefactorKindBoxSvc.RegisterEmptyingRequest(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
r := e.Group("/benefactor/kindboxes")
|
||||
|
||||
r.Use(
|
||||
middleware.Auth(h.authSvc, h.authConfig),
|
||||
middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole),
|
||||
)
|
||||
|
||||
|
|
|
@ -31,17 +31,15 @@ func (h Handler) Add(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateAddRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.benefactorKindBoxReqSvc.Add(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -1,153 +0,0 @@
|
|||
package benefactorkindboxreqhandler_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/middleware"
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param/benefactor/address"
|
||||
benefactoreparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactore"
|
||||
benefactorkindboxreqparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
|
||||
testutils "git.gocasts.ir/ebhomengo/niki/test"
|
||||
"git.gocasts.ir/ebhomengo/niki/test/seed"
|
||||
"github.com/brianvoe/gofakeit/v6"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAdd(t *testing.T) {
|
||||
testutils.SetupEnd2EndTest(t)
|
||||
respSendOTP := testutils.SendOTP(t)
|
||||
|
||||
loginOrRegisterRequest := benefactoreparam.LoginOrRegisterRequest{
|
||||
PhoneNumber: respSendOTP.PhoneNumber,
|
||||
VerificationCode: respSendOTP.Code,
|
||||
}
|
||||
benefactor, cleanupBenefactor := testutils.CreateBenefactorWithSvc(t, loginOrRegisterRequest)
|
||||
defer cleanupBenefactor()
|
||||
benefactorAddAddressRequest := addressparam.BenefactorAddAddressRequest{
|
||||
PostalCode: gofakeit.Address().Zip,
|
||||
Address: gofakeit.Address().Address,
|
||||
Lat: float32(gofakeit.Address().Latitude),
|
||||
Lon: float32(gofakeit.Address().Longitude),
|
||||
CityID: gofakeit.UintRange(1, 100),
|
||||
ProvinceID: gofakeit.UintRange(1, 31),
|
||||
BenefactorID: benefactor.BenefactorInfo.ID,
|
||||
}
|
||||
address, cleanupAddress := testutils.CreateAddressWithSvc(t, benefactorAddAddressRequest)
|
||||
defer cleanupAddress()
|
||||
kindboxreqResponse, _ := json.Marshal(entity.KindBoxReq{
|
||||
ID: 1,
|
||||
KindBoxType: entity.KindBoxCylindrical,
|
||||
CountRequested: gofakeit.UintRange(1, 100),
|
||||
CountAccepted: 0,
|
||||
BenefactorID: benefactor.BenefactorInfo.ID,
|
||||
Status: entity.KindBoxReqPendingStatus,
|
||||
Description: "",
|
||||
ReferDate: time.Time{},
|
||||
AddressID: address.Address.ID,
|
||||
})
|
||||
|
||||
type testCase struct {
|
||||
name string
|
||||
requestBody interface{}
|
||||
expectedStatus int
|
||||
expectedBody string
|
||||
err bool
|
||||
token string
|
||||
}
|
||||
|
||||
testCases := []testCase{
|
||||
{
|
||||
name: "invalid payload",
|
||||
requestBody: `invalid payload`,
|
||||
expectedStatus: http.StatusBadRequest,
|
||||
expectedBody: `{"message": "Bad request"}`,
|
||||
err: true,
|
||||
token: "Bearer " + benefactor.Tokens.AccessToken,
|
||||
},
|
||||
{
|
||||
name: "invalid or expired jwt",
|
||||
requestBody: benefactorkindboxreqparam.KindBoxReqAddRequest{
|
||||
KindBoxType: 1,
|
||||
AddressID: address.Address.ID,
|
||||
ReferDate: time.Now(),
|
||||
CountRequested: 1,
|
||||
},
|
||||
token: "Bearer 12" + benefactor.Tokens.AccessToken,
|
||||
expectedStatus: http.StatusUnauthorized,
|
||||
err: true,
|
||||
expectedBody: `{"message":"invalid or expired jwt"}`,
|
||||
},
|
||||
{
|
||||
name: "Validation Failed",
|
||||
requestBody: benefactorkindboxreqparam.KindBoxReqAddRequest{
|
||||
AddressID: address.Address.ID,
|
||||
ReferDate: time.Now(),
|
||||
CountRequested: 2,
|
||||
},
|
||||
err: true,
|
||||
token: "Bearer " + benefactor.Tokens.AccessToken,
|
||||
expectedStatus: http.StatusUnprocessableEntity,
|
||||
expectedBody: `{
|
||||
"errors":{
|
||||
"kind_box_type":"cannot be blank"
|
||||
},
|
||||
"message":"invalid input"
|
||||
}`,
|
||||
},
|
||||
{
|
||||
name: "Added successfully",
|
||||
requestBody: benefactorkindboxreqparam.KindBoxReqAddRequest{
|
||||
KindBoxType: 2,
|
||||
AddressID: address.Address.ID,
|
||||
ReferDate: time.Now(),
|
||||
CountRequested: 2,
|
||||
},
|
||||
token: "Bearer " + benefactor.Tokens.AccessToken,
|
||||
expectedStatus: http.StatusCreated,
|
||||
expectedBody: string(kindboxreqResponse),
|
||||
},
|
||||
}
|
||||
|
||||
e := echo.New()
|
||||
r := e.Group("/benefactor/kindboxreqs")
|
||||
|
||||
r.POST("/", testutils.BenefactorkindBoxReqHandler.Add, middleware.Auth(testutils.AuthSvc, testutils.AuthConfig),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
requestBody, _ := json.Marshal(tc.requestBody)
|
||||
req := httptest.NewRequest(http.MethodPost, "/benefactor/kindboxreqs/", bytes.NewBuffer(requestBody))
|
||||
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, tc.token)
|
||||
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
e.ServeHTTP(rec, req)
|
||||
|
||||
// Assertion
|
||||
assert.Equal(t, tc.expectedStatus, rec.Code)
|
||||
|
||||
if tc.err {
|
||||
assert.JSONEq(t, tc.expectedBody, rec.Body.String())
|
||||
return
|
||||
}
|
||||
response := &benefactorkindboxreqparam.KindBoxReqAddResponse{}
|
||||
err := json.Unmarshal(
|
||||
rec.Body.Bytes(),
|
||||
response,
|
||||
)
|
||||
assert.Nil(t, err, "error in deserializing the request")
|
||||
seed.DeleteBenefactor(t, testutils.MysqlRepo, response.KindBoxReq.ID)
|
||||
assert.NotEmpty(t, response.KindBoxReq)
|
||||
})
|
||||
}
|
||||
}
|
|
@ -27,17 +27,16 @@ func (h Handler) Delete(c echo.Context) error {
|
|||
}
|
||||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateDeleteRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, dErr := h.benefactorKindBoxReqSvc.Delete(c.Request().Context(), req)
|
||||
if dErr != nil {
|
||||
msg, code := httpmsg.Error(dErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -27,17 +27,15 @@ func (h Handler) Get(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateGetRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
resp, sErr := h.benefactorKindBoxReqSvc.Get(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -41,19 +41,17 @@ func (h Handler) GetAll(c echo.Context) error {
|
|||
}
|
||||
|
||||
req.Filter = queryparam.GetFilterParams(c)
|
||||
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateGetAll(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
req.Filter["benefactor_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
|
||||
resp, sErr := h.benefactorKindBoxReqSvc.GetAll(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -3,23 +3,18 @@ package benefactorkindboxreqhandler
|
|||
import (
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req"
|
||||
benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authConfig authservice.Config
|
||||
authSvc authservice.Service
|
||||
benefactorKindBoxReqSvc benefactorkindboxreqservice.Service
|
||||
benefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator
|
||||
}
|
||||
|
||||
func New(authConfig authservice.Config, authSvc authservice.Service,
|
||||
benefactorKindBoxReqSvc benefactorkindboxreqservice.Service, benefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator,
|
||||
func New(authSvc authservice.Service,
|
||||
benefactorKindBoxReqSvc benefactorkindboxreqservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authConfig: authConfig,
|
||||
authSvc: authSvc,
|
||||
benefactorKindBoxReqSvc: benefactorKindBoxReqSvc,
|
||||
benefactorKindBoxReqVld: benefactorKindBoxReqVld,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
r := e.Group("/benefactor/kindboxreqs")
|
||||
|
||||
r.Use(
|
||||
middleware.Auth(h.authSvc, h.authConfig),
|
||||
middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole),
|
||||
)
|
||||
|
||||
|
|
|
@ -33,18 +33,15 @@ func (h Handler) Update(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.BenefactorID = claims.UserID
|
||||
|
||||
if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateUpdateRequest(req); err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": fieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
sErr := h.benefactorKindBoxReqSvc.Update(c.Request().Context(), req)
|
||||
resp, sErr := h.benefactorKindBoxReqSvc.Update(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
return c.JSON(code, echo.Map{
|
||||
"message": msg,
|
||||
"errors": resp.FieldErrors,
|
||||
})
|
||||
}
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ func AdminAuthorization(service adminauthorizationservice.Service,
|
|||
return func(c echo.Context) (err error) {
|
||||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
|
||||
isAllowed, err := service.CheckAccess(claims.UserID, entity.MapToAdminRole(claims.Role), permissions...)
|
||||
isAllowed, err := service.CheckAccess(c.Request().Context(), claims.UserID, entity.MapToAdminRole(claims.Role), permissions...)
|
||||
if err != nil {
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, errmsg.ErrorMsgSomethingWentWrong)
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func Auth(service authservice.Service, cfg authservice.Config) echo.MiddlewareFunc {
|
||||
func Auth(service authservice.Service) echo.MiddlewareFunc {
|
||||
return mw.WithConfig(mw.Config{
|
||||
ContextKey: config.AuthMiddlewareContextKey,
|
||||
SigningKey: []byte(cfg.SignKey),
|
||||
SigningKey: []byte(service.Config.SignKey),
|
||||
// TODO - as sign method string to config
|
||||
SigningMethod: "HS256",
|
||||
ParseTokenFunc: func(c echo.Context, auth string) (interface{}, error) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin"
|
||||
adminagenthandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/agent"
|
||||
adminKindBoxHandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/kind_box"
|
||||
adminkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/kind_box_req"
|
||||
agentkindboxhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/agent/kind_box"
|
||||
|
@ -13,25 +14,7 @@ import (
|
|||
benefactorkindboxhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/benefactor/kind_box"
|
||||
benefactorkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/benefactor/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/docs"
|
||||
adminservice "git.gocasts.ir/ebhomengo/niki/service/admin/admin"
|
||||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box"
|
||||
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
||||
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
||||
benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box"
|
||||
benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/service/notification"
|
||||
adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin"
|
||||
adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box"
|
||||
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
||||
agentkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box"
|
||||
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
|
||||
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
|
||||
benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box"
|
||||
benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/service"
|
||||
echo "github.com/labstack/echo/v4"
|
||||
middleware "github.com/labstack/echo/v4/middleware"
|
||||
echoSwagger "github.com/swaggo/echo-swagger"
|
||||
|
@ -40,50 +23,33 @@ import (
|
|||
type Server struct {
|
||||
config config.Config
|
||||
Router *echo.Echo
|
||||
adminHandler adminhandler.Handler
|
||||
adminKindBoxReqHandler adminkindboxreqhandler.Handler
|
||||
adminKindBoxHandler adminKindBoxHandler.Handler
|
||||
adminAgentHandler adminagenthandler.Handler
|
||||
agentKindBoxHandler agentkindboxhandler.Handler
|
||||
benefactorHandler benefactorhandler.Handler
|
||||
benefactorKindBoxReqHandler benefactorkindboxreqhandler.Handler
|
||||
benefactorAddressHandler benefactoraddresshandler.Handler
|
||||
benefactorKindBoxHandler benefactorkindboxhandler.Handler
|
||||
adminHandler adminhandler.Handler
|
||||
adminKindBoxReqHandler adminkindboxreqhandler.Handler
|
||||
adminKindBoxHandler adminKindBoxHandler.Handler
|
||||
agentKindBoxHandler agentkindboxhandler.Handler
|
||||
}
|
||||
|
||||
func New(
|
||||
cfg config.Config,
|
||||
benefactorSvc benefactorservice.Service,
|
||||
benefactorVld benefactorvalidator.Validator,
|
||||
benefactorAuthSvc authservice.Service,
|
||||
benefactorKindBoxReqSvc benefactorkindboxreqservice.Service,
|
||||
benefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator,
|
||||
benefactorAddressSvc benefactoraddressservice.Service,
|
||||
benefactorAddressVld benefactoraddressvalidator.Validator,
|
||||
benefactorKindBoxSvc benefactorkindboxservice.Service,
|
||||
benefactorKindBoxVld benefactorkindboxvalidator.Validator,
|
||||
adminSvc adminservice.Service,
|
||||
adminVld adminvalidator.Validator,
|
||||
adminAuthSvc authservice.Service,
|
||||
adminKinBoxReqSvc adminkindboxreqservice.Service,
|
||||
adminKinBoxReqVld adminkindboxreqvalidator.Validator,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
adminKindBoxSvc adminkindboxservice.Service,
|
||||
adminKindBoxVld adminkindboxvalidator.Validator,
|
||||
agentKindBoxSvc agentkindboxservice.Service,
|
||||
agentKindBoxVld agentkindboxvalidator.Validator,
|
||||
notificationSvc notification.Service,
|
||||
) Server {
|
||||
return Server{
|
||||
svc *service.Service,
|
||||
) *Server {
|
||||
return &Server{
|
||||
Router: echo.New(),
|
||||
config: cfg,
|
||||
benefactorHandler: benefactorhandler.New(cfg.Auth, benefactorAuthSvc, benefactorSvc, benefactorVld),
|
||||
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(cfg.Auth, benefactorAuthSvc, benefactorKindBoxReqSvc, benefactorKindBoxReqVld),
|
||||
benefactorAddressHandler: benefactoraddresshandler.New(cfg.Auth, benefactorAuthSvc, benefactorAddressSvc, benefactorAddressVld),
|
||||
benefactorKindBoxHandler: benefactorkindboxhandler.New(cfg.Auth, benefactorAuthSvc, benefactorKindBoxSvc, benefactorKindBoxVld),
|
||||
adminHandler: adminhandler.New(cfg.AdminAuth, adminAuthSvc, adminSvc, adminVld, adminAuthorizeSvc),
|
||||
adminKindBoxReqHandler: adminkindboxreqhandler.New(cfg.Auth, adminAuthSvc, adminKinBoxReqSvc, adminKinBoxReqVld, adminAuthorizeSvc, notificationSvc),
|
||||
adminKindBoxHandler: adminKindBoxHandler.New(cfg.Auth, adminAuthSvc, adminKindBoxSvc, adminKindBoxVld, adminAuthorizeSvc),
|
||||
agentKindBoxHandler: agentkindboxhandler.New(cfg.AdminAuth, adminAuthSvc, agentKindBoxSvc, agentKindBoxVld, adminAuthorizeSvc),
|
||||
adminHandler: adminhandler.New(svc.AdminAuthSvc, svc.AdminSvc, svc.AdminAuthorizeSvc),
|
||||
adminKindBoxReqHandler: adminkindboxreqhandler.New(svc.AdminAuthSvc, svc.AdminKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
adminKindBoxHandler: adminKindBoxHandler.New(svc.AdminAuthSvc, svc.AdminKindBoxSvc, svc.AdminAuthorizeSvc),
|
||||
adminAgentHandler: adminagenthandler.New(svc.AdminAuthSvc, svc.AdminAgentSvc, svc.AdminAuthorizeSvc),
|
||||
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc),
|
||||
benefactorHandler: benefactorhandler.New(svc.BenefactorAuthSvc, svc.BenefactorSvc),
|
||||
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxReqSvc),
|
||||
benefactorAddressHandler: benefactoraddresshandler.New(svc.BenefactorAuthSvc, svc.BenefactorAddressSvc),
|
||||
benefactorKindBoxHandler: benefactorkindboxhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxSvc),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
353
docs/docs.go
353
docs/docs.go
|
@ -810,11 +810,11 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -1119,7 +1119,7 @@ const docTemplate = `{
|
|||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/adminserviceparam.GetAllAgentResponse"
|
||||
"$ref": "#/definitions/adminagentparam.GetAllAgentResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
|
@ -1170,11 +1170,11 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -1182,13 +1182,13 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"pending",
|
||||
"accepted",
|
||||
"assigned-sender-agent",
|
||||
"rejected",
|
||||
"delivered"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBoxReq status",
|
||||
"name": "filter_status",
|
||||
|
@ -1496,11 +1496,11 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_type",
|
||||
|
@ -2075,11 +2075,11 @@ const docTemplate = `{
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -2495,6 +2495,12 @@ const docTemplate = `{
|
|||
"properties": {
|
||||
"address": {
|
||||
"$ref": "#/definitions/entity.Address"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2503,6 +2509,12 @@ const docTemplate = `{
|
|||
"properties": {
|
||||
"address": {
|
||||
"$ref": "#/definitions/entity.Address"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2568,6 +2580,38 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"adminagentparam.Agent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first_name": {
|
||||
"type": "string",
|
||||
"example": "John"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
"example": "Doe"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09123456789"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminagentparam.GetAllAgentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/adminagentparam.Agent"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxparam.AssignReceiverRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -2593,6 +2637,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2619,6 +2669,12 @@ const docTemplate = `{
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2663,7 +2719,15 @@ const docTemplate = `{
|
|||
}
|
||||
},
|
||||
"adminkindboxreqparam.AssignSenderResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliverKindBoxReqRequest": {
|
||||
"type": "object",
|
||||
|
@ -2682,7 +2746,15 @@ const docTemplate = `{
|
|||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliverKindBoxReqResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
||||
"type": "object",
|
||||
|
@ -2693,6 +2765,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2725,6 +2803,12 @@ const docTemplate = `{
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2766,6 +2850,12 @@ const docTemplate = `{
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2803,6 +2893,12 @@ const docTemplate = `{
|
|||
"deliver_refer_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2836,13 +2932,19 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.KindBoxReqAddResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kindBoxReq": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
|
@ -2857,6 +2959,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2894,6 +3002,12 @@ const docTemplate = `{
|
|||
"type": "string",
|
||||
"example": "description"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
|
@ -2904,7 +3018,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
},
|
||||
"status": {
|
||||
"allOf": [
|
||||
|
@ -2912,7 +3026,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxReqStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "pending"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2949,7 +3063,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 2
|
||||
"example": "cylindrical"
|
||||
},
|
||||
"sender_agent_id": {
|
||||
"type": "integer",
|
||||
|
@ -2978,7 +3092,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.Gender"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "male"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
|
@ -3006,39 +3120,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.AdminStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminserviceparam.Agent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first_name": {
|
||||
"type": "string",
|
||||
"example": "John"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
"example": "Doe"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09123456789"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminserviceparam.GetAllAgentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/adminserviceparam.Agent"
|
||||
}
|
||||
"example": "active"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3061,6 +3143,12 @@ const docTemplate = `{
|
|||
"admin_info": {
|
||||
"$ref": "#/definitions/adminserviceparam.AdminInfo"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tokens": {
|
||||
"$ref": "#/definitions/adminserviceparam.Tokens"
|
||||
}
|
||||
|
@ -3087,7 +3175,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.Gender"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "male"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
|
@ -3115,7 +3203,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.AdminStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "active"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3124,6 +3212,12 @@ const docTemplate = `{
|
|||
"properties": {
|
||||
"admin": {
|
||||
"$ref": "#/definitions/entity.Admin"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3147,6 +3241,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3173,6 +3273,12 @@ const docTemplate = `{
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -3232,7 +3338,11 @@ const docTemplate = `{
|
|||
"example": "rez"
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/entity.UserRole"
|
||||
}
|
||||
],
|
||||
"example": "benefactor"
|
||||
}
|
||||
}
|
||||
|
@ -3256,6 +3366,12 @@ const docTemplate = `{
|
|||
"benefactore_info": {
|
||||
"$ref": "#/definitions/benefactoreparam.BenefactroInfo"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tokens": {
|
||||
"$ref": "#/definitions/benefactoreparam.Tokens"
|
||||
}
|
||||
|
@ -3277,6 +3393,12 @@ const docTemplate = `{
|
|||
"description": "this just use in test .env\n\t\tTODO - remove it after test",
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09198829528"
|
||||
|
@ -3303,6 +3425,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3329,6 +3457,12 @@ const docTemplate = `{
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -3390,6 +3524,12 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3424,24 +3564,44 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqAddResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqDeleteResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqGetResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
|
@ -3476,7 +3636,7 @@ const docTemplate = `{
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 2
|
||||
"example": "cylindrical"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3561,10 +3721,10 @@ const docTemplate = `{
|
|||
]
|
||||
},
|
||||
"entity.AdminStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2
|
||||
"active",
|
||||
"inactive"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"AdminActiveStatus",
|
||||
|
@ -3586,10 +3746,10 @@ const docTemplate = `{
|
|||
}
|
||||
},
|
||||
"entity.Gender": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2
|
||||
"male",
|
||||
"female"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"MaleGender",
|
||||
|
@ -3694,13 +3854,13 @@ const docTemplate = `{
|
|||
}
|
||||
},
|
||||
"entity.KindBoxReqStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"pending",
|
||||
"accepted",
|
||||
"assigned-sender-agent",
|
||||
"rejected",
|
||||
"delivered"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxReqPendingStatus",
|
||||
|
@ -3711,13 +3871,13 @@ const docTemplate = `{
|
|||
]
|
||||
},
|
||||
"entity.KindBoxStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"delivered",
|
||||
"ready-to-return",
|
||||
"assigned-receiver-agent",
|
||||
"returned",
|
||||
"enumerated"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxDeliveredStatus",
|
||||
|
@ -3728,11 +3888,11 @@ const docTemplate = `{
|
|||
]
|
||||
},
|
||||
"entity.KindBoxType": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxOnTable",
|
||||
|
@ -3751,6 +3911,15 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"entity.UserRole": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"benefactor"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"UserBenefactorRole"
|
||||
]
|
||||
},
|
||||
"httpmsg.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -3785,7 +3954,7 @@ const docTemplate = `{
|
|||
},
|
||||
"securityDefinitions": {
|
||||
"AuthBearerAdmin": {
|
||||
"description": "Type the word 'Bearer' followed by a space and Admin JWT token",
|
||||
"description": "Type the word 'Bearer' followed by a space and Admin JWT token.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
|
|
|
@ -799,11 +799,11 @@
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -1108,7 +1108,7 @@
|
|||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/adminserviceparam.GetAllAgentResponse"
|
||||
"$ref": "#/definitions/adminagentparam.GetAllAgentResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
|
@ -1159,11 +1159,11 @@
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -1171,13 +1171,13 @@
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"pending",
|
||||
"accepted",
|
||||
"assigned-sender-agent",
|
||||
"rejected",
|
||||
"delivered"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBoxReq status",
|
||||
"name": "filter_status",
|
||||
|
@ -1485,11 +1485,11 @@
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_type",
|
||||
|
@ -2064,11 +2064,11 @@
|
|||
},
|
||||
{
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"format": "enum",
|
||||
"description": "Filter by KindBox type",
|
||||
"name": "filter_kind_box_type",
|
||||
|
@ -2484,6 +2484,12 @@
|
|||
"properties": {
|
||||
"address": {
|
||||
"$ref": "#/definitions/entity.Address"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2492,6 +2498,12 @@
|
|||
"properties": {
|
||||
"address": {
|
||||
"$ref": "#/definitions/entity.Address"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2557,6 +2569,38 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"adminagentparam.Agent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first_name": {
|
||||
"type": "string",
|
||||
"example": "John"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
"example": "Doe"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09123456789"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminagentparam.GetAllAgentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/adminagentparam.Agent"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxparam.AssignReceiverRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -2582,6 +2626,12 @@
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2608,6 +2658,12 @@
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2652,7 +2708,15 @@
|
|||
}
|
||||
},
|
||||
"adminkindboxreqparam.AssignSenderResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliverKindBoxReqRequest": {
|
||||
"type": "object",
|
||||
|
@ -2671,7 +2735,15 @@
|
|||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliverKindBoxReqResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.DeliveryAwaitingGetAllResponse": {
|
||||
"type": "object",
|
||||
|
@ -2682,6 +2754,12 @@
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2714,6 +2792,12 @@
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2755,6 +2839,12 @@
|
|||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2792,6 +2882,12 @@
|
|||
"deliver_refer_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -2825,13 +2921,19 @@
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxreqparam.KindBoxReqAddResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kindBoxReq": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
|
@ -2846,6 +2948,12 @@
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -2883,6 +2991,12 @@
|
|||
"type": "string",
|
||||
"example": "description"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
|
@ -2893,7 +3007,7 @@
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
},
|
||||
"status": {
|
||||
"allOf": [
|
||||
|
@ -2901,7 +3015,7 @@
|
|||
"$ref": "#/definitions/entity.KindBoxReqStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "pending"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -2938,7 +3052,7 @@
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 2
|
||||
"example": "cylindrical"
|
||||
},
|
||||
"sender_agent_id": {
|
||||
"type": "integer",
|
||||
|
@ -2967,7 +3081,7 @@
|
|||
"$ref": "#/definitions/entity.Gender"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "male"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
|
@ -2995,39 +3109,7 @@
|
|||
"$ref": "#/definitions/entity.AdminStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminserviceparam.Agent": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first_name": {
|
||||
"type": "string",
|
||||
"example": "John"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"example": 1
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
"example": "Doe"
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09123456789"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminserviceparam.GetAllAgentResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"agents": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/adminserviceparam.Agent"
|
||||
}
|
||||
"example": "active"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3050,6 +3132,12 @@
|
|||
"admin_info": {
|
||||
"$ref": "#/definitions/adminserviceparam.AdminInfo"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tokens": {
|
||||
"$ref": "#/definitions/adminserviceparam.Tokens"
|
||||
}
|
||||
|
@ -3076,7 +3164,7 @@
|
|||
"$ref": "#/definitions/entity.Gender"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "male"
|
||||
},
|
||||
"last_name": {
|
||||
"type": "string",
|
||||
|
@ -3104,7 +3192,7 @@
|
|||
"$ref": "#/definitions/entity.AdminStatus"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "active"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3113,6 +3201,12 @@
|
|||
"properties": {
|
||||
"admin": {
|
||||
"$ref": "#/definitions/entity.Admin"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3136,6 +3230,12 @@
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3162,6 +3262,12 @@
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -3221,7 +3327,11 @@
|
|||
"example": "rez"
|
||||
},
|
||||
"role": {
|
||||
"type": "string",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/entity.UserRole"
|
||||
}
|
||||
],
|
||||
"example": "benefactor"
|
||||
}
|
||||
}
|
||||
|
@ -3245,6 +3355,12 @@
|
|||
"benefactore_info": {
|
||||
"$ref": "#/definitions/benefactoreparam.BenefactroInfo"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"tokens": {
|
||||
"$ref": "#/definitions/benefactoreparam.Tokens"
|
||||
}
|
||||
|
@ -3266,6 +3382,12 @@
|
|||
"description": "this just use in test .env\n\t\tTODO - remove it after test",
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"phone_number": {
|
||||
"type": "string",
|
||||
"example": "09198829528"
|
||||
|
@ -3292,6 +3414,12 @@
|
|||
"$ref": "#/definitions/entity.KindBox"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3318,6 +3446,12 @@
|
|||
"deliveredAt": {
|
||||
"type": "string"
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -3379,6 +3513,12 @@
|
|||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
},
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"pagination": {
|
||||
"$ref": "#/definitions/param.PaginationResponse"
|
||||
}
|
||||
|
@ -3413,24 +3553,44 @@
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 1
|
||||
"example": "on-table"
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqAddResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqDeleteResponse": {
|
||||
"type": "object"
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"benefactorkindboxreqparam.KindBoxReqGetResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fieldErrors": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"kind_box_req": {
|
||||
"$ref": "#/definitions/entity.KindBoxReq"
|
||||
}
|
||||
|
@ -3465,7 +3625,7 @@
|
|||
"$ref": "#/definitions/entity.KindBoxType"
|
||||
}
|
||||
],
|
||||
"example": 2
|
||||
"example": "cylindrical"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3550,10 +3710,10 @@
|
|||
]
|
||||
},
|
||||
"entity.AdminStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2
|
||||
"active",
|
||||
"inactive"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"AdminActiveStatus",
|
||||
|
@ -3575,10 +3735,10 @@
|
|||
}
|
||||
},
|
||||
"entity.Gender": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2
|
||||
"male",
|
||||
"female"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"MaleGender",
|
||||
|
@ -3683,13 +3843,13 @@
|
|||
}
|
||||
},
|
||||
"entity.KindBoxReqStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"pending",
|
||||
"accepted",
|
||||
"assigned-sender-agent",
|
||||
"rejected",
|
||||
"delivered"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxReqPendingStatus",
|
||||
|
@ -3700,13 +3860,13 @@
|
|||
]
|
||||
},
|
||||
"entity.KindBoxStatus": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
"delivered",
|
||||
"ready-to-return",
|
||||
"assigned-receiver-agent",
|
||||
"returned",
|
||||
"enumerated"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxDeliveredStatus",
|
||||
|
@ -3717,11 +3877,11 @@
|
|||
]
|
||||
},
|
||||
"entity.KindBoxType": {
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
1,
|
||||
2,
|
||||
3
|
||||
"on-table",
|
||||
"cylindrical",
|
||||
"stand-up"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"KindBoxOnTable",
|
||||
|
@ -3740,6 +3900,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"entity.UserRole": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"benefactor"
|
||||
],
|
||||
"x-enum-varnames": [
|
||||
"UserBenefactorRole"
|
||||
]
|
||||
},
|
||||
"httpmsg.ErrorResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -3774,7 +3943,7 @@
|
|||
},
|
||||
"securityDefinitions": {
|
||||
"AuthBearerAdmin": {
|
||||
"description": "Type the word 'Bearer' followed by a space and Admin JWT token",
|
||||
"description": "Type the word 'Bearer' followed by a space and Admin JWT token.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
|
|
|
@ -24,11 +24,19 @@ definitions:
|
|||
properties:
|
||||
address:
|
||||
$ref: '#/definitions/entity.Address'
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
addressparam.GetAddressResponse:
|
||||
properties:
|
||||
address:
|
||||
$ref: '#/definitions/entity.Address'
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
addressparam.GetAllAddressesResponse:
|
||||
properties:
|
||||
|
@ -72,6 +80,28 @@ definitions:
|
|||
example: "1234567890"
|
||||
type: string
|
||||
type: object
|
||||
adminagentparam.Agent:
|
||||
properties:
|
||||
first_name:
|
||||
example: John
|
||||
type: string
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
last_name:
|
||||
example: Doe
|
||||
type: string
|
||||
phone_number:
|
||||
example: "09123456789"
|
||||
type: string
|
||||
type: object
|
||||
adminagentparam.GetAllAgentResponse:
|
||||
properties:
|
||||
agents:
|
||||
items:
|
||||
$ref: '#/definitions/adminagentparam.Agent'
|
||||
type: array
|
||||
type: object
|
||||
adminkindboxparam.AssignReceiverRequest:
|
||||
properties:
|
||||
receiver_agent_id:
|
||||
|
@ -88,6 +118,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBox'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -105,6 +139,10 @@ definitions:
|
|||
type: integer
|
||||
deliveredAt:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
type: integer
|
||||
kindBoxReqID:
|
||||
|
@ -134,6 +172,11 @@ definitions:
|
|||
type: integer
|
||||
type: object
|
||||
adminkindboxreqparam.AssignSenderResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
adminkindboxreqparam.DeliverKindBoxReqRequest:
|
||||
properties:
|
||||
|
@ -147,6 +190,11 @@ definitions:
|
|||
type: array
|
||||
type: object
|
||||
adminkindboxreqparam.DeliverKindBoxReqResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
adminkindboxreqparam.DeliveryAwaitingGetAllResponse:
|
||||
properties:
|
||||
|
@ -154,6 +202,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -175,6 +227,10 @@ definitions:
|
|||
type: string
|
||||
description:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
type: integer
|
||||
kindBoxType:
|
||||
|
@ -202,6 +258,10 @@ definitions:
|
|||
type: string
|
||||
description:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
type: integer
|
||||
kindBoxType:
|
||||
|
@ -226,6 +286,10 @@ definitions:
|
|||
type: integer
|
||||
deliver_refer_date:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
kind_box_req_id:
|
||||
type: integer
|
||||
kind_box_req_status:
|
||||
|
@ -248,10 +312,14 @@ definitions:
|
|||
kind_box_type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxType'
|
||||
example: 1
|
||||
example: on-table
|
||||
type: object
|
||||
adminkindboxreqparam.KindBoxReqAddResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
kindBoxReq:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: object
|
||||
|
@ -261,6 +329,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -287,17 +359,21 @@ definitions:
|
|||
description:
|
||||
example: description
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
kind_box_type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxType'
|
||||
example: 1
|
||||
example: on-table
|
||||
status:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxReqStatus'
|
||||
example: 1
|
||||
example: pending
|
||||
type: object
|
||||
adminkindboxreqparam.KindBoxReqUpdateRequest:
|
||||
properties:
|
||||
|
@ -322,7 +398,7 @@ definitions:
|
|||
kind_box_type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxType'
|
||||
example: 2
|
||||
example: cylindrical
|
||||
sender_agent_id:
|
||||
example: 1
|
||||
type: integer
|
||||
|
@ -341,7 +417,7 @@ definitions:
|
|||
gender:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.Gender'
|
||||
example: 1
|
||||
example: male
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
|
@ -358,29 +434,7 @@ definitions:
|
|||
status:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.AdminStatus'
|
||||
example: 1
|
||||
type: object
|
||||
adminserviceparam.Agent:
|
||||
properties:
|
||||
first_name:
|
||||
example: John
|
||||
type: string
|
||||
id:
|
||||
example: 1
|
||||
type: integer
|
||||
last_name:
|
||||
example: Doe
|
||||
type: string
|
||||
phone_number:
|
||||
example: "09123456789"
|
||||
type: string
|
||||
type: object
|
||||
adminserviceparam.GetAllAgentResponse:
|
||||
properties:
|
||||
agents:
|
||||
items:
|
||||
$ref: '#/definitions/adminserviceparam.Agent'
|
||||
type: array
|
||||
example: active
|
||||
type: object
|
||||
adminserviceparam.LoginWithPhoneNumberRequest:
|
||||
properties:
|
||||
|
@ -395,6 +449,10 @@ definitions:
|
|||
properties:
|
||||
admin_info:
|
||||
$ref: '#/definitions/adminserviceparam.AdminInfo'
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
tokens:
|
||||
$ref: '#/definitions/adminserviceparam.Tokens'
|
||||
type: object
|
||||
|
@ -412,7 +470,7 @@ definitions:
|
|||
gender:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.Gender'
|
||||
example: 1
|
||||
example: male
|
||||
last_name:
|
||||
example: shahi
|
||||
type: string
|
||||
|
@ -429,12 +487,16 @@ definitions:
|
|||
status:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.AdminStatus'
|
||||
example: 1
|
||||
example: active
|
||||
type: object
|
||||
adminserviceparam.RegisterResponse:
|
||||
properties:
|
||||
admin:
|
||||
$ref: '#/definitions/entity.Admin'
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
adminserviceparam.Tokens:
|
||||
properties:
|
||||
|
@ -449,6 +511,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBox'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -466,6 +532,10 @@ definitions:
|
|||
type: integer
|
||||
deliveredAt:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
type: integer
|
||||
kindBoxReqID:
|
||||
|
@ -506,8 +576,9 @@ definitions:
|
|||
example: rez
|
||||
type: string
|
||||
role:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.UserRole'
|
||||
example: benefactor
|
||||
type: string
|
||||
type: object
|
||||
benefactoreparam.LoginOrRegisterRequest:
|
||||
properties:
|
||||
|
@ -522,6 +593,10 @@ definitions:
|
|||
properties:
|
||||
benefactore_info:
|
||||
$ref: '#/definitions/benefactoreparam.BenefactroInfo'
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
tokens:
|
||||
$ref: '#/definitions/benefactoreparam.Tokens'
|
||||
type: object
|
||||
|
@ -536,6 +611,10 @@ definitions:
|
|||
code:
|
||||
description: "this just use in test .env\n\t\tTODO - remove it after test"
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
phone_number:
|
||||
example: "09198829528"
|
||||
type: string
|
||||
|
@ -553,6 +632,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBox'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -570,6 +653,10 @@ definitions:
|
|||
type: integer
|
||||
deliveredAt:
|
||||
type: string
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
id:
|
||||
type: integer
|
||||
kindBoxReqID:
|
||||
|
@ -611,6 +698,10 @@ definitions:
|
|||
items:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: array
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
pagination:
|
||||
$ref: '#/definitions/param.PaginationResponse'
|
||||
type: object
|
||||
|
@ -634,17 +725,30 @@ definitions:
|
|||
kind_box_type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxType'
|
||||
example: 1
|
||||
example: on-table
|
||||
type: object
|
||||
benefactorkindboxreqparam.KindBoxReqAddResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
kind_box_req:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: object
|
||||
benefactorkindboxreqparam.KindBoxReqDeleteResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
benefactorkindboxreqparam.KindBoxReqGetResponse:
|
||||
properties:
|
||||
fieldErrors:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
kind_box_req:
|
||||
$ref: '#/definitions/entity.KindBoxReq'
|
||||
type: object
|
||||
|
@ -668,7 +772,7 @@ definitions:
|
|||
kind_box_type:
|
||||
allOf:
|
||||
- $ref: '#/definitions/entity.KindBoxType'
|
||||
example: 2
|
||||
example: cylindrical
|
||||
type: object
|
||||
entity.Address:
|
||||
properties:
|
||||
|
@ -726,9 +830,9 @@ definitions:
|
|||
- AdminAgentRole
|
||||
entity.AdminStatus:
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
type: integer
|
||||
- active
|
||||
- inactive
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- AdminActiveStatus
|
||||
- AdminInactiveStatus
|
||||
|
@ -743,9 +847,9 @@ definitions:
|
|||
type: object
|
||||
entity.Gender:
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
type: integer
|
||||
- male
|
||||
- female
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- MaleGender
|
||||
- FemaleGender
|
||||
|
@ -815,12 +919,12 @@ definitions:
|
|||
type: object
|
||||
entity.KindBoxReqStatus:
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
- 5
|
||||
type: integer
|
||||
- pending
|
||||
- accepted
|
||||
- assigned-sender-agent
|
||||
- rejected
|
||||
- delivered
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- KindBoxReqPendingStatus
|
||||
- KindBoxReqAcceptedStatus
|
||||
|
@ -829,12 +933,12 @@ definitions:
|
|||
- KindBoxReqDeliveredStatus
|
||||
entity.KindBoxStatus:
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
- 5
|
||||
type: integer
|
||||
- delivered
|
||||
- ready-to-return
|
||||
- assigned-receiver-agent
|
||||
- returned
|
||||
- enumerated
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- KindBoxDeliveredStatus
|
||||
- KindBoxReadyToReturnStatus
|
||||
|
@ -843,10 +947,10 @@ definitions:
|
|||
- KindBoxEnumeratedStatus
|
||||
entity.KindBoxType:
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
type: integer
|
||||
- on-table
|
||||
- cylindrical
|
||||
- stand-up
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- KindBoxOnTable
|
||||
- KindBoxCylindrical
|
||||
|
@ -858,6 +962,12 @@ definitions:
|
|||
name:
|
||||
type: string
|
||||
type: object
|
||||
entity.UserRole:
|
||||
enum:
|
||||
- benefactor
|
||||
type: string
|
||||
x-enum-varnames:
|
||||
- UserBenefactorRole
|
||||
httpmsg.ErrorResponse:
|
||||
properties:
|
||||
errors:
|
||||
|
@ -1424,13 +1534,13 @@ paths:
|
|||
type: integer
|
||||
- description: Filter by KindBox type
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- on-table
|
||||
- cylindrical
|
||||
- stand-up
|
||||
format: enum
|
||||
in: query
|
||||
name: filter_kind_box_type
|
||||
type: integer
|
||||
type: string
|
||||
- description: Filter by count requested
|
||||
in: query
|
||||
name: filter_count_requested
|
||||
|
@ -1596,7 +1706,7 @@ paths:
|
|||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/adminserviceparam.GetAllAgentResponse'
|
||||
$ref: '#/definitions/adminagentparam.GetAllAgentResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
|
@ -1627,24 +1737,24 @@ paths:
|
|||
type: integer
|
||||
- description: Filter by KindBox type
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- on-table
|
||||
- cylindrical
|
||||
- stand-up
|
||||
format: enum
|
||||
in: query
|
||||
name: filter_kind_box_type
|
||||
type: integer
|
||||
type: string
|
||||
- description: Filter by KindBoxReq status
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 4
|
||||
- 5
|
||||
- pending
|
||||
- accepted
|
||||
- assigned-sender-agent
|
||||
- rejected
|
||||
- delivered
|
||||
format: enum
|
||||
in: query
|
||||
name: filter_status
|
||||
type: integer
|
||||
type: string
|
||||
- description: Filter by count requested
|
||||
in: query
|
||||
name: filter_count_requested
|
||||
|
@ -1845,13 +1955,13 @@ paths:
|
|||
type: integer
|
||||
- description: Filter by KindBox type
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- on-table
|
||||
- cylindrical
|
||||
- stand-up
|
||||
format: enum
|
||||
in: query
|
||||
name: filter_type
|
||||
type: integer
|
||||
type: string
|
||||
- description: Filter by serial number
|
||||
in: query
|
||||
name: filter_serial_number
|
||||
|
@ -2235,13 +2345,13 @@ paths:
|
|||
type: integer
|
||||
- description: Filter by KindBox type
|
||||
enum:
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- on-table
|
||||
- cylindrical
|
||||
- stand-up
|
||||
format: enum
|
||||
in: query
|
||||
name: filter_kind_box_type
|
||||
type: integer
|
||||
type: string
|
||||
- description: Filter by KindBoxReq Status
|
||||
enum:
|
||||
- pending
|
||||
|
@ -2497,7 +2607,7 @@ paths:
|
|||
- Benefactor
|
||||
securityDefinitions:
|
||||
AuthBearerAdmin:
|
||||
description: Type the word 'Bearer' followed by a space and Admin JWT token
|
||||
description: Type the word 'Bearer' followed by a space and Admin JWT token.
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
|
|
|
@ -22,16 +22,6 @@ func (s AdminRole) IsValid() bool {
|
|||
return s > 0 && int(s) <= len(AdminRoleStrings)
|
||||
}
|
||||
|
||||
// AllAdminRole returns a slice containing all string values of AdminRole.
|
||||
func AllAdminRole() []string {
|
||||
roleStrings := make([]string, len(AdminRoleStrings))
|
||||
for role, str := range AdminRoleStrings {
|
||||
roleStrings[int(role)-1] = str
|
||||
}
|
||||
|
||||
return roleStrings
|
||||
}
|
||||
|
||||
// MapToAdminRole converts a string to the corresponding AdminRole value.
|
||||
func MapToAdminRole(roleStr string) AdminRole {
|
||||
for role, str := range AdminRoleStrings {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package entity
|
||||
|
||||
type AdminStatus uint
|
||||
type AdminStatus string
|
||||
|
||||
const (
|
||||
AdminActiveStatus AdminStatus = iota + 1
|
||||
AdminInactiveStatus
|
||||
AdminActiveStatus = AdminStatus("active")
|
||||
AdminInactiveStatus = AdminStatus("inactive")
|
||||
)
|
||||
|
||||
var AdminStatusStrings = map[AdminStatus]string{
|
||||
|
@ -12,31 +12,8 @@ var AdminStatusStrings = map[AdminStatus]string{
|
|||
AdminInactiveStatus: "inactive",
|
||||
}
|
||||
|
||||
func (s AdminStatus) String() string {
|
||||
return AdminStatusStrings[s]
|
||||
}
|
||||
func (a AdminStatus) IsValid() bool {
|
||||
_, ok := AdminStatusStrings[a]
|
||||
|
||||
func (s AdminStatus) IsValid() bool {
|
||||
return s > 0 && int(s) <= len(AdminStatusStrings)
|
||||
}
|
||||
|
||||
// AllAdminStatus returns a slice containing all string values of AdminStatus.
|
||||
func AllAdminStatus() []string {
|
||||
statusStrings := make([]string, len(AdminStatusStrings))
|
||||
for status, str := range AdminStatusStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
// MapToAdminStatus converts a string to the corresponding AdminStatus value.
|
||||
func MapToAdminStatus(statusStr string) AdminStatus {
|
||||
for status, str := range AdminStatusStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return AdminStatus(0)
|
||||
return ok
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package entity
|
||||
|
||||
type Gender uint
|
||||
type Gender string
|
||||
|
||||
const (
|
||||
MaleGender Gender = iota + 1
|
||||
FemaleGender
|
||||
MaleGender = Gender("male")
|
||||
FemaleGender = Gender("female")
|
||||
)
|
||||
|
||||
var GenderStrings = map[Gender]string{
|
||||
|
@ -12,31 +12,8 @@ var GenderStrings = map[Gender]string{
|
|||
FemaleGender: "female",
|
||||
}
|
||||
|
||||
func (s Gender) String() string {
|
||||
return GenderStrings[s]
|
||||
}
|
||||
func (g Gender) IsValid() bool {
|
||||
_, ok := GenderStrings[g]
|
||||
|
||||
// AllGender returns a slice containing all string values of Gender.
|
||||
func AllGender() []string {
|
||||
statusStrings := make([]string, len(GenderStrings))
|
||||
for status, str := range GenderStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
func (s Gender) IsValid() bool {
|
||||
return s > 0 && int(s) <= len(GenderStrings)
|
||||
}
|
||||
|
||||
// MapToGender converts a string to the corresponding Gender value.
|
||||
func MapToGender(statusStr string) Gender {
|
||||
for status, str := range GenderStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return Gender(0)
|
||||
return ok
|
||||
}
|
||||
|
|
|
@ -1,44 +1,11 @@
|
|||
package entity
|
||||
|
||||
type KindBoxReqStatus uint
|
||||
type KindBoxReqStatus string
|
||||
|
||||
const (
|
||||
KindBoxReqPendingStatus KindBoxReqStatus = iota + 1
|
||||
KindBoxReqAcceptedStatus
|
||||
KindBoxReqAssignedSenderAgentStatus
|
||||
KindBoxReqRejectedStatus
|
||||
KindBoxReqDeliveredStatus
|
||||
KindBoxReqPendingStatus = KindBoxReqStatus("pending")
|
||||
KindBoxReqAcceptedStatus = KindBoxReqStatus("accepted")
|
||||
KindBoxReqAssignedSenderAgentStatus = KindBoxReqStatus("assigned-sender-agent")
|
||||
KindBoxReqRejectedStatus = KindBoxReqStatus("rejected")
|
||||
KindBoxReqDeliveredStatus = KindBoxReqStatus("delivered")
|
||||
)
|
||||
|
||||
var kindBoxReqStatusStrings = map[KindBoxReqStatus]string{
|
||||
KindBoxReqPendingStatus: "pending",
|
||||
KindBoxReqAcceptedStatus: "accepted",
|
||||
KindBoxReqAssignedSenderAgentStatus: "assigned-sender-agent",
|
||||
KindBoxReqRejectedStatus: "rejected",
|
||||
KindBoxReqDeliveredStatus: "delivered",
|
||||
}
|
||||
|
||||
func (s KindBoxReqStatus) String() string {
|
||||
return kindBoxReqStatusStrings[s]
|
||||
}
|
||||
|
||||
// AllKindBoxReqStatus returns a slice containing all string values of KindBoxReqStatus.
|
||||
func AllKindBoxReqStatus() []string {
|
||||
statusStrings := make([]string, len(kindBoxStatusStrings))
|
||||
for status, str := range kindBoxReqStatusStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
// MapToKindBoxReqStatus converts a string to the corresponding KindBoxReqStatus value.
|
||||
func MapToKindBoxReqStatus(statusStr string) KindBoxReqStatus {
|
||||
for status, str := range kindBoxReqStatusStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return KindBoxReqStatus(0)
|
||||
}
|
||||
|
|
|
@ -1,44 +1,11 @@
|
|||
package entity
|
||||
|
||||
type KindBoxStatus uint
|
||||
type KindBoxStatus string
|
||||
|
||||
const (
|
||||
KindBoxDeliveredStatus KindBoxStatus = iota + 1
|
||||
KindBoxReadyToReturnStatus
|
||||
KindBoxAssignedReceiverAgentStatus
|
||||
KindBoxReturnedStatus
|
||||
KindBoxEnumeratedStatus
|
||||
KindBoxDeliveredStatus = KindBoxStatus("delivered")
|
||||
KindBoxReadyToReturnStatus = KindBoxStatus("ready-to-return")
|
||||
KindBoxAssignedReceiverAgentStatus = KindBoxStatus("assigned-receiver-agent")
|
||||
KindBoxReturnedStatus = KindBoxStatus("returned")
|
||||
KindBoxEnumeratedStatus = KindBoxStatus("enumerated")
|
||||
)
|
||||
|
||||
var kindBoxStatusStrings = map[KindBoxStatus]string{
|
||||
KindBoxDeliveredStatus: "delivered",
|
||||
KindBoxReadyToReturnStatus: "ready-to-return",
|
||||
KindBoxAssignedReceiverAgentStatus: "assigned-receiver-agent",
|
||||
KindBoxReturnedStatus: "returned",
|
||||
KindBoxEnumeratedStatus: "enumerated",
|
||||
}
|
||||
|
||||
func (s KindBoxStatus) String() string {
|
||||
return kindBoxStatusStrings[s]
|
||||
}
|
||||
|
||||
// AllKindBoxStatus returns a slice containing all string values of KindBoxStatus.
|
||||
func AllKindBoxStatus() []string {
|
||||
statusStrings := make([]string, len(kindBoxStatusStrings))
|
||||
for status, str := range kindBoxStatusStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
// MapToKindBoxStatus converts a string to the corresponding KindBoxStatus value.
|
||||
func MapToKindBoxStatus(statusStr string) KindBoxStatus {
|
||||
for status, str := range kindBoxStatusStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return KindBoxStatus(0)
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package entity
|
||||
|
||||
type KindBoxType uint
|
||||
type KindBoxType string
|
||||
|
||||
const (
|
||||
KindBoxOnTable KindBoxType = iota + 1
|
||||
KindBoxCylindrical
|
||||
KindBoxStandUp
|
||||
KindBoxOnTable = KindBoxType("on-table")
|
||||
KindBoxCylindrical = KindBoxType("cylindrical")
|
||||
KindBoxStandUp = KindBoxType("stand-up")
|
||||
)
|
||||
|
||||
var KindBoxTypeStrings = map[KindBoxType]string{
|
||||
|
@ -14,31 +14,8 @@ var KindBoxTypeStrings = map[KindBoxType]string{
|
|||
KindBoxStandUp: "stand-up",
|
||||
}
|
||||
|
||||
func (s KindBoxType) String() string {
|
||||
return KindBoxTypeStrings[s]
|
||||
}
|
||||
|
||||
func (s KindBoxType) IsValid() bool {
|
||||
return s > 0 && int(s) <= len(KindBoxTypeStrings)
|
||||
}
|
||||
_, ok := KindBoxTypeStrings[s]
|
||||
|
||||
// AllKindBoxType returns a slice containing all string values of KindBoxType.
|
||||
func AllKindBoxType() []string {
|
||||
statusStrings := make([]string, len(KindBoxTypeStrings))
|
||||
for status, str := range KindBoxTypeStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
// MapToKindBoxType converts a string to the corresponding KindBoxType value.
|
||||
func MapToKindBoxType(statusStr string) KindBoxType {
|
||||
for status, str := range KindBoxTypeStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return KindBoxType(0)
|
||||
return ok
|
||||
}
|
||||
|
|
|
@ -1,42 +1,13 @@
|
|||
package entity
|
||||
|
||||
type ReferTimeStatus uint
|
||||
type ReferTimeStatus string
|
||||
|
||||
const (
|
||||
ReferTimeActiveStatus ReferTimeStatus = iota + 1
|
||||
ReferTimeInactiveStatus
|
||||
ReferTimeActiveStatus = ReferTimeStatus("active")
|
||||
ReferTimeInactiveStatus = ReferTimeStatus("inactive")
|
||||
)
|
||||
|
||||
var ReferTimeStatusStrings = map[ReferTimeStatus]string{
|
||||
ReferTimeActiveStatus: "active",
|
||||
ReferTimeInactiveStatus: "inactive",
|
||||
}
|
||||
|
||||
func (s ReferTimeStatus) String() string {
|
||||
return ReferTimeStatusStrings[s]
|
||||
}
|
||||
|
||||
func (s ReferTimeStatus) IsValid() bool {
|
||||
return s > 0 && int(s) <= len(ReferTimeStatusStrings)
|
||||
}
|
||||
|
||||
// AllReferTimeStatus returns a slice containing all string values of ReferTimeStatus.
|
||||
func AllReferTimeStatus() []string {
|
||||
statusStrings := make([]string, len(ReferTimeStatusStrings))
|
||||
for status, str := range ReferTimeStatusStrings {
|
||||
statusStrings[int(status)-1] = str
|
||||
}
|
||||
|
||||
return statusStrings
|
||||
}
|
||||
|
||||
// MapToReferTimeStatus converts a string to the corresponding ReferTimeStatus value.
|
||||
func MapToReferTimeStatus(statusStr string) ReferTimeStatus {
|
||||
for status, str := range ReferTimeStatusStrings {
|
||||
if str == statusStr {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
return ReferTimeStatus(0)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package entity
|
||||
|
||||
type UserRole uint
|
||||
type UserRole string
|
||||
|
||||
const (
|
||||
UserBenefactorRole UserRole = iota + 1
|
||||
UserBenefactorRole = UserRole("benefactor")
|
||||
)
|
||||
|
||||
var UserRoleStrings = map[UserRole]string{
|
||||
|
@ -13,24 +13,3 @@ var UserRoleStrings = map[UserRole]string{
|
|||
func (s UserRole) String() string {
|
||||
return UserRoleStrings[s]
|
||||
}
|
||||
|
||||
// AllUserRole returns a slice containing all string values of UserRole.
|
||||
func AllUserRole() []string {
|
||||
roleStrings := make([]string, len(UserRoleStrings))
|
||||
for role, str := range UserRoleStrings {
|
||||
roleStrings[int(role)-1] = str
|
||||
}
|
||||
|
||||
return roleStrings
|
||||
}
|
||||
|
||||
// MapToUserRole converts a string to the corresponding UserRole value.
|
||||
func MapToUserRole(roleStr string) UserRole {
|
||||
for role, str := range UserRoleStrings {
|
||||
if str == roleStr {
|
||||
return role
|
||||
}
|
||||
}
|
||||
|
||||
return UserRole(0)
|
||||
}
|
||||
|
|
4
go.mod
4
go.mod
|
@ -3,7 +3,6 @@ module git.gocasts.ir/ebhomengo/niki
|
|||
go 1.21.3
|
||||
|
||||
require (
|
||||
github.com/brianvoe/gofakeit/v6 v6.28.0
|
||||
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
|
@ -14,7 +13,6 @@ require (
|
|||
github.com/labstack/echo/v4 v4.12.0
|
||||
github.com/redis/go-redis/v9 v9.4.0
|
||||
github.com/rubenv/sql-migrate v1.6.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/swaggo/echo-swagger v1.4.1
|
||||
github.com/swaggo/swag v1.16.3
|
||||
golang.org/x/crypto v0.23.0
|
||||
|
@ -25,7 +23,6 @@ require (
|
|||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
|
@ -45,7 +42,6 @@ require (
|
|||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/swaggo/files/v2 v2.0.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -29,8 +29,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
|
|||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
|
||||
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package initial
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
)
|
||||
|
||||
type Auth struct {
|
||||
BenefactorAuthSvc authservice.Service
|
||||
AdminAuthSvc authservice.Service
|
||||
}
|
||||
|
||||
func InitBenefactorAuthService(cfg config.Config) authservice.Service {
|
||||
return authservice.New(cfg.Auth)
|
||||
}
|
||||
|
||||
func InitAdminAuthService(cfg config.Config) authservice.Service {
|
||||
return authservice.New(cfg.AdminAuth)
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package initial
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
)
|
||||
|
||||
type AdminAuthorization struct {
|
||||
AdminAuthorizationSvc adminauthorizationservice.Service
|
||||
}
|
||||
|
||||
func InitAdminAuthorizationService(db *mysql.DB) adminauthorizationservice.Service {
|
||||
return adminauthorizationservice.New(InitAdminMysql(db))
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package initial
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
mysqladdress "git.gocasts.ir/ebhomengo/niki/repository/mysql/address"
|
||||
mysqladmin "git.gocasts.ir/ebhomengo/niki/repository/mysql/admin"
|
||||
mysqlkindbox "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box"
|
||||
mysqlkindboxreq "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box_req"
|
||||
mysqlrefertime "git.gocasts.ir/ebhomengo/niki/repository/mysql/refer_time"
|
||||
)
|
||||
|
||||
type Databases struct {
|
||||
BenefactorAddressDB *mysqladdress.DB
|
||||
BenefactorKindBoxReqDB *mysqlkindboxreq.DB
|
||||
KindBoxRepo *mysqlkindbox.DB
|
||||
AdminMysql *mysqladmin.DB
|
||||
}
|
||||
|
||||
func InitMysql(cfg config.Config) *mysql.DB {
|
||||
return mysql.New(cfg.Mysql)
|
||||
}
|
||||
|
||||
func InitBenefactorAddressDB(db *mysql.DB) *mysqladdress.DB {
|
||||
return mysqladdress.New(db)
|
||||
}
|
||||
|
||||
func InitBenefactorKindBoxReqDB(db *mysql.DB) *mysqlkindboxreq.DB {
|
||||
return mysqlkindboxreq.New(db)
|
||||
}
|
||||
|
||||
func InitKindBoxRepo(db *mysql.DB) *mysqlkindbox.DB {
|
||||
return mysqlkindbox.New(db)
|
||||
}
|
||||
|
||||
func InitAdminMysql(db *mysql.DB) *mysqladmin.DB {
|
||||
return mysqladmin.New(db)
|
||||
}
|
||||
|
||||
func InitAdminReferTimeDB(db *mysql.DB) *mysqlrefertime.DB {
|
||||
return mysqlrefertime.New(db)
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package initial
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
|
||||
smsprovider "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar"
|
||||
kavenegarnotification "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar/notification"
|
||||
kavenegarotp "git.gocasts.ir/ebhomengo/niki/adapter/sms_provider/kavenegar/otp"
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
mysqladdress "git.gocasts.ir/ebhomengo/niki/repository/mysql/address"
|
||||
mysqlbenefactor "git.gocasts.ir/ebhomengo/niki/repository/mysql/benefactor"
|
||||
mysqlkindbox "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box"
|
||||
mysqlkindboxreq "git.gocasts.ir/ebhomengo/niki/repository/mysql/kind_box_req"
|
||||
redisotp "git.gocasts.ir/ebhomengo/niki/repository/redis/redis_otp"
|
||||
adminservice "git.gocasts.ir/ebhomengo/niki/service/admin/admin"
|
||||
benefactorforadminservice "git.gocasts.ir/ebhomengo/niki/service/admin/benefactor"
|
||||
adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box"
|
||||
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
||||
adminrefertimeservice "git.gocasts.ir/ebhomengo/niki/service/admin/refer_time"
|
||||
agentkindboxservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box"
|
||||
benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address"
|
||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/benefactor"
|
||||
benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box"
|
||||
benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/service/notification"
|
||||
)
|
||||
|
||||
type Services struct {
|
||||
BenefactorSvc benefactorservice.Service
|
||||
BenefactorKindBoxReqSvc benefactorkindboxreqservice.Service
|
||||
BenefactorAddressSvc benefactoraddressservice.Service
|
||||
BenefactorKindBoxSvc benefactorkindboxservice.Service
|
||||
AdminKindBoxSvc adminkindboxservice.Service
|
||||
AgentKindBoxSvc agentkindboxservice.Service
|
||||
AdminSvc adminservice.Service
|
||||
AdminKindBoxReqSvc adminkindboxreqservice.Service
|
||||
AdminReferTimeSvc adminrefertimeservice.Service
|
||||
NotificationSvc notification.Service
|
||||
}
|
||||
|
||||
func initSmsOtp(cfg config.Config) *kavenegarotp.Adapter {
|
||||
return kavenegarotp.New(smsprovider.New(cfg.KavenegarSmsProvider))
|
||||
}
|
||||
|
||||
func initSmsNotification(cfg config.Config) *kavenegarnotification.Adapter {
|
||||
return kavenegarnotification.New(smsprovider.New(cfg.KavenegarSmsProvider))
|
||||
}
|
||||
|
||||
func InitAdminService(cfg config.Config, db *mysql.DB) adminservice.Service {
|
||||
return adminservice.New(InitAdminMysql(db), InitAdminAuthService(cfg))
|
||||
}
|
||||
|
||||
func InitBenefactorForAdminService(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorforadminservice.Service {
|
||||
return benefactorforadminservice.New(InitAdminMysql(db), InitBenefactorService(cfg, redisAdapter, db))
|
||||
}
|
||||
|
||||
func InitBenefactorService(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorservice.Service {
|
||||
return benefactorservice.New(
|
||||
cfg.BenefactorSvc,
|
||||
redisotp.New(redisAdapter),
|
||||
initSmsOtp(cfg),
|
||||
InitBenefactorAuthService(cfg),
|
||||
mysqlbenefactor.New(db),
|
||||
)
|
||||
}
|
||||
|
||||
func InitBenefactorAddressService(db *mysql.DB) benefactoraddressservice.Service {
|
||||
return benefactoraddressservice.New(mysqladdress.New(db))
|
||||
}
|
||||
|
||||
func InitBenefactorKindBoxReqService(db *mysql.DB) benefactorkindboxreqservice.Service {
|
||||
return benefactorkindboxreqservice.New(mysqlkindboxreq.New(db))
|
||||
}
|
||||
|
||||
func InitAdminKindBoxService(db *mysql.DB) adminkindboxservice.Service {
|
||||
return adminkindboxservice.New(InitKindBoxRepo(db))
|
||||
}
|
||||
|
||||
func InitAgentKindBoxService(db *mysql.DB) agentkindboxservice.Service {
|
||||
return agentkindboxservice.New(InitKindBoxRepo(db))
|
||||
}
|
||||
|
||||
func InitAdminKindBoxReqService(db *mysql.DB) adminkindboxreqservice.Service {
|
||||
return adminkindboxreqservice.New(InitBenefactorKindBoxReqDB(db), InitAdminKindBoxService(db))
|
||||
}
|
||||
|
||||
func InitAdminReferTimeService(db *mysql.DB) adminrefertimeservice.Service {
|
||||
return adminrefertimeservice.New(
|
||||
InitAdminReferTimeDB(db),
|
||||
)
|
||||
}
|
||||
|
||||
func InitBenefactorKindBoxService(db *mysql.DB) benefactorkindboxservice.Service {
|
||||
return benefactorkindboxservice.New(mysqlkindbox.New(db))
|
||||
}
|
||||
|
||||
func InitNotificationService(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) notification.Service {
|
||||
return notification.New(initSmsNotification(cfg), InitAdminKindBoxReqService(db), InitBenefactorForAdminService(cfg, redisAdapter, db))
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package initial
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin"
|
||||
adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box"
|
||||
adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req"
|
||||
agentkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/agent/kind_box"
|
||||
benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address"
|
||||
benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor"
|
||||
benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box"
|
||||
benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req"
|
||||
)
|
||||
|
||||
type Validators struct {
|
||||
BenefactorVld benefactorvalidator.Validator
|
||||
BenefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator
|
||||
BenefactorAddressVld benefactoraddressvalidator.Validator
|
||||
BenefactorKindBoxVld benefactorkindboxvalidator.Validator
|
||||
AdminKindBoxReqVld adminkindboxreqvalidator.Validator
|
||||
AdminVld adminvalidator.Validator
|
||||
AdminKindBoxVld adminkindboxvalidator.Validator
|
||||
AgentKindBoxVld agentkindboxvalidator.Validator
|
||||
}
|
||||
|
||||
func InitAdminKindBoxReqValidator(db *mysql.DB, cfg config.Config, redisAdapter redis.Adapter) adminkindboxreqvalidator.Validator {
|
||||
return adminkindboxreqvalidator.New(InitBenefactorKindBoxReqDB(db), InitAdminService(cfg, db), InitBenefactorForAdminService(cfg, redisAdapter, db), InitAdminReferTimeService(db), InitBenefactorAddressService(db))
|
||||
}
|
||||
|
||||
func InitAdminValidator(db *mysql.DB) adminvalidator.Validator {
|
||||
return adminvalidator.New(InitAdminMysql(db))
|
||||
}
|
||||
|
||||
func InitBenefactorValidator() benefactorvalidator.Validator {
|
||||
return benefactorvalidator.New()
|
||||
}
|
||||
|
||||
func InitBenefactorKindBoxReqValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorkindboxreqvalidator.Validator {
|
||||
return benefactorkindboxreqvalidator.New(
|
||||
InitBenefactorService(cfg, redisAdapter, db),
|
||||
InitBenefactorAddressService(db),
|
||||
InitAdminReferTimeService(db),
|
||||
InitBenefactorKindBoxReqDB(db),
|
||||
)
|
||||
}
|
||||
|
||||
func InitBenefactorAddressValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactoraddressvalidator.Validator {
|
||||
return benefactoraddressvalidator.New(
|
||||
InitBenefactorService(cfg, redisAdapter, db),
|
||||
InitBenefactorAddressDB(db),
|
||||
)
|
||||
}
|
||||
|
||||
func InitAdminKindBoxValidator(db *mysql.DB, cfg config.Config) adminkindboxvalidator.Validator {
|
||||
return adminkindboxvalidator.New(InitKindBoxRepo(db), InitAdminService(cfg, db))
|
||||
}
|
||||
|
||||
func InitAgentKindBoxValidator(db *mysql.DB) agentkindboxvalidator.Validator {
|
||||
return agentkindboxvalidator.New(InitKindBoxRepo(db))
|
||||
}
|
||||
|
||||
func InitBenefactorKindBoxValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorkindboxvalidator.Validator {
|
||||
return benefactorkindboxvalidator.New(
|
||||
InitKindBoxRepo(db),
|
||||
InitBenefactorService(cfg, redisAdapter, db),
|
||||
InitBenefactorAddressService(db),
|
||||
InitAdminReferTimeService(db),
|
||||
)
|
||||
}
|
114
main.go
114
main.go
|
@ -4,30 +4,17 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/adapter/kavenegar"
|
||||
"git.gocasts.ir/ebhomengo/niki/adapter/redis"
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
smscontract "git.gocasts.ir/ebhomengo/niki/contract/sms"
|
||||
httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server"
|
||||
"git.gocasts.ir/ebhomengo/niki/internal/initial"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/migrator"
|
||||
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
|
||||
"git.gocasts.ir/ebhomengo/niki/service"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
)
|
||||
|
||||
type Dependencies struct {
|
||||
initial.Auth
|
||||
initial.Databases
|
||||
initial.Validators
|
||||
initial.Services
|
||||
initial.AdminAuthorization
|
||||
}
|
||||
|
||||
func parseFlags() bool {
|
||||
migrateFlag := flag.Bool("migrate", false, "perform database migration")
|
||||
flag.Parse()
|
||||
|
||||
return *migrateFlag
|
||||
}
|
||||
|
||||
// @securityDefinitions.apikey AuthBearerBenefactor
|
||||
// @in header
|
||||
// @name Authorization
|
||||
|
@ -37,89 +24,46 @@ func parseFlags() bool {
|
|||
// @name Authorization
|
||||
// @description Type the word 'Bearer' followed by a space and Admin JWT token.
|
||||
func main() {
|
||||
migrate := parseFlags()
|
||||
|
||||
cfg := config.C()
|
||||
db := initDatabase(cfg, migrate)
|
||||
cfg := Config()
|
||||
db := MariaDB(cfg)
|
||||
defer func() {
|
||||
if err := db.CloseStatements(); err != nil {
|
||||
fmt.Printf("Error closing statements: %v\n", err)
|
||||
}
|
||||
}()
|
||||
redisAdapter := initRedis(cfg)
|
||||
|
||||
dependencies := initDependencies(cfg, redisAdapter, db)
|
||||
|
||||
initAndRunServer(cfg, dependencies)
|
||||
rds := Redis(cfg)
|
||||
kvn := Kavenegar(cfg)
|
||||
svc := Service(cfg, db, rds, kvn)
|
||||
httpServer := HTTPServer(cfg, svc)
|
||||
httpServer.Serve()
|
||||
}
|
||||
|
||||
func initDependencies(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) *Dependencies {
|
||||
return &Dependencies{
|
||||
initial.Auth{
|
||||
BenefactorAuthSvc: initial.InitBenefactorAuthService(cfg),
|
||||
AdminAuthSvc: initial.InitAdminAuthService(cfg),
|
||||
},
|
||||
initial.Databases{
|
||||
BenefactorAddressDB: initial.InitBenefactorAddressDB(db),
|
||||
BenefactorKindBoxReqDB: initial.InitBenefactorKindBoxReqDB(db),
|
||||
KindBoxRepo: initial.InitKindBoxRepo(db),
|
||||
AdminMysql: initial.InitAdminMysql(db),
|
||||
},
|
||||
initial.Validators{
|
||||
BenefactorVld: initial.InitBenefactorValidator(),
|
||||
BenefactorKindBoxReqVld: initial.InitBenefactorKindBoxReqValidator(cfg, redisAdapter, db),
|
||||
BenefactorAddressVld: initial.InitBenefactorAddressValidator(cfg, redisAdapter, db),
|
||||
BenefactorKindBoxVld: initial.InitBenefactorKindBoxValidator(cfg, redisAdapter, db),
|
||||
AdminKindBoxReqVld: initial.InitAdminKindBoxReqValidator(db, cfg, redisAdapter),
|
||||
AdminVld: initial.InitAdminValidator(db),
|
||||
AdminKindBoxVld: initial.InitAdminKindBoxValidator(db, cfg),
|
||||
AgentKindBoxVld: initial.InitAgentKindBoxValidator(db),
|
||||
},
|
||||
initial.Services{
|
||||
BenefactorSvc: initial.InitBenefactorService(cfg, redisAdapter, db),
|
||||
BenefactorKindBoxReqSvc: initial.InitBenefactorKindBoxReqService(db),
|
||||
BenefactorAddressSvc: initial.InitBenefactorAddressService(db),
|
||||
BenefactorKindBoxSvc: initial.InitBenefactorKindBoxService(db),
|
||||
AdminKindBoxSvc: initial.InitAdminKindBoxService(db),
|
||||
AgentKindBoxSvc: initial.InitAgentKindBoxService(db),
|
||||
AdminKindBoxReqSvc: initial.InitAdminKindBoxReqService(db),
|
||||
AdminSvc: initial.InitAdminService(cfg, db),
|
||||
AdminReferTimeSvc: initial.InitAdminReferTimeService(db),
|
||||
NotificationSvc: initial.InitNotificationService(cfg, redisAdapter, db),
|
||||
},
|
||||
initial.AdminAuthorization{
|
||||
AdminAuthorizationSvc: initial.InitAdminAuthorizationService(db),
|
||||
},
|
||||
}
|
||||
func Config() config.Config {
|
||||
return config.C()
|
||||
}
|
||||
|
||||
func initAndRunServer(cfg config.Config, dependencies *Dependencies) {
|
||||
server := httpserver.New(cfg,
|
||||
dependencies.BenefactorSvc, dependencies.BenefactorVld, dependencies.BenefactorAuthSvc,
|
||||
dependencies.BenefactorKindBoxReqSvc, dependencies.BenefactorKindBoxReqVld,
|
||||
dependencies.BenefactorAddressSvc, dependencies.BenefactorAddressVld,
|
||||
dependencies.BenefactorKindBoxSvc, dependencies.BenefactorKindBoxVld,
|
||||
dependencies.AdminSvc, dependencies.AdminVld, dependencies.AdminAuthSvc,
|
||||
dependencies.AdminKindBoxReqSvc, dependencies.AdminKindBoxReqVld, dependencies.AdminAuthorizationSvc,
|
||||
dependencies.AdminKindBoxSvc, dependencies.AdminKindBoxVld,
|
||||
dependencies.AgentKindBoxSvc, dependencies.AgentKindBoxVld, dependencies.NotificationSvc)
|
||||
|
||||
server.Serve()
|
||||
func MariaDB(cfg config.Config) *mysql.DB {
|
||||
migrate := flag.Bool("migrate", false, "perform database migration")
|
||||
flag.Parse()
|
||||
if *migrate {
|
||||
migrator.New(cfg.Mysql).Up()
|
||||
}
|
||||
|
||||
func initDatabase(cfg config.Config, migrate bool) *mysql.DB {
|
||||
if migrate {
|
||||
migrateDatabase(cfg)
|
||||
return mysql.New(cfg.Mysql)
|
||||
}
|
||||
|
||||
return initial.InitMysql(cfg)
|
||||
}
|
||||
|
||||
func initRedis(cfg config.Config) redis.Adapter {
|
||||
func Redis(cfg config.Config) *redis.Adapter {
|
||||
return redis.New(cfg.Redis)
|
||||
}
|
||||
|
||||
func migrateDatabase(cfg config.Config) {
|
||||
migratorDB := migrator.New(cfg.Mysql)
|
||||
migratorDB.Up()
|
||||
func Kavenegar(cfg config.Config) *kavenegar.Adapter {
|
||||
return kavenegar.New(cfg.KavenegarSmsProvider)
|
||||
}
|
||||
|
||||
func Service(cfg config.Config, db *mysql.DB, rds *redis.Adapter, smsAdapter smscontract.SmsAdapter) *service.Service {
|
||||
return service.New(cfg, db, rds, smsAdapter)
|
||||
}
|
||||
|
||||
func HTTPServer(cfg config.Config, svc *service.Service) *httpserver.Server {
|
||||
return httpserver.New(cfg, svc)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package adminaddressparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type AddressGetRequest struct {
|
||||
AddressID uint
|
||||
}
|
||||
|
||||
type AddressGetResponse struct {
|
||||
Address entity.Address
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package adminserviceparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type GetAddressByIDRequest struct {
|
||||
ID uint
|
||||
}
|
||||
type GetAddressByIDResponse struct {
|
||||
Address *entity.Address
|
||||
}
|
|
@ -10,6 +10,7 @@ type LoginWithPhoneNumberRequest struct {
|
|||
type LoginWithPhoneNumberResponse struct {
|
||||
AdminInfo AdminInfo `json:"admin_info"`
|
||||
Tokens Tokens `json:"tokens"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
||||
type AdminInfo struct {
|
||||
|
@ -20,6 +21,6 @@ type AdminInfo struct {
|
|||
Role entity.AdminRole `json:"role" example:"2"`
|
||||
Description string `json:"description" example:"This is a description"`
|
||||
Email string `json:"email" example:"example@gmail.com"`
|
||||
Gender entity.Gender `json:"gender" example:"1"`
|
||||
Status entity.AdminStatus `json:"status" example:"1"`
|
||||
Gender entity.Gender `json:"gender" example:"male"`
|
||||
Status entity.AdminStatus `json:"status" example:"active"`
|
||||
}
|
||||
|
|
|
@ -10,10 +10,11 @@ type RegisterRequest struct {
|
|||
Role *entity.AdminRole `json:"role" example:"2"`
|
||||
Description *string `json:"description" example:"this is a description"`
|
||||
Email *string `json:"email" example:"miaad.66@gmail.com"`
|
||||
Gender *entity.Gender `json:"gender" example:"1"`
|
||||
Status *entity.AdminStatus `json:"status" example:"1"`
|
||||
Gender *entity.Gender `json:"gender" example:"male"`
|
||||
Status *entity.AdminStatus `json:"status" example:"active"`
|
||||
}
|
||||
|
||||
type RegisterResponse struct {
|
||||
Admin entity.Admin `json:"admin"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package adminagentparam
|
||||
|
||||
type AdminAgentExistByIDRequest struct {
|
||||
AgentID uint
|
||||
}
|
||||
|
||||
type AdminAgentExistByIDResponse struct {
|
||||
Exist bool
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package adminserviceparam
|
||||
package adminagentparam
|
||||
|
||||
type GetAllAgentResponse struct {
|
||||
Agents []Agent `json:"agents"`
|
|
@ -1,4 +1,4 @@
|
|||
package adminserviceparam
|
||||
package adminbenefactoreparam
|
||||
|
||||
type BenefactorExistByIDRequest struct {
|
||||
ID uint
|
|
@ -4,3 +4,7 @@ type AssignReceiverRequest struct {
|
|||
KindBoxID uint `json:"-" param:"id"`
|
||||
ReceiverAgentID uint `json:"receiver_agent_id"`
|
||||
}
|
||||
|
||||
type AssignReceiverResponse struct {
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -4,3 +4,7 @@ type EnumerateKindBoxRequest struct {
|
|||
KindBoxID uint `json:"-" param:"id"`
|
||||
Amount uint `json:"amount"`
|
||||
}
|
||||
|
||||
type EnumerateKindBoxResponse struct {
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -8,4 +8,5 @@ type KindBoxGetRequest struct {
|
|||
|
||||
type KindBoxGetResponse struct {
|
||||
entity.KindBox
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue