forked from ebhomengo/niki
Compare commits
1 Commits
develop
...
stage/fate
Author | SHA1 | Date |
---|---|---|
Fatemeh Javadi | 66ced2ea9b |
|
@ -18,9 +18,9 @@ activate.mise.toml
|
|||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
vendor/
|
||||
.idea
|
||||
bin
|
||||
tmp
|
||||
|
||||
#.env
|
||||
*.env
|
||||
|
|
34
Dockerfile
34
Dockerfile
|
@ -1,29 +1,37 @@
|
|||
# Build Stage
|
||||
FROM golang:1.23.0-alpine AS builder
|
||||
|
||||
# First pull Golang image
|
||||
FROM golang:1.21.3-alpine as builder
|
||||
|
||||
# Set environment variable
|
||||
ENV APP_NAME niki
|
||||
ENV CMD_PATH main.go
|
||||
|
||||
# Add a work directory
|
||||
WORKDIR /$APP_NAME
|
||||
|
||||
## Cache and install dependencies
|
||||
#COPY go.mod go.sum ./
|
||||
#RUN go mod download
|
||||
|
||||
# Copy app files
|
||||
COPY . .
|
||||
|
||||
# Budild application
|
||||
RUN CGO_ENABLED=0 go build -mod=vendor -v -o $APP_NAME .
|
||||
RUN CGO_ENABLED=0 go build -mod=mod -v -o $APP_NAME .
|
||||
|
||||
# Run Stage
|
||||
FROM alpine:3.20 AS runtime
|
||||
|
||||
# Copy the binary from the builder stage
|
||||
COPY --from=builder /niki/niki .
|
||||
|
||||
# Copy migration files
|
||||
COPY --from=builder /niki/repository/mysql/migration ./repository/mysql/migration
|
||||
FROM alpine:3.18 as development
|
||||
|
||||
|
||||
# Set environment variable
|
||||
ENV APP_NAME niki
|
||||
|
||||
# Copy only required data into this image
|
||||
COPY --from=builder /$APP_NAME .
|
||||
|
||||
# Expose application port
|
||||
EXPOSE 8313
|
||||
|
||||
# Start the application
|
||||
CMD ["./niki", "--migrate"]
|
||||
EXPOSE 1313
|
||||
|
||||
# Start app
|
||||
CMD ./$APP_NAME
|
2
Makefile
2
Makefile
|
@ -16,7 +16,7 @@ format:
|
|||
@which gofumpt || (go install mvdan.cc/gofumpt@latest)
|
||||
@gofumpt -l -w $(ROOT)
|
||||
@which gci || (go install github.com/daixiang0/gci@latest)
|
||||
@gci write $(ROOT) --skip-generated --skip-vendor
|
||||
@gci write $(ROOT)
|
||||
@which golangci-lint || (go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.0)
|
||||
@golangci-lint run --fix
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ redis:
|
|||
password: ""
|
||||
db: 0
|
||||
|
||||
sms_provider:
|
||||
host: localhost
|
||||
port: 443
|
||||
|
||||
benefactor_service:
|
||||
length_of_otp_code: 5
|
||||
|
||||
|
|
|
@ -10,12 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type HTTPServer struct {
|
||||
Port int `koanf:"port"`
|
||||
Cors Cors `koanf:"cors"`
|
||||
}
|
||||
|
||||
type Cors struct {
|
||||
AllowOrigins []string `koanf:"allow_origins"`
|
||||
Port int `koanf:"port"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// LoginByPhoneNumber godoc
|
||||
// @Summary Admin login by PhoneNumber
|
||||
// @Tags Admins
|
||||
// @Tags Admin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body adminserviceparam.LoginWithPhoneNumberRequest true "Admin login request body"
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package adminhandler
|
||||
|
||||
import (
|
||||
adminserviceparam "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
|
||||
"net/http"
|
||||
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// RefreshAccess godoc
|
||||
// @Summary Get a new access token by providing a refresh token
|
||||
// @Tags Admins
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body adminserviceparam.RefreshAccessRequest true "Refresh access request body"
|
||||
// @Success 200 {object} adminserviceparam.RefreshAccessResponse
|
||||
// @Failure 400 {string} "Bad Request"
|
||||
// @Failure 422 {string} "invalid or expired jwt"
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Router /admins/refresh-access [post].
|
||||
func (h Handler) RefreshAccess(c echo.Context) error {
|
||||
var req adminserviceparam.RefreshAccessRequest
|
||||
|
||||
if err := c.Bind(&req); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
resp, err := h.adminSvc.RefreshAccess(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, resp)
|
||||
}
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// Register godoc
|
||||
// @Summary Register an admin by super-admin
|
||||
// @Tags Admins
|
||||
// @Tags Admin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body adminserviceparam.RegisterRequest true "Admin Register Request Body"
|
||||
|
|
|
@ -13,7 +13,6 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
//r.POST("/", h.Add).Name = "admin-addkindboxreq"
|
||||
r.POST("/register", h.Register, middleware.Auth(h.authSvc), middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminAdminRegisterPermission))
|
||||
r.POST("/login-by-phone", h.LoginByPhoneNumber)
|
||||
r.POST("/refresh-access", h.RefreshAccess)
|
||||
//nolint:gocritic
|
||||
//r.PATCH("/:id", h.Update).Name = "admin-updatekindboxreq"
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// GetAllAgent godoc
|
||||
// @Summary Get all agents by admin
|
||||
// @Tags Admins
|
||||
// @Tags Admin
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} adminagentparam.GetAllAgentResponse
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// AssignReceiverAgent godoc
|
||||
// @Summary Admin assign receiver agent to kindbox
|
||||
// @Tags Admins KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBox ID"
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
// @Success 204
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxes/{id}/assign-receiver-agent [patch].
|
||||
// @Router /admin/kindboxes/assign-receiver-agent/{id} [patch].
|
||||
func (h Handler) AssignReceiverAgent(c echo.Context) error {
|
||||
var req param.AssignReceiverRequest
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// Enumerate godoc
|
||||
// @Summary Admin enumerate kindbox
|
||||
// @Tags Admins KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBox ID"
|
||||
|
@ -23,7 +23,7 @@ import (
|
|||
// @Failure 422 {object} httpmsg.ErrorResponse
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxes/{id}/enumerate [patch].
|
||||
// @Router /admin/kindboxes/{id}/enumerate [patch].
|
||||
func (h Handler) Enumerate(c echo.Context) error {
|
||||
var req param.EnumerateKindBoxRequest
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
// Get godoc
|
||||
// @Summary Get a specific kind box by admin
|
||||
// @Description This endpoint retrieves a specific kind box by admin
|
||||
// @Tags Admins KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Kind box ID"
|
||||
// @Success 200 {object} param.KindBoxGetResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxes/{id} [get].
|
||||
// @Router /admin/kindboxes/{id} [get].
|
||||
func (h Handler) Get(c echo.Context) error {
|
||||
var req param.KindBoxGetRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// GetAll godoc
|
||||
// @Summary Get all KindBoxes by admin
|
||||
// @Description Retrieves a list of all KindBoxes with filtering, sorting, and pagination options
|
||||
// @Tags Admins KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
|
@ -39,7 +39,7 @@ import (
|
|||
// @Success 200 {object} param.KindBoxGetAllResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxes [get].
|
||||
// @Router /admin/kindboxes [get].
|
||||
func (h Handler) GetAll(c echo.Context) error {
|
||||
var req param.KindBoxGetAllRequest
|
||||
|
||||
|
|
|
@ -7,13 +7,12 @@ import (
|
|||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/admins/kindboxes")
|
||||
r := e.Group("/admin/kindboxes")
|
||||
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
|
||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetPermission))
|
||||
r.PATCH("/:id/assign-receiver-agent", h.AssignReceiverAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxAssignReceiverAgentPermission))
|
||||
r.PATCH("/assign-receiver-agent/:id", h.AssignReceiverAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxAssignReceiverAgentPermission))
|
||||
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAllPermission))
|
||||
r.PATCH("/:id/enumerate", h.Enumerate, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxEnumeratePermission))
|
||||
r.PUT("/update/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxUpdatePermission))
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
package adminkindboxhandler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// Update godoc
|
||||
// @Summary Update kind Box by admin
|
||||
// @Tags Admins KindBoxes
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Kind Box ID"
|
||||
// @Param Request body param.KindBoxUpdateRequest true "Update KindBox Request Body"
|
||||
// @Success 204
|
||||
// @Failure 400 {string} "Bad Request"
|
||||
// @Failure 401 {string} "invalid or expired jwt"
|
||||
// @Failure 403 {string} "user not allowed"
|
||||
// @Failure 422 {object} httpmsg.ErrorResponse
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxes/update/{id} [put].
|
||||
func (h Handler) Update(c echo.Context) error {
|
||||
|
||||
var req param.KindBoxUpdateRequest
|
||||
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
return c.JSON(http.StatusBadRequest, httpmsg.ErrorResponse{
|
||||
Message: "Invalid request body",
|
||||
})
|
||||
}
|
||||
|
||||
resp, sErr := h.adminKindBoxSvc.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)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusNoContent, nil)
|
||||
}
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
// Accept godoc
|
||||
// @Summary Accept kind box request by admin
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
@ -21,7 +21,7 @@ import (
|
|||
// @Success 200 {object} param.KindBoxReqAcceptResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxreqs/{id}/accept-kind-box-req [patch].
|
||||
// @Router /admin/kindboxreqs/accept-kind-box-req/{id} [patch].
|
||||
func (h Handler) Accept(c echo.Context) error {
|
||||
var req param.KindBoxReqAcceptRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
|
||||
// AddKindBoxReq godoc
|
||||
// @Summary Add a new kind box request for a benefactor by admin
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body param.KindBoxReqAddRequest true "New kind box request details"
|
||||
// @Success 200 {object} param.KindBoxReqAddResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxreqs [post].
|
||||
// @Router /admin/kindboxreqs [post].
|
||||
func (h Handler) AddKindBoxReq(c echo.Context) error {
|
||||
req := param.KindBoxReqAddRequest{}
|
||||
if err := c.Bind(&req); err != nil {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
// AssignSenderAgent godoc
|
||||
// @Summary Admin Assign Sender Agent to kindboxreq
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
@ -21,7 +21,7 @@ import (
|
|||
// @Success 200 {object} param.AssignSenderResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxreqs/{id}/assign-sender-agent [patch].
|
||||
// @Router /admin/kindboxreqs/assign-sender-agent/{id} [patch].
|
||||
func (h Handler) AssignSenderAgent(c echo.Context) error {
|
||||
var req param.AssignSenderRequest
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package agentkindboxreqhandler
|
||||
package adminkindboxreqhandler
|
||||
|
||||
import (
|
||||
"context"
|
||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||
"net/http"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
querier "git.gocasts.ir/ebhomengo/niki/pkg/query_transaction/sql"
|
||||
|
@ -13,8 +12,8 @@ import (
|
|||
)
|
||||
|
||||
// Deliver godoc
|
||||
// @Summary Agent deliver a kindboxreq
|
||||
// @Tags Agents KindBoxReqs
|
||||
// @Summary Admin deliver a kindboxreq
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
@ -22,7 +21,7 @@ import (
|
|||
// @Success 200 {object} param.DeliverKindBoxReqResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /agents/kindboxreqs/{id}/deliver-kind-box-req [patch].
|
||||
// @Router /admin/kindboxreqs/deliver-kind-box-req/{id} [patch].
|
||||
func (h Handler) Deliver(c echo.Context) error {
|
||||
var req param.DeliverKindBoxReqRequest
|
||||
|
||||
|
@ -32,7 +31,7 @@ func (h Handler) Deliver(c echo.Context) error {
|
|||
|
||||
q := querier.GetQuerierFromContextOrNew(c.Request().Context()).Begin()
|
||||
ctx := context.WithValue(c.Request().Context(), querier.QuerierContextKey, q)
|
||||
resp, sErr := h.agentKindBoxReqSvc.Deliver(ctx, req)
|
||||
resp, sErr := h.adminKindBoxReqSvc.Deliver(ctx, req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
||||
|
@ -53,9 +52,5 @@ func (h Handler) Deliver(c echo.Context) error {
|
|||
return echo.NewHTTPError(http.StatusInternalServerError, errmsg.ErrorMsgSomethingWentWrong)
|
||||
}
|
||||
|
||||
go h.notificationSvc.KindBoxReqDelivered(params.NotificationKindBoxReqDelivered{
|
||||
KindBoxReqID: req.KindBoxReqID,
|
||||
})
|
||||
|
||||
return c.JSON(http.StatusOK, resp)
|
||||
}
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// Get godoc
|
||||
// @Summary Get a specific kind box req by ID
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// GetAll godoc
|
||||
// @Summary Admin get all kindboxreq
|
||||
// @Description Retrieves a list of all KindBox requests with filtering, sorting, and pagination options
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package agentkindboxreqhandler
|
||||
package adminkindboxreqhandler
|
||||
|
||||
import (
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||
"net/http"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param"
|
||||
|
@ -14,7 +14,7 @@ import (
|
|||
// GetAllAwaitingDelivery godoc
|
||||
// @Summary Get all awaiting delivery KindBox requests
|
||||
// @Description Retrieves a list of all awaiting KindBox requests with filtering, sorting, and pagination options
|
||||
// @Tags Agents KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
|
@ -32,7 +32,7 @@ import (
|
|||
// @Success 200 {object} param.DeliveryAwaitingGetAllResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /agents/kindboxreqs/awaiting-delivery [get].
|
||||
// @Router /admin/kindboxreqs/awaiting-delivery [get].
|
||||
func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
||||
var req param.DeliveryAwaitingGetAllRequest
|
||||
|
||||
|
@ -42,7 +42,7 @@ func (h Handler) GetAllAwaitingDelivery(c echo.Context) error {
|
|||
req.Filter = queryparam.GetFilterParams(c)
|
||||
req.Filter["sender_agent_id"] = claim.GetClaimsFromEchoContext(c).UserID
|
||||
req.Filter["status"] = entity.KindBoxReqAssignedSenderAgentStatus
|
||||
resp, sErr := h.agentKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
||||
resp, sErr := h.adminKindBoxReqSvc.GetAllAwaitingDelivery(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
|
@ -1,9 +1,9 @@
|
|||
package agentkindboxreqhandler
|
||||
package adminkindboxreqhandler
|
||||
|
||||
import (
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box_req"
|
||||
"net/http"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
|
@ -11,14 +11,14 @@ import (
|
|||
|
||||
// GetAwaitingDelivery godoc
|
||||
// @Summary Get a kind box reqs that is awaiting delivery by agent
|
||||
// @Tags Agents KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
// @Success 200 {object} param.DeliveryAwaitingGetResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /agents/kindboxreqs/awaiting-delivery/{id} [get].
|
||||
// @Router /admin/kindboxreqs/awaiting-delivery/{id} [get].
|
||||
func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
||||
var req param.DeliveryAwaitingGetRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
@ -28,7 +28,7 @@ func (h Handler) GetAwaitingDelivery(c echo.Context) error {
|
|||
claims := claim.GetClaimsFromEchoContext(c)
|
||||
req.AgentID = claims.UserID
|
||||
|
||||
resp, sErr := h.agentKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
|
||||
resp, sErr := h.adminKindBoxReqSvc.GetAwaitingDelivery(c.Request().Context(), req)
|
||||
if sErr != nil {
|
||||
msg, code := httpmsg.Error(sErr)
|
||||
if resp.FieldErrors != nil {
|
|
@ -13,7 +13,7 @@ import (
|
|||
|
||||
// Reject godoc
|
||||
// @Summary Reject a kindboxreq by admin
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq id"
|
||||
|
@ -21,7 +21,7 @@ import (
|
|||
// @Success 200 {object} param.KindBoxReqRejectResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxreqs/{id}/reject-kind-box-req [patch].
|
||||
// @Router /admin/kindboxreqs/reject-kind-box-req/{id} [patch].
|
||||
func (h Handler) Reject(c echo.Context) error {
|
||||
var req param.KindBoxReqRejectRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -11,10 +11,13 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
r.POST("", h.AddKindBoxReq, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAddPermission))
|
||||
r.PATCH("/:id/accept-kind-box-req", h.Accept, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAcceptPermission))
|
||||
r.PATCH("/:id/reject-kind-box-req", h.Reject, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqRejectPermission))
|
||||
r.PATCH("/:id/assign-sender-agent", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
|
||||
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))
|
||||
r.PATCH("/deliver-kind-box-req/:id", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
|
||||
r.PATCH("/assign-sender-agent/:id", h.AssignSenderAgent, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqAssignSenderAgentPermission))
|
||||
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAllPermission))
|
||||
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||
r.PUT("/:id", h.Update, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqUpdatePermission))
|
||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetPermission))
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
// Update godoc
|
||||
// @Summary Update kind box request by admin
|
||||
// @Tags Admins KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
@ -18,7 +18,7 @@ import (
|
|||
// @Success 204
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/kindboxreqs/{id} [put].
|
||||
// @Router /admin/kindboxreqs/{id} [put].
|
||||
func (h Handler) Update(c echo.Context) error {
|
||||
var req param.KindBoxReqUpdateRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// Get godoc
|
||||
// @Summary Get a kind box that is awaiting return by agent
|
||||
// @Tags Agents KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBox ID"
|
|
@ -14,7 +14,7 @@ import (
|
|||
// GetAll godoc
|
||||
// @Summary Get all awaiting return KindBoxes by agent
|
||||
// @Description Retrieves a list of all awaiting return KindBoxes for agent with filtering, sorting, and pagination options
|
||||
// @Tags Agents KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
|
@ -4,25 +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"
|
||||
"git.gocasts.ir/ebhomengo/niki/service/notification"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authSvc authservice.Service
|
||||
agentKindBoxSvc agentkindboxservice.Service
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
notificationSvc notification.Service
|
||||
}
|
||||
|
||||
func New(authSvc authservice.Service,
|
||||
agentKindBoxSvc agentkindboxservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
notificationSvc notification.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authSvc: authSvc,
|
||||
agentKindBoxSvc: agentKindBoxSvc,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
notificationSvc: notificationSvc,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package agentkindboxhandler
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/agent/kind_box"
|
||||
"git.gocasts.ir/ebhomengo/niki/pkg/claim"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
|
@ -12,7 +11,7 @@ import (
|
|||
|
||||
// Return godoc
|
||||
// @Summary Return KindBox from benefactor by agent
|
||||
// @Tags Agents KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBox ID"
|
||||
|
@ -24,7 +23,7 @@ import (
|
|||
// @Failure 422 {object} httpmsg.ErrorResponse
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /agents/kindboxes/{id}/return [patch].
|
||||
// @Router /agents/kindboxes/return/{id} [patch].
|
||||
func (h Handler) Return(c echo.Context) error {
|
||||
var req param.ReturnKindBoxRequest
|
||||
if err := c.Bind(&req); err != nil {
|
||||
|
@ -47,9 +46,5 @@ func (h Handler) Return(c echo.Context) error {
|
|||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
go h.notificationSvc.KindBoxReturned(params.NotificationKindBoxReturned{
|
||||
KindBoxID: req.KindBoxID,
|
||||
})
|
||||
|
||||
return c.NoContent(http.StatusNoContent)
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
|
||||
r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
|
||||
r.GET("", h.GetAll, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetAwaitingReturnPermission))
|
||||
r.PATCH("/:id/return", h.Return, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReturnPermission))
|
||||
r.PATCH("/return/:id", h.Return, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReturnPermission))
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
package agentkindboxreqhandler
|
||||
|
||||
import (
|
||||
adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
agentkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/agent/kind_box_req"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
"git.gocasts.ir/ebhomengo/niki/service/notification"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authSvc authservice.Service
|
||||
agentKindBoxReqSvc agentkindboxreqservice.Service
|
||||
adminAuthorizeSvc adminauthorizationservice.Service
|
||||
notificationSvc notification.Service
|
||||
}
|
||||
|
||||
func New(authSvc authservice.Service,
|
||||
agentKindBoxReqSvc agentkindboxreqservice.Service,
|
||||
adminAuthorizeSvc adminauthorizationservice.Service,
|
||||
notificationSvc notification.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authSvc: authSvc,
|
||||
agentKindBoxReqSvc: agentKindBoxReqSvc,
|
||||
adminAuthorizeSvc: adminAuthorizeSvc,
|
||||
notificationSvc: notificationSvc,
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package agentkindboxreqhandler
|
||||
|
||||
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("/agents/kindboxreqs")
|
||||
|
||||
r.Use(middleware.Auth(h.authSvc))
|
||||
r.GET("/awaiting-delivery/:id", h.GetAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||
r.GET("/awaiting-delivery", h.GetAllAwaitingDelivery, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqGetAwaitingDeliveryPermission))
|
||||
r.PATCH("/:id/deliver-kind-box-req", h.Deliver, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxReqDeliverPermission))
|
||||
}
|
|
@ -12,14 +12,14 @@ import (
|
|||
// AddAddress godoc
|
||||
// @Summary Add a new address for a benefactor
|
||||
// @Description This endpoint allows an authenticated benefactor to add a new address to their account.
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body param.BenefactorAddAddressRequest true "New address details"
|
||||
// @Success 201 {object} param.BenefactorAddAddressResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/addresses [post].
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /address/ [post].
|
||||
func (h Handler) AddAddress(c echo.Context) error {
|
||||
req := param.BenefactorAddAddressRequest{}
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -12,12 +12,12 @@ import (
|
|||
// DeleteAddress godoc
|
||||
// @Summary Delete address by benefactor
|
||||
// @Description This endpoint is used to delete an address by benefactor
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Param id path int true "Address ID"
|
||||
// @Success 204
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/addresses/{id} [delete].
|
||||
// @Router /address/{id} [delete].
|
||||
func (h Handler) DeleteAddress(c echo.Context) error {
|
||||
var req param.DeleteAddressRequest
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
|
||||
// GetAddress godoc
|
||||
// @Summary Get a benefactor address
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Address ID"
|
||||
// @Success 200 {object} param.GetAddressResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/addresses/{id} [get].
|
||||
// @Router /address/{id} [get].
|
||||
func (h Handler) GetAddress(c echo.Context) error {
|
||||
var req param.GetAddressRequest
|
||||
if bErr := echo.PathParamsBinder(c).Uint("id", &req.AddressID).BindError(); bErr != nil {
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
|
||||
// GetAddresses godoc
|
||||
// @Summary Get all benefactor addresses
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} param.GetAllAddressesResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/addresses [get].
|
||||
// @Router /address/ [get].
|
||||
func (h Handler) GetAddresses(c echo.Context) error {
|
||||
var req param.GetAllAddressesRequest
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
|
||||
// GetAllCities godoc
|
||||
// @Summary Get all cities
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} addressparam.GetAllCitiesResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Router /benefactors/addresses/cities [get].
|
||||
// @Router /address/cities [get].
|
||||
func (h Handler) GetAllCities(c echo.Context) error {
|
||||
var req addressparam.GetAllCitiesRequest
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
|
||||
// GetAllProvinces godoc
|
||||
// @Summary Get all provinces
|
||||
// @Tags Benefactors Addresses
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} addressparam.GetAllProvincesResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Router /benefactors/addresses/provinces [get].
|
||||
// @Router /address/provinces [get].
|
||||
func (h Handler) GetAllProvinces(c echo.Context) error {
|
||||
var req addressparam.GetAllProvincesRequest
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@ import (
|
|||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/benefactors/addresses")
|
||||
r := e.Group("/address")
|
||||
|
||||
r.GET("/provinces", h.GetAllProvinces)
|
||||
r.GET("/cities", h.GetAllCities)
|
||||
r.POST("", h.AddAddress, middleware.Auth(h.authSvc),
|
||||
r.POST("/", h.AddAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.GET("/:id", h.GetAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.GET("", h.GetAddresses, middleware.Auth(h.authSvc),
|
||||
r.GET("/", h.GetAddresses, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.DELETE("/:id", h.DeleteAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
r.PUT("/:id", h.UpdateAddress, middleware.Auth(h.authSvc),
|
||||
r.PATCH("/:id", h.UpdateAddress, middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import (
|
|||
)
|
||||
|
||||
// UpdateAddress godoc
|
||||
// @Summary Update benefactor address
|
||||
// @Tags Benefactors Addresses
|
||||
// @Summary Edit benefactor address
|
||||
// @Tags Address
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Address ID"
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
// @Success 204
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/addresses/{id} [put].
|
||||
// @Router /address/{id} [patch].
|
||||
func (h Handler) UpdateAddress(c echo.Context) error {
|
||||
var req param.UpdateAddressRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
// loginOrRegister godoc
|
||||
// @Summary Login or register a benefactor
|
||||
// @Description This endpoint is used to authenticate an existing benefactor account or register a new one.
|
||||
// @Tags Benefactors
|
||||
// @Tags Benefactor
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body benefactoreparam.LoginOrRegisterRequest true "Login or register request details"
|
||||
// @Success 200 {object} benefactoreparam.LoginOrRegisterResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Router /benefactors/login-register [post].
|
||||
// @Router /benefactor/login-register [post].
|
||||
func (h Handler) loginOrRegister(c echo.Context) error {
|
||||
var req benefactoreparam.LoginOrRegisterRequest
|
||||
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package benefactorhandler
|
||||
|
||||
import (
|
||||
benefactorparam "git.gocasts.ir/ebhomengo/niki/param/benefactor/benefactor"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// RefreshAccess godoc
|
||||
// @Summary Get a new access token by providing your refresh token
|
||||
// @Tags Benefactors
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body benefactorparam.RefreshAccessRequest true "Refresh access token request body"
|
||||
// @Success 200 {object} benefactorparam.RefreshAccessResponse
|
||||
// @Failure 400 {string} "Bad Request"
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Router /benefactors/refresh-access [post].
|
||||
func (h Handler) RefreshAccess(c echo.Context) error {
|
||||
var req benefactorparam.RefreshAccessRequest
|
||||
|
||||
if err := c.Bind(&req); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
resp, err := h.benefactorSvc.RefreshAccess(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, resp)
|
||||
}
|
|
@ -5,9 +5,8 @@ import (
|
|||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/benefactors")
|
||||
r := e.Group("/benefactor")
|
||||
|
||||
r.POST("/send-otp", h.SendOtp)
|
||||
r.POST("/login-register", h.loginOrRegister)
|
||||
r.POST("/refresh-access", h.RefreshAccess)
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
// SendOtp godoc
|
||||
// @Summary Send OTP to benefactor
|
||||
// @Description This endpoint sends an OTP to the benefactor's phone number for verification purposes.
|
||||
// @Tags Benefactors
|
||||
// @Tags Benefactor
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body benefactoreparam.SendOtpRequest true "Send OTP request details"
|
||||
// @Success 200 {object} benefactoreparam.SendOtpResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Router /benefactors/send-otp [post].
|
||||
// @Router /benefactor/send-otp [post].
|
||||
func (h Handler) SendOtp(c echo.Context) error {
|
||||
var req benefactoreparam.SendOtpRequest
|
||||
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
// Get godoc
|
||||
// @Summary Get a specific kind box for a benefactor
|
||||
// @Description This endpoint retrieves a specific kind box associated with an authenticated benefactor.
|
||||
// @Tags Benefactors KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Kind box ID"
|
||||
// @Success 200 {object} param.KindBoxGetResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxes/{id} [get].
|
||||
// @Router /benefactor/kindboxes/{id} [get].
|
||||
func (h Handler) Get(c echo.Context) error {
|
||||
var req param.KindBoxGetRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
// GetAll godoc
|
||||
// @Summary Get all KindBoxes by benefactor
|
||||
// @Description Retrieves a list of all KindBoxes with filtering, sorting, and pagination options
|
||||
// @Tags Benefactors KindBoxes
|
||||
// @Tags KindBox
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
|
@ -40,7 +40,7 @@ import (
|
|||
// @Success 200 {object} param.KindBoxGetAllResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxes [get].
|
||||
// @Router /benefactor/kindboxes [get].
|
||||
func (h Handler) GetAll(c echo.Context) error {
|
||||
var req param.KindBoxGetAllRequest
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
// RegisterEmptyingRequest godoc
|
||||
// @Summary Register a new emptying request for a kind box by benefactor
|
||||
// @Tags Benefactors KindBoxes
|
||||
// @Tags Benefactor
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBox ID"
|
||||
|
@ -20,7 +20,7 @@ import (
|
|||
// @Success 204 {string} "No content"
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxes/{id}/emptying-requests [patch].
|
||||
// @Router /benefactor/kindboxes/{id}/emptying-requests [patch].
|
||||
func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
|
||||
var req param.KindBoxRegisterEmptyingRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
@ -44,7 +44,7 @@ func (h Handler) RegisterEmptyingRequest(c echo.Context) error {
|
|||
}
|
||||
|
||||
go h.notificationSvc.KindBoxRegisteredEmptyingRequest(params.NotificationKindBoxRegisteredEmptyingRequest{
|
||||
KindBoxID: resp.Data.ID,
|
||||
KindBoxID: resp.ID,
|
||||
})
|
||||
|
||||
return c.JSON(http.StatusNoContent, nil)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/benefactors/kindboxes")
|
||||
r := e.Group("/benefactor/kindboxes")
|
||||
|
||||
r.Use(
|
||||
middleware.Auth(h.authSvc),
|
||||
|
|
|
@ -13,14 +13,14 @@ import (
|
|||
|
||||
// Add godoc
|
||||
// @Summary Add a new kind box request for a benefactor
|
||||
// @Tags Benefactors KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param Request body param.KindBoxReqAddRequest true "New kind box request details"
|
||||
// @Success 200 {object} param.KindBoxReqAddResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxreqs [post].
|
||||
// @Router /benefactor/kindboxreqs/ [post].
|
||||
func (h Handler) Add(c echo.Context) error {
|
||||
req := param.KindBoxReqAddRequest{}
|
||||
if err := c.Bind(&req); err != nil {
|
||||
|
@ -46,7 +46,7 @@ func (h Handler) Add(c echo.Context) error {
|
|||
}
|
||||
|
||||
go h.notificationSvc.KindBoxReqAdded(params.NotificationKindBoxReqAdded{
|
||||
KindBoxReqID: resp.Data.ID,
|
||||
KindBoxReqID: resp.KindBoxReq.ID,
|
||||
})
|
||||
|
||||
return c.JSON(http.StatusCreated, resp)
|
||||
|
|
|
@ -9,17 +9,17 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// Delete godoc
|
||||
// @Summary Delete kindboxreq by benefactor
|
||||
// delete godoc
|
||||
// @Summary delete kindboxreq by benefactor
|
||||
// @Description This endpoint is used to delete benefactor's kindboxreq at pending status
|
||||
// @Tags Benefactors KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Kind box request ID"
|
||||
// @Success 200 {object} param.KindBoxReqDeleteResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxreqs/{id} [delete].
|
||||
// @Router /benefactor/kindboxreqs/{id} [delete].
|
||||
func (h Handler) Delete(c echo.Context) error {
|
||||
req := param.KindBoxReqDeleteRequest{}
|
||||
if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {
|
||||
|
|
|
@ -11,14 +11,14 @@ import (
|
|||
|
||||
// Get godoc
|
||||
// @Summary Get a kind box request for a benefactor
|
||||
// @Tags Benefactors KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Kind box request ID"
|
||||
// @Success 200 {object} param.KindBoxReqGetResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxreqs/{id} [get].
|
||||
// @Router /benefactor/kindboxreqs/{id} [get].
|
||||
func (h Handler) Get(c echo.Context) error {
|
||||
var req param.KindBoxReqGetRequest
|
||||
if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
// GetAll godoc
|
||||
// @Summary Get all KindBox requests
|
||||
// @Description Retrieves a list of all KindBox requests with filtering, sorting, and pagination options
|
||||
// @Tags Benefactors KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param filter_id query int false "Filter by ID"
|
||||
|
@ -32,7 +32,7 @@ import (
|
|||
// @Success 200 {object} param.GetAllResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxreqs [get].
|
||||
// @Router /benefactor/kindboxreqs/ [get].
|
||||
func (h Handler) GetAll(c echo.Context) error {
|
||||
var req param.GetAllRequest
|
||||
|
||||
|
|
|
@ -7,16 +7,16 @@ import (
|
|||
)
|
||||
|
||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||
r := e.Group("/benefactors/kindboxreqs")
|
||||
r := e.Group("/benefactor/kindboxreqs")
|
||||
|
||||
r.Use(
|
||||
middleware.Auth(h.authSvc),
|
||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole),
|
||||
)
|
||||
|
||||
r.POST("", h.Add)
|
||||
r.POST("/", h.Add)
|
||||
r.GET("/:id", h.Get)
|
||||
r.DELETE("/:id", h.Delete)
|
||||
r.GET("", h.GetAll)
|
||||
r.GET("/", h.GetAll)
|
||||
r.PUT("/:id", h.Update)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
// Update godoc
|
||||
// @Summary Update kind box request by benefactor
|
||||
// @Tags Benefactors KindBoxReqs
|
||||
// @Tags KindBoxReq
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "KindBoxReq ID"
|
||||
|
@ -23,7 +23,7 @@ import (
|
|||
// @Failure 422 {object} httpmsg.ErrorResponse
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Security AuthBearerBenefactor
|
||||
// @Router /benefactors/kindboxreqs/{id} [put].
|
||||
// @Router /benefactor/kindboxreqs/{id} [put].
|
||||
func (h Handler) Update(c echo.Context) error {
|
||||
var req param.KindBoxReqUpdateRequest
|
||||
if bErr := c.Bind(&req); bErr != nil {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
//go:build end2end
|
||||
// +build end2end
|
||||
|
||||
package end2end
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup"
|
||||
adminserviceparam "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestAdmin_KindBox_Get(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
// Get token
|
||||
lRes, err := services.AdminSvc.LoginWithPhoneNumber(context.Background(), adminserviceparam.LoginWithPhoneNumberRequest{
|
||||
PhoneNumber: "09384664402",
|
||||
Password: "Abc123456",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("could not login: %s", err)
|
||||
}
|
||||
|
||||
// Create a request
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/kindboxes/1", nil)
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
// Serve the request
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
// Assertions
|
||||
assert.Equal(t, http.StatusOK, rec.Code)
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
//go:build end2end
|
||||
// +build end2end
|
||||
|
||||
package end2end
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/delivery/http_server/end2end/setup"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
adminserviceparam "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Utility function to log in as an admin with dynamic credentials
|
||||
func loginAsAdmin(t *testing.T, phoneNumber, password string) (*adminserviceparam.LoginWithPhoneNumberResponse, error) {
|
||||
lRes, err := services.AdminSvc.LoginWithPhoneNumber(context.Background(), adminserviceparam.LoginWithPhoneNumberRequest{
|
||||
PhoneNumber: phoneNumber,
|
||||
Password: password,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("could not login: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
return &lRes, nil // Return address of lRes
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_Enumerate(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reqBody := `{
|
||||
"amount": 5
|
||||
}`
|
||||
|
||||
req := httptest.NewRequest(http.MethodPatch, "/admin/kindboxes/1/enumerate", strings.NewReader(reqBody))
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusNoContent, rec.Code)
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_Enumerate_MissingAmount(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reqBody := `{}`
|
||||
|
||||
req := httptest.NewRequest(http.MethodPatch, "/admin/kindboxes/1/enumerate", strings.NewReader(reqBody))
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusUnprocessableEntity, rec.Code)
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_Enumerate_NegativeAmount(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reqBody := `{
|
||||
"amount": -5
|
||||
}`
|
||||
|
||||
req := httptest.NewRequest(http.MethodPatch, "/admin/kindboxes/1/enumerate", strings.NewReader(reqBody))
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusBadRequest, rec.Code)
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_Enumeration_Forbidden(t *testing.T) {
|
||||
lRes, err := loginAsAdmin(t, "09384664403", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/kindboxes/1/enumerate", nil)
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusForbidden, rec.Code)
|
||||
|
||||
var response httpmsg.ErrorResponse
|
||||
err = json.NewDecoder(rec.Body).Decode(&response)
|
||||
if err != nil {
|
||||
t.Fatalf("could not decode response: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_GetAll(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/kindboxes?page_number=1&page_size=10&sort=created_at&order=desc&filter=status:active", nil)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusOK, rec.Code)
|
||||
|
||||
var response param.KindBoxGetAllResponse
|
||||
err = json.NewDecoder(rec.Body).Decode(&response)
|
||||
if err != nil {
|
||||
t.Fatalf("could not decode response: %s", err)
|
||||
}
|
||||
|
||||
assert.NotEmpty(t, response.AllKindBox, "expected kind boxes in response")
|
||||
assert.Equal(t, uint(1), response.Pagination.PageNumber, "expected page 1")
|
||||
assert.Equal(t, uint(10), response.Pagination.PageSize, "expected limit 10")
|
||||
assert.Empty(t, response.FieldErrors, "expected no field errors")
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_AssignReceiver(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
reqBody := `{
|
||||
"receiver_agent_id": 4
|
||||
}`
|
||||
|
||||
req := httptest.NewRequest(http.MethodPatch, "/admin/kindboxes/assign-receiver-agent/1", strings.NewReader(reqBody))
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusUnprocessableEntity, rec.Code)
|
||||
}
|
||||
|
||||
func TestAdmin_KindBox_Get(t *testing.T) {
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
lRes, err := loginAsAdmin(t, "09384664401", "Abc123456")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/admin/kindboxes/1", nil)
|
||||
req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
|
||||
req.Header.Set(echo.HeaderAuthorization, fmt.Sprintf("Bearer %s", lRes.Tokens.AccessToken))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
testServer.Serve(rec, req)
|
||||
|
||||
assert.Equal(t, http.StatusOK, rec.Code)
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package setup
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"net/http"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
httpserver "git.gocasts.ir/ebhomengo/niki/delivery/http_server"
|
||||
"git.gocasts.ir/ebhomengo/niki/service"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
type TestServer struct {
|
||||
|
|
|
@ -14,7 +14,7 @@ func Auth(service authservice.Service) echo.MiddlewareFunc {
|
|||
// TODO - as sign method string to config
|
||||
SigningMethod: "HS256",
|
||||
ParseTokenFunc: func(c echo.Context, auth string) (interface{}, error) {
|
||||
claims, err := service.ParseBearerToken(auth)
|
||||
claims, err := service.ParseToken(auth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// nolint
|
||||
//nolint
|
||||
func BenefactorAuthorization(role entity.UserRole) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
|
|
|
@ -2,7 +2,6 @@ package httpserver
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
agentkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/agent/kind_box_req"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/config"
|
||||
adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin"
|
||||
|
@ -29,7 +28,6 @@ type Server struct {
|
|||
adminKindBoxHandler adminKindBoxHandler.Handler
|
||||
adminAgentHandler adminagenthandler.Handler
|
||||
agentKindBoxHandler agentkindboxhandler.Handler
|
||||
agentKindBoxReqHandler agentkindboxreqhandler.Handler
|
||||
benefactorHandler benefactorhandler.Handler
|
||||
benefactorKindBoxReqHandler benefactorkindboxreqhandler.Handler
|
||||
benefactorAddressHandler benefactoraddresshandler.Handler
|
||||
|
@ -47,8 +45,7 @@ func New(
|
|||
adminKindBoxReqHandler: adminkindboxreqhandler.New(svc.AdminAuthSvc, svc.AdminKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
adminKindBoxHandler: adminKindBoxHandler.New(svc.AdminAuthSvc, svc.AdminKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
adminAgentHandler: adminagenthandler.New(svc.AdminAuthSvc, svc.AdminAgentSvc, svc.AdminAuthorizeSvc),
|
||||
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
agentKindBoxReqHandler: agentkindboxreqhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc),
|
||||
benefactorHandler: benefactorhandler.New(svc.BenefactorAuthSvc, svc.BenefactorSvc),
|
||||
benefactorKindBoxReqHandler: benefactorkindboxreqhandler.New(svc.BenefactorAuthSvc, svc.BenefactorKindBoxReqSvc, svc.NotificationSvc),
|
||||
benefactorAddressHandler: benefactoraddresshandler.New(svc.BenefactorAuthSvc, svc.BenefactorAddressSvc),
|
||||
|
@ -70,10 +67,7 @@ func (s Server) Serve() {
|
|||
func (s Server) RegisterRoutes() {
|
||||
s.Router.Use(middleware.RequestID())
|
||||
s.Router.Use(middleware.Recover())
|
||||
s.Router.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
AllowOrigins: s.config.HTTPServer.Cors.AllowOrigins,
|
||||
}))
|
||||
registerSwagger(s.Router)
|
||||
registerSwagger(s.Router, s.config)
|
||||
|
||||
// Routes
|
||||
s.Router.GET("/health-check", s.healthCheck)
|
||||
|
@ -82,18 +76,17 @@ func (s Server) RegisterRoutes() {
|
|||
s.benefactorAddressHandler.SetRoutes(s.Router)
|
||||
s.benefactorKindBoxHandler.SetRoutes(s.Router)
|
||||
s.adminHandler.SetRoutes(s.Router)
|
||||
s.adminAgentHandler.SetRoutes(s.Router)
|
||||
s.adminKindBoxReqHandler.SetRoutes(s.Router)
|
||||
s.adminKindBoxHandler.SetRoutes(s.Router)
|
||||
s.agentKindBoxHandler.SetRoutes(s.Router)
|
||||
s.agentKindBoxReqHandler.SetRoutes(s.Router)
|
||||
}
|
||||
|
||||
func registerSwagger(s *echo.Echo) {
|
||||
func registerSwagger(s *echo.Echo, c config.Config) {
|
||||
// TODO: move this to a better place and make it more dynamic and configurable
|
||||
docs.SwaggerInfo.Title = "NIKI API"
|
||||
docs.SwaggerInfo.Description = "This is the API documentation for the NIKI project"
|
||||
docs.SwaggerInfo.Version = "1.0.0"
|
||||
docs.SwaggerInfo.Host = fmt.Sprintf("localhost:%d", c.HTTPServer.Port)
|
||||
|
||||
s.GET("/swagger/*any", echoSwagger.WrapHandler)
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
COMPOSE_MARIADB_PORT=3306
|
||||
COMPOSE_MARIADB_DATABASE=niki_db
|
||||
COMPOSE_MARIADB_USER=niki
|
||||
COMPOSE_MARIADB_UR_PASSWORD=n0ki2agd23
|
||||
|
||||
COMPOSE_REDIS_PORT=6379
|
||||
COMPOSE_REDIS_DB=0
|
||||
COMPOSE_REDIS_PASSWORD=n0ki2agd23
|
||||
|
||||
COMPOSE_AUTH_SIGN_KEY=jwt_secret_stage_nik
|
||||
COMPOSE_ADMIN_AUTH_SIGN_KEY=admin-jwt_secret_stage_nik
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
type: yml
|
||||
|
||||
http_server:
|
||||
port: 1313
|
||||
cors:
|
||||
allow_origins:
|
||||
- "*"
|
||||
|
||||
benefactor_service:
|
||||
length_of_otp_code: 5
|
||||
|
||||
kavenegar_sms_provider:
|
||||
api_key: insert_your_api_key
|
||||
sender: insert_sender_number
|
|
@ -1,26 +1,12 @@
|
|||
version: '3.9'
|
||||
version: '3.7'
|
||||
|
||||
services:
|
||||
niki_app_stage:
|
||||
image: niki:${STAGE_NIKI_IMAGE_VERSION?error}
|
||||
image: niki:${STAGE_NIKI_IMAGE_VERSION}
|
||||
container_name: niki_app_stage
|
||||
environment:
|
||||
EB_MARIADB__HOST: niki_stage_mariadb
|
||||
EB_MARIADB__PORT: ${COMPOSE_MARIADB_PORT?error}
|
||||
EB_MARIADB__DB_NAME: ${COMPOSE_MARIADB_DATABASE?error}
|
||||
EB_MARIADB__USERNAME: ${COMPOSE_MARIADB_USER?error}
|
||||
EB_MARIADB__PASSWORD: ${COMPOSE_MARIADB_UR_PASSWORD?error}
|
||||
|
||||
EB_REDIS__HOST: niki_stage_redis
|
||||
EB_REDIS__PORT: ${COMPOSE_REDIS_PORT?error}
|
||||
EB_REDIS__DB: ${COMPOSE_REDIS_DB?error}
|
||||
EB_REDIS__PASSWORD: ${COMPOSE_REDIS_PASSWORD?error}
|
||||
|
||||
EB_AUTH__SIGN_KEY: ${COMPOSE_AUTH_SIGN_KEY?error}
|
||||
EB_ADMIN_AUTH__SIGN_KEY: ${COMPOSE_ADMIN_AUTH_SIGN_KEY?error}
|
||||
restart: always
|
||||
ports:
|
||||
- "127.0.0.1:8313:1313"
|
||||
- '127.0.0.1:8198:1313'
|
||||
networks:
|
||||
- niki-stage
|
||||
volumes:
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
type: yml
|
||||
|
||||
auth:
|
||||
sign_key: jwt_secret_stage_nik
|
||||
|
||||
http_server:
|
||||
port: 1313
|
||||
|
||||
mysql:
|
||||
port: 3306
|
||||
host: niki_stage_mariadb
|
||||
db_name: niki_db
|
||||
username: niki
|
||||
password: n0ki2agd23
|
||||
|
||||
redis:
|
||||
port: 6379
|
||||
host: niki_stage_redis
|
||||
password: ""
|
||||
db: 0
|
||||
|
||||
sms_provider:
|
||||
host: localhost
|
||||
port: 443
|
||||
|
||||
benefactor_service:
|
||||
length_of_otp_code: 5
|
||||
|
||||
kavenegar_sms_provider:
|
||||
api_key: insert_your_api_key
|
||||
otp_template_new_user: ebhomeverify
|
||||
otp_template_registered_user: ebhomeverify
|
||||
|
||||
admin_auth:
|
||||
sign_key: admin-jwt_secret_test_nik
|
|
@ -1,4 +0,0 @@
|
|||
COMPOSE_MARIADB_DATABASE=niki_db
|
||||
COMPOSE_MARIADB_USER=niki
|
||||
COMPOSE_MARIADB_UR_PASSWORD=n0ki2agd23
|
||||
COMPOSE_MARIADB_RT_PASSWORD=n0ki2agd23
|
|
@ -1,22 +1,22 @@
|
|||
version: '3.9'
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
niki_stage_mariadb:
|
||||
image: docker.io/bitnami/mariadb:11.1
|
||||
container_name: niki_stage_mariadb
|
||||
restart: always
|
||||
ports:
|
||||
- '127.0.0.1:3429:3306'
|
||||
networks:
|
||||
- niki-stage
|
||||
expose:
|
||||
- "3306"
|
||||
volumes:
|
||||
- 'niki_stage_mariadb_data:/bitnami/mariadb'
|
||||
environment:
|
||||
MARIADB_USER: ${COMPOSE_MARIADB_USER?error}
|
||||
MARIADB_PASSWORD: ${COMPOSE_MARIADB_UR_PASSWORD?error}
|
||||
MARIADB_DATABASE: ${COMPOSE_MARIADB_DATABASE?error}
|
||||
MARIADB_ROOT_PASSWORD: ${COMPOSE_MARIADB_RT_PASSWORD?error}
|
||||
ALLOW_EMPTY_PASSWORD: no
|
||||
- MARIADB_USER=niki
|
||||
- MARIADB_PASSWORD=${NIKI_STAGE_MARIADB_UR_PASSWORD}
|
||||
- MARIADB_DATABASE=niki_db
|
||||
- MARIADB_ROOT_PASSWORD=${NIKI_STAGE_MARIADB_RT_PASSWORD}
|
||||
- ALLOW_EMPTY_PASSWORD=no
|
||||
healthcheck:
|
||||
test: ['CMD', '/opt/bitnami/scripts/mariadb/healthcheck.sh']
|
||||
interval: 15s
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
COMPOSE_REDIS_PASSWORD=n0ki2agd23
|
|
@ -1,17 +1,18 @@
|
|||
version: '3.9'
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
niki_stage_redis:
|
||||
image: bitnami/redis:6.2
|
||||
container_name: niki_stage_redis
|
||||
restart: always
|
||||
command: redis-server --loglevel warning --protected-mode no
|
||||
ports:
|
||||
- '127.0.0.1:6380:6379'
|
||||
# TODO - remove `--save "" --appendonly no` from command to persist data
|
||||
command: redis-server --loglevel warning --protected-mode no --save "" --appendonly no
|
||||
environment:
|
||||
REDIS_PASSWORD: ${COMPOSE_REDIS_PASSWORD?error}
|
||||
- ALLOW_EMPTY_PASSWORD=yes
|
||||
networks:
|
||||
- niki-stage
|
||||
expose:
|
||||
- "6379"
|
||||
- core
|
||||
volumes:
|
||||
- niki__stage_redis_data:/data
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
version: '3.9'
|
||||
|
||||
services:
|
||||
mysqltest:
|
||||
image: mysql:8.0
|
||||
ports:
|
||||
- "3305:3306"
|
||||
container_name: niki-database-test
|
||||
volumes:
|
||||
- dbdatatest:/var/lib/mysql
|
||||
restart: always
|
||||
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ]
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: 123456
|
||||
MYSQL_DATABASE: test_db
|
||||
MYSQL_USER: testuser
|
||||
MYSQL_PASSWORD: test1234
|
||||
|
||||
niki-redis-test:
|
||||
image: bitnami/redis:6.2
|
||||
container_name: niki-redis-test
|
||||
restart: always
|
||||
ports:
|
||||
- '6381:6379'
|
||||
# TODO - remove `--save "" --appendonly no` from command to persist data
|
||||
command: redis-server --loglevel warning --protected-mode no --save "" --appendonly no
|
||||
environment:
|
||||
- ALLOW_EMPTY_PASSWORD=yes
|
||||
volumes:
|
||||
- niki-redis-data-test:/data
|
||||
|
||||
|
||||
|
||||
volumes:
|
||||
dbdatatest:
|
||||
niki-redis-data-test:
|
||||
|
||||
|
||||
|
||||
# docker-compose -f docker-compose.dev.yaml up -d
|
2834
docs/docs.go
2834
docs/docs.go
File diff suppressed because it is too large
Load Diff
2834
docs/swagger.json
2834
docs/swagger.json
File diff suppressed because it is too large
Load Diff
1830
docs/swagger.yaml
1830
docs/swagger.yaml
File diff suppressed because it is too large
Load Diff
|
@ -20,5 +20,4 @@ const (
|
|||
AdminKindBoxGetAwaitingReturnPermission = AdminPermission("kindbox-get_awaiting_return")
|
||||
AdminKindBoxReturnPermission = AdminPermission("kindbox-return")
|
||||
AdminKindBoxEnumeratePermission = AdminPermission("kindbox-enumerate")
|
||||
AdminKindBoxUpdatePermission = AdminPermission("kindbox-update")
|
||||
)
|
||||
|
|
|
@ -12,5 +12,4 @@ type Benefactor struct {
|
|||
Gender Gender
|
||||
BirthDate time.Time
|
||||
Role UserRole
|
||||
Status BenefactorStatus
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package entity
|
||||
|
||||
type BenefactorStatus string
|
||||
|
||||
const (
|
||||
BenefactorActiveStatus = BenefactorStatus("active")
|
||||
BenefactorInactiveStatus = BenefactorStatus("inactive")
|
||||
)
|
||||
|
||||
var BenefactorStatusStrings = map[BenefactorStatus]string{
|
||||
BenefactorActiveStatus: "active",
|
||||
BenefactorInactiveStatus: "inactive",
|
||||
}
|
||||
|
||||
func (b BenefactorStatus) IsValid() bool {
|
||||
_, ok := BenefactorStatusStrings[b]
|
||||
|
||||
return ok
|
||||
}
|
4
go.mod
4
go.mod
|
@ -1,6 +1,8 @@
|
|||
module git.gocasts.ir/ebhomengo/niki
|
||||
|
||||
go 1.23
|
||||
go 1.22
|
||||
|
||||
toolchain go1.22.4
|
||||
|
||||
require (
|
||||
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package adminserviceparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type Data struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
FirstName string `json:"first_name" example:"John"`
|
||||
LastName string `json:"last_name" example:"Doe"`
|
||||
PhoneNumber string `json:"phone_number" example:"09123456789"`
|
||||
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:"male"`
|
||||
Status entity.AdminStatus `json:"status" example:"active"`
|
||||
}
|
|
@ -1,12 +1,26 @@
|
|||
package adminserviceparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type LoginWithPhoneNumberRequest struct {
|
||||
PhoneNumber string `json:"phone_number" example:"09123456789"`
|
||||
Password string `json:"password" example:"password123"`
|
||||
}
|
||||
|
||||
type LoginWithPhoneNumberResponse struct {
|
||||
Data Data `json:"data"`
|
||||
AdminInfo AdminInfo `json:"admin_info"`
|
||||
Tokens Tokens `json:"tokens"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
||||
type AdminInfo struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
FirstName string `json:"first_name" example:"John"`
|
||||
LastName string `json:"last_name" example:"Doe"`
|
||||
PhoneNumber string `json:"phone_number" example:"09123456789"`
|
||||
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:"male"`
|
||||
Status entity.AdminStatus `json:"status" example:"active"`
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package adminserviceparam
|
||||
|
||||
type RefreshAccessRequest struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
type RefreshAccessResponse struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
}
|
|
@ -15,6 +15,6 @@ type RegisterRequest struct {
|
|||
}
|
||||
|
||||
type RegisterResponse struct {
|
||||
Data Data `json:"data"`
|
||||
Admin entity.Admin `json:"admin"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package adminagentparam
|
||||
|
||||
type GetAllAgentResponse struct {
|
||||
Data []Data `json:"data"`
|
||||
Agents []Agent `json:"agents"`
|
||||
}
|
||||
|
||||
type Data struct {
|
||||
type Agent struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
FirstName string `json:"first_name" example:"John"`
|
||||
LastName string `json:"last_name" example:"Doe"`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package agentkindboxparam
|
||||
package adminkindboxparam
|
||||
|
||||
import (
|
||||
"time"
|
|
@ -1,27 +0,0 @@
|
|||
package adminkindboxparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
ID uint `json:"id"`
|
||||
KindBoxReqID uint `json:"kind_box_req_id"`
|
||||
BenefactorID uint `json:"benefactor_id"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type"`
|
||||
Amount uint `json:"amount"`
|
||||
SerialNumber string `json:"serial_number"`
|
||||
Status entity.KindBoxStatus `json:"status"`
|
||||
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date"`
|
||||
DeliverAddressID uint `json:"deliver_address_id"`
|
||||
SenderAgentID uint `json:"sender_agent_id"`
|
||||
DeliveredAt time.Time `json:"delivered_at"`
|
||||
ReturnReferTimeID uint `json:"return_refer_time_id"`
|
||||
ReturnReferDate time.Time `json:"return_refer_date"`
|
||||
ReturnAddressID uint `json:"return_address_id"`
|
||||
ReceiverAgentID uint `json:"receiver_agent_id"`
|
||||
ReturnedAt time.Time `json:"returned_at"`
|
||||
}
|
|
@ -1,10 +1,12 @@
|
|||
package adminkindboxparam
|
||||
|
||||
import entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type KindBoxGetRequest struct {
|
||||
KindBoxID uint `param:"id"`
|
||||
}
|
||||
|
||||
type KindBoxGetResponse struct {
|
||||
Data Data `json:"data"`
|
||||
entity.KindBox
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package adminkindboxparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
|
@ -11,7 +12,7 @@ type KindBoxGetAllRequest struct {
|
|||
}
|
||||
|
||||
type KindBoxGetAllResponse struct {
|
||||
Data []Data `json:"data"`
|
||||
AllKindBox []entity.KindBox `json:"all_kind_box"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
package adminkindboxparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
import entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
//when kindbox creates, which fields are
|
||||
type KindBoxUpdateRequest struct {
|
||||
KindBoxID uint `json:"-" param:"id" example:"1"` // ID is passed in the URL path
|
||||
BenefactorID uint `json:"benefactor_id" example:"1"`
|
||||
ReturnReferTimeID uint `json:"return_refere_time_id" example:"3"`
|
||||
ReturnReferDate time.Time `json:"return_refer_date" example:"2025-01-02T15:04:05Z"`
|
||||
ReturnAddressID uint `json:"return_address_id" example:"1"`
|
||||
ReceiverAgentID uint `json:"receiver_agent_id" example:"23"`
|
||||
Amount uint `json:"amount" example:"3"`
|
||||
BenefactorID uint
|
||||
KindBoxID uint
|
||||
Amount uint
|
||||
ReceiverAgentID uint
|
||||
SenderAgentID uint
|
||||
SerialNumber string
|
||||
Status entity.KindBoxStatus
|
||||
}
|
||||
|
||||
type KindBoxUpdateResponse struct {
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
KindBox entity.KindBox
|
||||
}
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type KindBoxReqAcceptRequest struct {
|
||||
ID uint `json:"-"`
|
||||
CountAccepted uint `json:"count_accepted"`
|
||||
}
|
||||
|
||||
type KindBoxReqAcceptResponse struct {
|
||||
Data Data `json:"data"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
KindBoxReqID uint `json:"kind_box_req_id"`
|
||||
KindBoxReqStatus entity.KindBoxReqStatus `json:"kind_box_req_status"`
|
||||
CountRequested uint `json:"count_requested"`
|
||||
CountAccepted uint `json:"count_accepted"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date"`
|
||||
DeliverAddressID uint `json:"deliver_address_id"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"time"
|
||||
)
|
||||
import entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type KindBoxReqAddRequest struct {
|
||||
BenefactorID uint `json:"benefactor_id" example:"1"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
|
||||
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date" example:"2025-01-02T15:04:05Z"`
|
||||
DeliverReferTimeID uint `json:"deliver_refer_time_id" example:"1"`
|
||||
CountRequested uint `json:"count_requested" example:"2"`
|
||||
BenefactorID uint `json:"benefactor_id" example:"1"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
|
||||
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
|
||||
DeliverReferDate string `json:"deliver_refer_date" example:"2025-01-02 15:04:05"`
|
||||
CountRequested uint `json:"count_requested" example:"2"`
|
||||
}
|
||||
|
||||
type KindBoxReqAddResponse struct {
|
||||
Data Data `json:"data"`
|
||||
KindBoxReq entity.KindBoxReq
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
ID uint `json:"id"`
|
||||
BenefactorID uint `json:"benefactor_id"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type"`
|
||||
CountRequested uint `json:"count_requested"`
|
||||
CountAccepted uint `json:"count_accepted"`
|
||||
Description string `json:"description"`
|
||||
Status entity.KindBoxReqStatus `json:"status"`
|
||||
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date"`
|
||||
DeliverAddressID uint `json:"deliver_address_id"`
|
||||
SenderAgentID uint `json:"sender_agent_id"`
|
||||
DeliveredAt time.Time `json:"delivered_at"`
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package agentkindboxreqparam
|
||||
package adminkindboxreqparam
|
||||
|
||||
type DeliverKindBoxReqRequest struct {
|
||||
KindBoxReqID uint `json:"-" param:"id"`
|
|
@ -1,10 +1,12 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type GetKindBoxReqRequest struct {
|
||||
KindBoxID uint `param:"id"`
|
||||
}
|
||||
|
||||
type GetKindBoxReqResponse struct {
|
||||
Data Data `json:"data"`
|
||||
entity.KindBoxReq
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
|
@ -11,7 +12,7 @@ type KindBoxReqGetAllRequest struct {
|
|||
}
|
||||
|
||||
type KindBoxReqGetAllResponse struct {
|
||||
Data []Data `json:"data"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
AllKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
type DeliveryAwaitingGetAllRequest struct {
|
||||
Pagination param.PaginationRequest
|
||||
Sort param.SortRequest
|
||||
Filter param.FilterRequest
|
||||
}
|
||||
|
||||
type DeliveryAwaitingGetAllResponse struct {
|
||||
AllAwaitingKindBoxReq []entity.KindBoxReq `json:"all_awaiting_kind_box_req"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
|
@ -1,4 +1,6 @@
|
|||
package agentkindboxreqparam
|
||||
package adminkindboxreqparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type DeliveryAwaitingGetRequest struct {
|
||||
KindBoxReqID uint `param:"id"`
|
||||
|
@ -6,6 +8,6 @@ type DeliveryAwaitingGetRequest struct {
|
|||
}
|
||||
|
||||
type DeliveryAwaitingGetResponse struct {
|
||||
Data Data `json:"data"`
|
||||
entity.KindBoxReq
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
|
@ -1,11 +1,24 @@
|
|||
package adminkindboxreqparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type KindBoxReqRejectRequest struct {
|
||||
ID uint `json:"-"`
|
||||
Description string `json:"description" example:"description"`
|
||||
}
|
||||
|
||||
type KindBoxReqRejectResponse struct {
|
||||
Data Data `json:"data"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
ID uint `json:"id" example:"1"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type" example:"on-table"`
|
||||
CountRequested uint `json:"count_requested" example:"1"`
|
||||
BenefactorID uint `json:"benefactor_id" example:"1"`
|
||||
Status entity.KindBoxReqStatus `json:"status" example:"pending"`
|
||||
Description string `json:"description" example:"description"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date" example:"2025-01-02 15:04:05"`
|
||||
DeliverAddressID uint `json:"deliver_address_id" example:"1"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package agentkindboxparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
ID uint `json:"id"`
|
||||
KindBoxReqID uint `json:"kind_box_req_id"`
|
||||
BenefactorID uint `json:"benefactor_id"`
|
||||
KindBoxType entity.KindBoxType `json:"kind_box_type"`
|
||||
Amount uint `json:"amount"`
|
||||
SerialNumber string `json:"serial_number"`
|
||||
Status entity.KindBoxStatus `json:"status"`
|
||||
DeliverReferTimeID uint `json:"deliver_refer_time_id"`
|
||||
DeliverReferDate time.Time `json:"deliver_refer_date"`
|
||||
DeliverAddressID uint `json:"deliver_address_id"`
|
||||
SenderAgentID uint `json:"sender_agent_id"`
|
||||
DeliveredAt time.Time `json:"delivered_at"`
|
||||
ReturnReferTimeID uint `json:"return_refer_time_id"`
|
||||
ReturnReferDate time.Time `json:"return_refer_date"`
|
||||
ReturnAddressID uint `json:"return_address_id"`
|
||||
ReceiverAgentID uint `json:"receiver_agent_id"`
|
||||
ReturnedAt time.Time `json:"returned_at"`
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package agentkindboxparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type GetKindBoxRequest struct {
|
||||
KindBoxID uint `param:"id"`
|
||||
AgentID uint
|
||||
}
|
||||
|
||||
type GetKindBoxResponse struct {
|
||||
Data Data `json:"data"`
|
||||
entity.KindBox
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package agentkindboxparam
|
||||
|
||||
import (
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"git.gocasts.ir/ebhomengo/niki/param"
|
||||
)
|
||||
|
||||
|
@ -11,7 +12,7 @@ type GetAllRequest struct {
|
|||
}
|
||||
|
||||
type GetAllResponse struct {
|
||||
Data []Data `json:"data"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
FieldErrors map[string]string `json:"field_errors,omitempty"`
|
||||
AllKindBoxes []entity.KindBox `json:"all_kind_boxes"`
|
||||
Pagination param.PaginationResponse `json:"pagination"`
|
||||
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