forked from ebhomengo/niki
Merge pull request 'feat(niki): get benefactor info by admin (#174)' (#192) from stage/ruhollahh01/get-benefactor-by-admin into develop
Reviewed-on: ebhomengo/niki#192
This commit is contained in:
commit
0e92213d2e
2
Makefile
2
Makefile
|
|
@ -23,7 +23,7 @@ format:
|
|||
@golangci-lint run --fix
|
||||
|
||||
build:
|
||||
go build main.go --migrate
|
||||
go build -o niki main.go
|
||||
|
||||
run:
|
||||
go run main.go --migrate
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package adminbenefactorhandler
|
||||
|
||||
import (
|
||||
adminaddressparam "git.gocasts.ir/ebhomengo/niki/param/admin/address"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
|
||||
adminkindboxparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||
adminkindboxreqparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
Benefactor param.Data `json:"benefactor"`
|
||||
Addresses []adminaddressparam.Data `json:"addresses"`
|
||||
KindBoxes []adminkindboxparam.Data `json:"kind_boxes"`
|
||||
KindBoxReqs []adminkindboxreqparam.Data `json:"kind_box_reqs"`
|
||||
}
|
||||
|
||||
type BenefactorAggregatedResponse struct {
|
||||
Data Data `json:"data"`
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package adminbenefactorhandler
|
||||
|
||||
import (
|
||||
params "git.gocasts.ir/ebhomengo/niki/param"
|
||||
adminaddressparam "git.gocasts.ir/ebhomengo/niki/param/admin/address"
|
||||
adminkindboxparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
|
||||
adminkindboxreqparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
|
||||
"net/http"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
|
||||
httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// GetBenefactor godoc
|
||||
// @Summary Get benefactor details by id
|
||||
// @Description This endpoint retrieves details for a specific benefactor.
|
||||
// @Tags Admins Benefactors
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int true "Benefactor ID"
|
||||
// @Success 200 {object} param.GetBenefactorByIDResponse
|
||||
// @Failure 400 {string} "Bad request"
|
||||
// @Failure 401 {string} "invalid or expired jwt"
|
||||
// @Failure 403 {string} "user not allowed"
|
||||
// @Failure 404 {string} "record not found"
|
||||
// @Failure 500 {string} "something went wrong"
|
||||
// @Security AuthBearerAdmin
|
||||
// @Router /admins/benefactors/{id} [get].
|
||||
func (h Handler) GetBenefactor(c echo.Context) error {
|
||||
var req param.GetBenefactorByIDRequest
|
||||
if err := c.Bind(&req); err != nil {
|
||||
return echo.NewHTTPError(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
bnf, err := h.benefactorSvc.GetByID(c.Request().Context(), req)
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
addresses, err := h.addressSvc.GetAll(c.Request().Context(), adminaddressparam.GetAllAddressesRequest{
|
||||
BenefactorID: bnf.Data.ID,
|
||||
})
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
kindBoxes, err := h.kindBoxSvc.GetAll(c.Request().Context(), adminkindboxparam.KindBoxGetAllRequest{
|
||||
Pagination: params.PaginationRequest{
|
||||
PageSize: 50,
|
||||
PageNumber: 1,
|
||||
},
|
||||
Sort: params.SortRequest{
|
||||
Field: "created_at",
|
||||
Direction: params.DescSortDirection,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
kindBoxReqs, err := h.kindBoxReqSvc.GetAll(c.Request().Context(), adminkindboxreqparam.KindBoxReqGetAllRequest{
|
||||
Pagination: params.PaginationRequest{
|
||||
PageSize: 50,
|
||||
PageNumber: 1,
|
||||
},
|
||||
Sort: params.SortRequest{
|
||||
Field: "created_at",
|
||||
Direction: params.DescSortDirection,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
msg, code := httpmsg.Error(err)
|
||||
|
||||
return echo.NewHTTPError(code, msg)
|
||||
}
|
||||
|
||||
resp := BenefactorAggregatedResponse{
|
||||
Data: Data{
|
||||
Benefactor: bnf.Data,
|
||||
Addresses: addresses.Data,
|
||||
KindBoxes: kindBoxes.Data,
|
||||
KindBoxReqs: kindBoxReqs.Data,
|
||||
},
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
|
@ -1,24 +1,36 @@
|
|||
package adminbenefactorhandler
|
||||
|
||||
import (
|
||||
adminaddressservice "git.gocasts.ir/ebhomengo/niki/service/admin/address"
|
||||
authorizeservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization"
|
||||
benefactorservice "git.gocasts.ir/ebhomengo/niki/service/admin/benefactor"
|
||||
adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box"
|
||||
adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req"
|
||||
authservice "git.gocasts.ir/ebhomengo/niki/service/auth"
|
||||
)
|
||||
|
||||
type Handler struct {
|
||||
authSvc authservice.Service
|
||||
benefactorSvc benefactorservice.Service
|
||||
authorizeSvc authorizeservice.Service
|
||||
benefactorSvc benefactorservice.Service
|
||||
addressSvc adminaddressservice.Service
|
||||
kindBoxSvc adminkindboxservice.Service
|
||||
kindBoxReqSvc adminkindboxreqservice.Service
|
||||
}
|
||||
|
||||
func New(authSvc authservice.Service,
|
||||
benefactorSvc benefactorservice.Service,
|
||||
authorizeSvc authorizeservice.Service,
|
||||
benefactorSvc benefactorservice.Service,
|
||||
addressSvc adminaddressservice.Service,
|
||||
kindBoxSvc adminkindboxservice.Service,
|
||||
kindBoxReqSvc adminkindboxreqservice.Service,
|
||||
) Handler {
|
||||
return Handler{
|
||||
authSvc: authSvc,
|
||||
benefactorSvc: benefactorSvc,
|
||||
authorizeSvc: authorizeSvc,
|
||||
benefactorSvc: benefactorSvc,
|
||||
addressSvc: addressSvc,
|
||||
kindBoxSvc: kindBoxSvc,
|
||||
kindBoxReqSvc: kindBoxReqSvc,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ func (h Handler) SetRoutes(e *echo.Echo) {
|
|||
r.Use(middleware.Auth(h.authSvc))
|
||||
|
||||
r.GET("", h.GetAllBenefactor, middleware.AdminAuthorization(h.authorizeSvc, entity.AdminBenefactorGetAllPermission))
|
||||
r.GET("/:id", h.GetBenefactor, middleware.AdminAuthorization(h.authorizeSvc, entity.AdminBenefactorGetPermission))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,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),
|
||||
adminBenefactorHandler: adminbenefactorhandler.New(svc.AdminAuthSvc, svc.AdminBenefactorSvc, svc.AdminAuthorizeSvc),
|
||||
adminBenefactorHandler: adminbenefactorhandler.New(svc.AdminAuthSvc, svc.AdminAuthorizeSvc, svc.AdminBenefactorSvc, svc.AdminAddressSvc, svc.AdminKindBoxSvc, svc.AdminKindBoxReqSvc),
|
||||
adminReferTimeHandler: adminrefertimehandler.New(svc.AdminAuthSvc, svc.AdminReferTimeSvc, svc.AdminAuthorizeSvc),
|
||||
agentKindBoxHandler: agentkindboxhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
agentKindBoxReqHandler: agentkindboxreqhandler.New(svc.AdminAuthSvc, svc.AgentKindBoxReqSvc, svc.AdminAuthorizeSvc, svc.NotificationSvc),
|
||||
|
|
|
|||
75
docs/docs.go
75
docs/docs.go
|
|
@ -184,6 +184,73 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/admins/benefactors/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"AuthBearerAdmin": []
|
||||
}
|
||||
],
|
||||
"description": "This endpoint retrieves details for a specific benefactor.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admins Benefactors"
|
||||
],
|
||||
"summary": "Get benefactor details by id",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Benefactor ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/adminbenefactoreparam.GetBenefactorByIDResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "invalid or expired jwt",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "user not allowed",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "record not found",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "something went wrong",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admins/kindboxes": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -3063,6 +3130,14 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"adminbenefactoreparam.GetBenefactorByIDResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/adminbenefactoreparam.Data"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxparam.AssignReceiverRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -173,6 +173,73 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/admins/benefactors/{id}": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"AuthBearerAdmin": []
|
||||
}
|
||||
],
|
||||
"description": "This endpoint retrieves details for a specific benefactor.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Admins Benefactors"
|
||||
],
|
||||
"summary": "Get benefactor details by id",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Benefactor ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/adminbenefactoreparam.GetBenefactorByIDResponse"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad request",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "invalid or expired jwt",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "user not allowed",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "record not found",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "something went wrong",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/admins/kindboxes": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -3052,6 +3119,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"adminbenefactoreparam.GetBenefactorByIDResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/adminbenefactoreparam.Data"
|
||||
}
|
||||
}
|
||||
},
|
||||
"adminkindboxparam.AssignReceiverRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,11 @@ definitions:
|
|||
status:
|
||||
$ref: '#/definitions/entity.BenefactorStatus'
|
||||
type: object
|
||||
adminbenefactoreparam.GetBenefactorByIDResponse:
|
||||
properties:
|
||||
data:
|
||||
$ref: '#/definitions/adminbenefactoreparam.Data'
|
||||
type: object
|
||||
adminkindboxparam.AssignReceiverRequest:
|
||||
properties:
|
||||
receiver_agent_id:
|
||||
|
|
@ -1152,6 +1157,49 @@ paths:
|
|||
summary: Get all benefactors by admin
|
||||
tags:
|
||||
- Admins Benefactors
|
||||
/admins/benefactors/{id}:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: This endpoint retrieves details for a specific benefactor.
|
||||
parameters:
|
||||
- description: Benefactor ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/adminbenefactoreparam.GetBenefactorByIDResponse'
|
||||
"400":
|
||||
description: Bad request
|
||||
schema:
|
||||
type: string
|
||||
"401":
|
||||
description: invalid or expired jwt
|
||||
schema:
|
||||
type: string
|
||||
"403":
|
||||
description: user not allowed
|
||||
schema:
|
||||
type: string
|
||||
"404":
|
||||
description: record not found
|
||||
schema:
|
||||
type: string
|
||||
"500":
|
||||
description: something went wrong
|
||||
schema:
|
||||
type: string
|
||||
security:
|
||||
- AuthBearerAdmin: []
|
||||
summary: Get benefactor details by id
|
||||
tags:
|
||||
- Admins Benefactors
|
||||
/admins/kindboxes:
|
||||
get:
|
||||
consumes:
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ const (
|
|||
AdminKindBoxReturnPermission = AdminPermission("kindbox-return")
|
||||
AdminKindBoxEnumeratePermission = AdminPermission("kindbox-enumerate")
|
||||
AdminKindBoxUpdatePermission = AdminPermission("kindbox-update")
|
||||
AdminBenefactorGetPermission = AdminPermission("benefactor-get")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package adminaddressparam
|
||||
|
||||
type Data struct {
|
||||
ID uint `json:"id"`
|
||||
PostalCode string `json:"postal_code"`
|
||||
Address string `json:"address"`
|
||||
Name string `json:"name"`
|
||||
Lat float64 `json:"lat"`
|
||||
Lon float64 `json:"lon"`
|
||||
CityID uint `json:"city_id"`
|
||||
ProvinceID uint `json:"province_id"`
|
||||
BenefactorID uint `json:"benefactor_id"`
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package adminaddressparam
|
||||
|
||||
type GetAllAddressesRequest struct {
|
||||
BenefactorID uint
|
||||
}
|
||||
|
||||
type GetAllAddressesResponse struct {
|
||||
Data []Data `json:"data"`
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
package adminbenefactoreparam
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
package adminbenefactoreparam
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
|
||||
type GetBenefactorByIDRequest struct {
|
||||
BenefactorID uint
|
||||
BenefactorID uint `param:"id" example:"1"`
|
||||
}
|
||||
type GetBenefactorByIDResponse struct {
|
||||
entity.Benefactor
|
||||
Data Data `json:"data"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
-- +migrate Up
|
||||
ALTER TABLE `admin_access_controls` MODIFY COLUMN `permission`
|
||||
enum (
|
||||
'admin-register',
|
||||
'kindboxreq-accept',
|
||||
'kindboxreq-reject',
|
||||
'kindboxreq-getall',
|
||||
'kindboxreq-deliver',
|
||||
'kindboxreq-assign_sender_agent',
|
||||
'admin-getall_agent',
|
||||
'kindboxreq-get_awaiting_delivery',
|
||||
'kindbox-get',
|
||||
'kindboxreq-add',
|
||||
'kindbox-assign_receiver_agent',
|
||||
'kindbox-getall',
|
||||
'kindboxreq-update',
|
||||
'kindboxreq-get',
|
||||
'kindbox-get_awaiting_return',
|
||||
'kindbox-return',
|
||||
'kindbox-enumerate',
|
||||
'kindbox-update',
|
||||
'benefactor-getall',
|
||||
'benefactor-get'
|
||||
) NOT NULL;
|
||||
|
||||
INSERT INTO `admin_access_controls` (`actor_id`, `actor_type`, `permission`)
|
||||
VALUES (1, 'role', 'benefactor-get'),
|
||||
(2, 'role', 'benefactor-get');
|
||||
|
||||
-- +migrate Down
|
||||
DELETE
|
||||
FROM `admin_access_controls`;
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package adminaddressservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/address"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) GetAll(ctx context.Context, request param.GetAllAddressesRequest) (param.GetAllAddressesResponse, error) {
|
||||
const op = "adminaddressservice.GetAll"
|
||||
|
||||
addresses, err := s.repo.GetAddresses(ctx, request.BenefactorID)
|
||||
if err != nil {
|
||||
return param.GetAllAddressesResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||||
}
|
||||
|
||||
var data []param.Data
|
||||
for _, address := range addresses {
|
||||
data = append(data, param.Data{
|
||||
ID: address.ID,
|
||||
PostalCode: address.PostalCode,
|
||||
Address: address.Address,
|
||||
Name: address.Name,
|
||||
Lat: address.Lat,
|
||||
Lon: address.Lon,
|
||||
CityID: address.CityID,
|
||||
ProvinceID: address.ProvinceID,
|
||||
BenefactorID: address.BenefactorID,
|
||||
})
|
||||
}
|
||||
|
||||
return param.GetAllAddressesResponse{Data: data}, nil
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
type Repository interface {
|
||||
GetAddressByID(ctx context.Context, id uint) (entity.Address, error)
|
||||
GetAddresses(ctx context.Context, benefactorID uint) ([]entity.Address, error)
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package adminbenefactorservice
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
|
@ -15,7 +14,19 @@ func (s Service) GetByID(ctx context.Context, req param.GetBenefactorByIDRequest
|
|||
return param.GetBenefactorByIDResponse{}, richerror.New(op).WithErr(gErr)
|
||||
}
|
||||
|
||||
return param.GetBenefactorByIDResponse{Benefactor: bnf}, nil
|
||||
return param.GetBenefactorByIDResponse{
|
||||
Data: param.Data{
|
||||
ID: bnf.ID,
|
||||
FirstName: bnf.FirstName,
|
||||
LastName: bnf.LastName,
|
||||
PhoneNumber: bnf.PhoneNumber,
|
||||
Description: bnf.Description,
|
||||
Email: bnf.Email,
|
||||
Gender: bnf.Gender,
|
||||
BirthDate: bnf.BirthDate,
|
||||
Status: bnf.Status,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s Service) BenefactorExistByID(ctx context.Context, req param.BenefactorExistByIDRequest) (param.BenefactorExistByIDResponse, error) {
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ func (s Service) KindBoxEnumerated(req params.NotificationKindBoxEnumerated) {
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxEnumerated, bnf.FirstName, kb.Data.SerialNumber, kb.Data.Amount))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxEnumerated, bnf.Data.FirstName, kb.Data.SerialNumber, kb.Data.Amount))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ func (s Service) KindBoxRegisteredEmptyingRequest(req params.NotificationKindBox
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxRegistedEmptyingRequest, bnf.FirstName))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxRegistedEmptyingRequest, bnf.Data.FirstName))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ func (s Service) KindBoxReturned(req param.NotificationKindBoxReturned) {
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReturned, bnf.FirstName, kb.Data.SerialNumber))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReturned, bnf.Data.FirstName, kb.Data.SerialNumber))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ func (s Service) KindBoxReqAccepted(req params.NotificationKindBoxReqAccepted) {
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAccepted, bnf.FirstName))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAccepted, bnf.Data.FirstName))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,5 @@ func (s Service) KindBoxReqAdded(req params.NotificationKindBoxReqAdded) {
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAdded, bnf.FirstName))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqAdded, bnf.Data.FirstName))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ func (s Service) KindBoxReqDelivered(req param.NotificationKindBoxReqDelivered)
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqDelivered, bnf.FirstName))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqDelivered, bnf.Data.FirstName))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,5 @@ func (s Service) KindBoxReqRejected(req params.NotificationKindBoxReqRejected) {
|
|||
if gErr != nil {
|
||||
fmt.Println(fmt.Errorf("error(%s):%w", op, gErr))
|
||||
}
|
||||
s.smsAdapter.Send(bnf.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqRejected, bnf.FirstName, req.Description))
|
||||
s.smsAdapter.Send(bnf.Data.PhoneNumber, fmt.Sprintf(smsmsg.SmsMsgKindBoxReqRejected, bnf.Data.FirstName, req.Description))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ type Service struct {
|
|||
AdminAuthSvc auth.Service
|
||||
AdminKindBoxSvc adminkindboxservice.Service
|
||||
AdminKindBoxReqSvc adminkindboxreqservice.Service
|
||||
AdminAddressSvc adminaddressservice.Service
|
||||
AdminAuthorizeSvc adminauthorizationservice.Service
|
||||
AdminSvc adminservice.Service
|
||||
AdminAgentSvc adminagentservice.Service
|
||||
|
|
@ -116,6 +117,7 @@ func New(cfg config.Config, db *mysql.DB, rds *redis.Adapter, smsAdapter smscont
|
|||
AdminAuthSvc: AdminAuthSvc,
|
||||
AdminKindBoxSvc: AdminKindBoxSvc,
|
||||
AdminKindBoxReqSvc: AdminKindBoxReqSvc,
|
||||
AdminAddressSvc: AdminAddressSvc,
|
||||
AdminAuthorizeSvc: AdminAuthorizeSvc,
|
||||
AdminSvc: AdminSvc,
|
||||
AdminAgentSvc: AdminAgentSvc,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func (v Validator) ValidateGetAll(req param.KindBoxGetAllRequest) (map[string]st
|
|||
const op = "adminkindboxvalidator.ValidateGetAll"
|
||||
|
||||
validFields := []string{
|
||||
"id", "kind_box_req_id", "benefactor_id", "kind_box_type", "amount", "serial_number",
|
||||
"id", "created_at", "kind_box_req_id", "benefactor_id", "kind_box_type", "amount", "serial_number",
|
||||
"status", "deliver_refer_time_id", "deliver_refer_date", "deliver_address_id", "sender_agent_id",
|
||||
"delivered_at", "return_refer_time_id", "return_refer_date",
|
||||
"return_address_id", "receiver_agent_id", "returned_at",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import (
|
|||
func (v Validator) ValidateGetAll(req param.KindBoxReqGetAllRequest) (map[string]string, error) {
|
||||
const op = "adminkindboxreqvalidator.ValidateGetAll"
|
||||
validFields := []string{
|
||||
"id", "benefactor_id", "sender_agent_id",
|
||||
"id", "created_at", "benefactor_id", "sender_agent_id",
|
||||
"kind_box_type", "status", "count_requested", "count_accepted",
|
||||
"deliver_refer_time_id", "deliver_refer_date",
|
||||
"deliver_address_id", "delivered_at",
|
||||
|
|
|
|||
Loading…
Reference in New Issue