fix(niki): Completion of swagger

This commit is contained in:
mehdi 2024-05-15 11:08:39 +03:30
parent b039bfcb95
commit 51693db30d
19 changed files with 4164 additions and 24 deletions

View File

@ -8,6 +8,15 @@ import (
"github.com/labstack/echo/v4"
)
// LoginByPhoneNumber godoc
// @Summary Login By PhoneNumber admin
// @Tags admin
// @Accept json
// @Produce json
// @Param Request body adminserviceparam.LoginWithPhoneNumberRequest true "Login By PhoneNumber admin"
// @Success 200 {object} adminserviceparam.LoginWithPhoneNumberResponse
// @Failure 400 {string} "Bad request"
// @Router /admins/login-by-phone [post]
func (h Handler) LoginByPhoneNumber(c echo.Context) error {
var req adminserviceparam.LoginWithPhoneNumberRequest

View File

@ -8,6 +8,15 @@ import (
"github.com/labstack/echo/v4"
)
// Register godoc
// @Summary super-admin register admin
// @Tags admin
// @Accept json
// @Produce json
// @Param Request body adminserviceparam.RegisterRequest true "super-admin register admin"
// @Success 200 {object} adminserviceparam.RegisterResponse
// @Failure 400 {string} "Bad request"
// @Router /admins/register [post]
func (h Handler) Register(c echo.Context) error {
var req adminserviceparam.RegisterRequest

View File

@ -10,6 +10,17 @@ import (
"github.com/labstack/echo/v4"
)
// Accept godoc
// @Summary admin Accept kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param id path int true "Id"
// @Param Request body param.KindBoxReqAcceptRequest true "admin Accept kindboxreq"
// @Success 200 {object} param.KindBoxReqAcceptResponse
// @Failure 400 {string} "Bad request"
// @Router /admin/kindboxreqs/accept-kind-box-req/{id} [patch]
// @Security AuthBearerAdmin
func (h Handler) Accept(c echo.Context) error {
var req param.KindBoxReqAcceptRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -10,6 +10,17 @@ import (
echo "github.com/labstack/echo/v4"
)
// AssignSenderAgent godoc
// @Summary admin AssignSenderAgent kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param id path int true "Id"
// @Param Request body param.AssignSenderRequest true "admin AssignSenderAgent kindboxreq"
// @Success 200 {object} param.DeliverKindBoxReqResponse
// @Failure 400 {string} "Bad request"
// @Router /admin/kindboxreqs/assign-sender-agent/{id} [patch]
// @Security AuthBearerAdmin
func (h Handler) AssignSenderAgent(c echo.Context) error {
var req param.AssignSenderRequest

View File

@ -10,6 +10,16 @@ import (
echo "github.com/labstack/echo/v4"
)
// Deliver godoc
// @Summary admin Deliver kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param id path int true "Id"
// @Success 200 {object} param.DeliverKindBoxReqResponse
// @Failure 400 {string} "Bad request"
// @Router /admin/kindboxreqs/deliver-kind-box-req/{id} [patch]
// @Security AuthBearerAdmin
func (h Handler) Deliver(c echo.Context) error {
var req param.DeliverKindBoxReqRequest

View File

@ -10,6 +10,17 @@ import (
echo "github.com/labstack/echo/v4"
)
// GetAll godoc
// @Summary admin get All kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param page_number query int false "page_number"
// @Param page_size query int false "page_size"
// @Success 200 {object} param.KindBoxReqGetAllResponse
// @Failure 400 {string} "Bad request"
// @Router /admin/kindboxreqs/ [get]
// @Security AuthBearerAdmin
func (h Handler) GetAll(c echo.Context) error {
var req param.KindBoxReqGetAllRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -10,6 +10,17 @@ import (
"github.com/labstack/echo/v4"
)
// Reject godoc
// @Summary admin Reject kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param id path int true "Id"
// @Param Request body param.KindBoxReqRejectRequest true "admin Reject kindboxreq"
// @Success 200 {object} param.KindBoxReqRejectResponse
// @Failure 400 {string} "Bad request"
// @Router /admin/kindboxreqs/reject-kind-box-req/{id} [patch]
// @Security AuthBearerAdmin
func (h Handler) Reject(c echo.Context) error {
var req param.KindBoxReqRejectRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,14 +11,14 @@ import (
// AddAddress godoc
// @Summary Add Address benefactor
// @Tags benefactor
// @Tags address
// @Accept json
// @Produce json
// @Param Request body param.BenefactorAddAddressRequest true "Add Address benefactor"
// @Success 200 {object} param.BenefactorAddAddressResponse
// @Failure 400 {string} "Bad request"
// @Router /address/ [post]
// @Security AuthBearer
// @Security AuthBearerBenefactor
func (h Handler) AddAddress(c echo.Context) error {
req := param.BenefactorAddAddressRequest{}
if bErr := c.Bind(&req); bErr != nil {

View File

@ -10,7 +10,7 @@ import (
// GetAllCities godoc
// @Summary get all cities
// @Tags benefactor
// @Tags address
// @Accept json
// @Produce json
// @Success 200 {object} addressparam.GetAllCitiesResponse

View File

@ -10,7 +10,7 @@ import (
// GetAllProvinces godoc
// @Summary get all provinces
// @Tags benefactor
// @Tags address
// @Accept json
// @Produce json
// @Success 200 {object} addressparam.GetAllProvincesResponse

View File

@ -8,6 +8,16 @@ import (
echo "github.com/labstack/echo/v4"
)
// Get godoc
// @Summary benefactor get kindbox
// @Tags kindbox
// @Accept json
// @Produce json
// @Param id path int true "id"
// @Success 200 {object} param.KindBoxGetResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactor/kindboxes/{id} [get]
// @Security AuthBearerBenefactor
func (h Handler) Get(c echo.Context) error {
var req param.KindBoxGetRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -8,6 +8,15 @@ import (
echo "github.com/labstack/echo/v4"
)
// GetAll godoc
// @Summary benefactor get All kindbox
// @Tags kindbox
// @Accept json
// @Produce json
// @Success 200 {object} param.KindBoxGetResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactor/kindboxes/ [get]
// @Security AuthBearerBenefactor
func (h Handler) GetAll(c echo.Context) error {
var req param.KindBoxGetAllRequest
if bErr := c.Bind(&req); bErr != nil {

View File

@ -11,6 +11,16 @@ import (
echo "github.com/labstack/echo/v4"
)
// Add godoc
// @Summary benefactor Add kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param Request body param.KindBoxReqAddRequest true "benefactor Add kindboxreq"
// @Success 200 {object} param.KindBoxReqAddResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactor/kindboxreqs/ [post]
// @Security AuthBearerBenefactor
func (h Handler) Add(c echo.Context) error {
req := param.KindBoxReqAddRequest{}
if err := c.Bind(&req); err != nil {

View File

@ -9,6 +9,16 @@ import (
"github.com/labstack/echo/v4"
)
// Get godoc
// @Summary benefactor get kindboxreq
// @Tags kindboxreq
// @Accept json
// @Produce json
// @Param id path int true "Id"
// @Success 200 {object} param.KindBoxReqGetResponse
// @Failure 400 {string} "Bad request"
// @Router /benefactor/kindboxreqs/{id} [get]
// @Security AuthBearerBenefactor
func (h Handler) Get(c echo.Context) error {
var req param.KindBoxReqGetRequest
if bErr := echo.PathParamsBinder(c).Uint("id", &req.KindBoxReqID).BindError(); bErr != nil {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,119 @@ definitions:
$ref: '#/definitions/entity.Province'
type: array
type: object
adminkindboxreqparam.AssignSenderRequest:
properties:
kind_box_req_id:
type: integer
sender_agent_id:
type: integer
type: object
adminkindboxreqparam.DeliverKindBoxReqResponse:
type: object
adminkindboxreqparam.KindBoxReqAcceptRequest:
properties:
count_accepted:
type: integer
id:
type: integer
type: object
adminkindboxreqparam.KindBoxReqAcceptResponse:
properties:
count_accepted:
type: integer
count_requested:
type: integer
deliver_address_id:
type: integer
deliver_refer_date:
type: string
kind_box_req_id:
type: integer
kind_box_req_status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object
adminkindboxreqparam.KindBoxReqGetAllResponse:
properties:
allKindBoxReq:
items:
$ref: '#/definitions/entity.KindBoxReq'
type: array
pagination:
$ref: '#/definitions/param.PaginationResponse'
type: object
adminkindboxreqparam.KindBoxReqRejectRequest:
properties:
description:
type: string
id:
type: integer
type: object
adminkindboxreqparam.KindBoxReqRejectResponse:
properties:
benefactor_id:
type: integer
count_requested:
type: integer
deliver_address_id:
type: integer
deliver_refer_date:
type: string
description:
type: string
id:
type: integer
kind_box_type:
$ref: '#/definitions/entity.KindBoxType'
status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object
adminserviceparam.LoginWithPhoneNumberRequest:
properties:
password:
type: string
phone_number:
type: string
type: object
adminserviceparam.LoginWithPhoneNumberResponse:
properties:
admin:
$ref: '#/definitions/entity.Admin'
tokens:
$ref: '#/definitions/adminserviceparam.Tokens'
type: object
adminserviceparam.RegisterRequest:
properties:
description:
type: string
email:
type: string
first_name:
type: string
gender:
$ref: '#/definitions/entity.Gender'
last_name:
type: string
password:
type: string
phone_number:
type: string
role:
$ref: '#/definitions/entity.AdminRole'
status:
$ref: '#/definitions/entity.AdminStatus'
type: object
adminserviceparam.RegisterResponse:
properties:
admin:
$ref: '#/definitions/entity.Admin'
type: object
adminserviceparam.Tokens:
properties:
access_token:
type: string
refresh_token:
type: string
type: object
benefactoreparam.BenefactroInfo:
properties:
first_name:
@ -95,6 +208,82 @@ definitions:
refresh_token:
type: string
type: object
benefactorkindboxparam.KindBoxGetResponse:
properties:
amount:
type: integer
benefactorID:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliveredAt:
type: string
id:
type: integer
kindBoxReqID:
type: integer
receiverAgentID:
type: integer
returnAddressID:
type: integer
returnReferDate:
type: string
returnedAt:
type: string
senderAgentID:
type: integer
serialNumber:
type: string
status:
$ref: '#/definitions/entity.KindBoxStatus'
type:
$ref: '#/definitions/entity.KindBoxType'
type: object
benefactorkindboxreqparam.KindBoxReqAddRequest:
properties:
benefactor_id:
type: integer
count_requested:
type: integer
deliver_address_id:
type: integer
deliver_refer_date:
type: string
type_id:
$ref: '#/definitions/entity.KindBoxType'
type: object
benefactorkindboxreqparam.KindBoxReqAddResponse:
properties:
kind_box_req:
$ref: '#/definitions/entity.KindBoxReq'
type: object
benefactorkindboxreqparam.KindBoxReqGetResponse:
properties:
benefactorID:
type: integer
countAccepted:
type: integer
countRequested:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliveredAt:
type: string
description:
type: string
id:
type: integer
kindBoxType:
$ref: '#/definitions/entity.KindBoxType'
senderAgentID:
type: integer
status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object
entity.Address:
properties:
address:
@ -116,6 +305,47 @@ definitions:
provinceID:
type: integer
type: object
entity.Admin:
properties:
description:
type: string
email:
type: string
firstName:
type: string
gender:
$ref: '#/definitions/entity.Gender'
id:
type: integer
lastName:
type: string
password:
type: string
phoneNumber:
type: string
role:
$ref: '#/definitions/entity.AdminRole'
status:
$ref: '#/definitions/entity.AdminStatus'
type: object
entity.AdminRole:
enum:
- 1
- 2
- 3
type: integer
x-enum-varnames:
- AdminSuperAdminRole
- AdminAdminRole
- AdminAgentRole
entity.AdminStatus:
enum:
- 1
- 2
type: integer
x-enum-varnames:
- AdminActiveStatus
- AdminInactiveStatus
entity.City:
properties:
id:
@ -125,6 +355,77 @@ definitions:
provinceID:
type: integer
type: object
entity.Gender:
enum:
- 1
- 2
type: integer
x-enum-varnames:
- MaleGender
- FemaleGender
entity.KindBoxReq:
properties:
benefactorID:
type: integer
countAccepted:
type: integer
countRequested:
type: integer
deliverAddressID:
type: integer
deliverReferDate:
type: string
deliveredAt:
type: string
description:
type: string
id:
type: integer
kindBoxType:
$ref: '#/definitions/entity.KindBoxType'
senderAgentID:
type: integer
status:
$ref: '#/definitions/entity.KindBoxReqStatus'
type: object
entity.KindBoxReqStatus:
enum:
- 1
- 2
- 3
- 4
- 5
type: integer
x-enum-varnames:
- KindBoxReqPendingStatus
- KindBoxReqAcceptedStatus
- KindBoxReqAssignedSenderAgentStatus
- KindBoxReqRejectedStatus
- KindBoxReqDeliveredStatus
entity.KindBoxStatus:
enum:
- 1
- 2
- 3
- 4
- 5
type: integer
x-enum-varnames:
- KindBoxDeliveredStatus
- KindBoxReadyToReturnStatus
- KindBoxAssignedReceiverAgentStatus
- KindBoxReturnedStatus
- KindBoxEnumeratedStatus
entity.KindBoxType:
enum:
- 1
- 2
- 3
type: integer
x-enum-varnames:
- KindBoxOnTable
- KindBoxCylindrical
- KindBoxStandUp
entity.Province:
properties:
id:
@ -132,6 +433,15 @@ definitions:
name:
type: string
type: object
param.PaginationResponse:
properties:
pageNumber:
type: integer
pageSize:
type: integer
total:
type: integer
type: object
info:
contact: {}
paths:
@ -158,10 +468,10 @@ paths:
schema:
type: string
security:
- AuthBearer: []
- AuthBearerBenefactor: []
summary: Add Address benefactor
tags:
- benefactor
- address
/address/cities:
get:
consumes:
@ -179,7 +489,7 @@ paths:
type: string
summary: get all cities
tags:
- benefactor
- address
/address/provinces:
get:
consumes:
@ -197,7 +507,307 @@ paths:
type: string
summary: get all provinces
tags:
- benefactor
- address
/admin/kindboxreqs/:
get:
consumes:
- application/json
parameters:
- description: page_number
in: query
name: page_number
type: integer
- description: page_size
in: query
name: page_size
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminkindboxreqparam.KindBoxReqGetAllResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerAdmin: []
summary: admin get All kindboxreq
tags:
- kindboxreq
/admin/kindboxreqs/accept-kind-box-req/{id}:
patch:
consumes:
- application/json
parameters:
- description: Id
in: path
name: id
required: true
type: integer
- description: admin Accept kindboxreq
in: body
name: Request
required: true
schema:
$ref: '#/definitions/adminkindboxreqparam.KindBoxReqAcceptRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminkindboxreqparam.KindBoxReqAcceptResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerAdmin: []
summary: admin Accept kindboxreq
tags:
- kindboxreq
/admin/kindboxreqs/assign-sender-agent/{id}:
patch:
consumes:
- application/json
parameters:
- description: Id
in: path
name: id
required: true
type: integer
- description: admin AssignSenderAgent kindboxreq
in: body
name: Request
required: true
schema:
$ref: '#/definitions/adminkindboxreqparam.AssignSenderRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminkindboxreqparam.DeliverKindBoxReqResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerAdmin: []
summary: admin AssignSenderAgent kindboxreq
tags:
- kindboxreq
/admin/kindboxreqs/deliver-kind-box-req/{id}:
patch:
consumes:
- application/json
parameters:
- description: Id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminkindboxreqparam.DeliverKindBoxReqResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerAdmin: []
summary: admin Deliver kindboxreq
tags:
- kindboxreq
/admin/kindboxreqs/reject-kind-box-req/{id}:
patch:
consumes:
- application/json
parameters:
- description: Id
in: path
name: id
required: true
type: integer
- description: admin Reject kindboxreq
in: body
name: Request
required: true
schema:
$ref: '#/definitions/adminkindboxreqparam.KindBoxReqRejectRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminkindboxreqparam.KindBoxReqRejectResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerAdmin: []
summary: admin Reject kindboxreq
tags:
- kindboxreq
/admins/login-by-phone:
post:
consumes:
- application/json
parameters:
- description: Login By PhoneNumber admin
in: body
name: Request
required: true
schema:
$ref: '#/definitions/adminserviceparam.LoginWithPhoneNumberRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminserviceparam.LoginWithPhoneNumberResponse'
"400":
description: Bad request
schema:
type: string
summary: Login By PhoneNumber admin
tags:
- admin
/admins/register:
post:
consumes:
- application/json
parameters:
- description: super-admin register admin
in: body
name: Request
required: true
schema:
$ref: '#/definitions/adminserviceparam.RegisterRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/adminserviceparam.RegisterResponse'
"400":
description: Bad request
schema:
type: string
summary: super-admin register admin
tags:
- admin
/benefactor/kindboxes/:
get:
consumes:
- application/json
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/benefactorkindboxparam.KindBoxGetResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerBenefactor: []
summary: benefactor get All kindbox
tags:
- kindbox
/benefactor/kindboxes/{id}:
get:
consumes:
- application/json
parameters:
- description: id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/benefactorkindboxparam.KindBoxGetResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerBenefactor: []
summary: benefactor get kindbox
tags:
- kindbox
/benefactor/kindboxreqs/:
post:
consumes:
- application/json
parameters:
- description: benefactor Add kindboxreq
in: body
name: Request
required: true
schema:
$ref: '#/definitions/benefactorkindboxreqparam.KindBoxReqAddRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/benefactorkindboxreqparam.KindBoxReqAddResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerBenefactor: []
summary: benefactor Add kindboxreq
tags:
- kindboxreq
/benefactor/kindboxreqs/{id}:
get:
consumes:
- application/json
parameters:
- description: Id
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/benefactorkindboxreqparam.KindBoxReqGetResponse'
"400":
description: Bad request
schema:
type: string
security:
- AuthBearerBenefactor: []
summary: benefactor get kindboxreq
tags:
- kindboxreq
/benefactor/login-register:
post:
consumes:
@ -249,8 +859,12 @@ paths:
tags:
- benefactor
securityDefinitions:
AuthBearer:
AuthBearerAdmin:
in: header
name: Authorization
name: Authorization admin
type: apiKey
AuthBearerBenefactor:
in: header
name: Authorization Benefactor
type: apiKey
swagger: "2.0"

View File

@ -26,9 +26,12 @@ func parseFlags() bool {
return *migrateFlag
}
// @securityDefinitions.apikey AuthBearer
// @securityDefinitions.apikey AuthBearerBenefactor
// @in header
// @name Authorization
// @name Authorization Benefactor
// @securityDefinitions.apikey AuthBearerAdmin
// @in header
// @name Authorization admin
func main() {
migrate := parseFlags()

1520
mise.log

File diff suppressed because it is too large Load Diff