diff --git a/Makefile b/Makefile index d3519f1e..43ec50c5 100644 --- a/Makefile +++ b/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 diff --git a/delivery/http_server/admin/benefactor/dto.go b/delivery/http_server/admin/benefactor/dto.go new file mode 100644 index 00000000..b4b28dd0 --- /dev/null +++ b/delivery/http_server/admin/benefactor/dto.go @@ -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"` +} diff --git a/delivery/http_server/admin/benefactor/get.go b/delivery/http_server/admin/benefactor/get.go new file mode 100644 index 00000000..122c5254 --- /dev/null +++ b/delivery/http_server/admin/benefactor/get.go @@ -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) +} diff --git a/delivery/http_server/admin/benefactor/handler.go b/delivery/http_server/admin/benefactor/handler.go index 29e91c95..861be766 100644 --- a/delivery/http_server/admin/benefactor/handler.go +++ b/delivery/http_server/admin/benefactor/handler.go @@ -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, } } diff --git a/delivery/http_server/admin/benefactor/route.go b/delivery/http_server/admin/benefactor/route.go index 28c8cabd..b38be80d 100644 --- a/delivery/http_server/admin/benefactor/route.go +++ b/delivery/http_server/admin/benefactor/route.go @@ -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)) } diff --git a/delivery/http_server/server.go b/delivery/http_server/server.go index 29b61e80..10cc69f3 100644 --- a/delivery/http_server/server.go +++ b/delivery/http_server/server.go @@ -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), diff --git a/docs/docs.go b/docs/docs.go index 5a35ab0c..ab6f7171 100644 --- a/docs/docs.go +++ b/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": { diff --git a/docs/swagger.json b/docs/swagger.json index c6341ee6..b0add356 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -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": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 944409be..8db781b9 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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: diff --git a/entity/admin_permission.go b/entity/admin_permission.go index 5ec9a9a5..0f9a0b8a 100644 --- a/entity/admin_permission.go +++ b/entity/admin_permission.go @@ -22,4 +22,5 @@ const ( AdminKindBoxReturnPermission = AdminPermission("kindbox-return") AdminKindBoxEnumeratePermission = AdminPermission("kindbox-enumerate") AdminKindBoxUpdatePermission = AdminPermission("kindbox-update") + AdminBenefactorGetPermission = AdminPermission("benefactor-get") ) diff --git a/param/admin/address/data.go b/param/admin/address/data.go new file mode 100644 index 00000000..a56fec52 --- /dev/null +++ b/param/admin/address/data.go @@ -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"` +} diff --git a/param/admin/address/get_all.go b/param/admin/address/get_all.go new file mode 100644 index 00000000..cbd0a812 --- /dev/null +++ b/param/admin/address/get_all.go @@ -0,0 +1,9 @@ +package adminaddressparam + +type GetAllAddressesRequest struct { + BenefactorID uint +} + +type GetAllAddressesResponse struct { + Data []Data `json:"data"` +} diff --git a/param/admin/benefactor/data.go b/param/admin/benefactor/data.go index e846e075..d0aec69a 100644 --- a/param/admin/benefactor/data.go +++ b/param/admin/benefactor/data.go @@ -1,9 +1,8 @@ package adminbenefactoreparam import ( - "time" - "git.gocasts.ir/ebhomengo/niki/entity" + "time" ) type Data struct { diff --git a/param/admin/benefactor/get.go b/param/admin/benefactor/get.go index 67f3e852..dc028ccf 100644 --- a/param/admin/benefactor/get.go +++ b/param/admin/benefactor/get.go @@ -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"` } diff --git a/repository/mysql/migration/1727209869_add_get_benefactor_access.sql b/repository/mysql/migration/1727209869_add_get_benefactor_access.sql new file mode 100644 index 00000000..214f5ec6 --- /dev/null +++ b/repository/mysql/migration/1727209869_add_get_benefactor_access.sql @@ -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`; \ No newline at end of file diff --git a/service/admin/address/get_all.go b/service/admin/address/get_all.go new file mode 100644 index 00000000..7e220c3d --- /dev/null +++ b/service/admin/address/get_all.go @@ -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 +} diff --git a/service/admin/address/service.go b/service/admin/address/service.go index 14c9fb0f..b3af6155 100644 --- a/service/admin/address/service.go +++ b/service/admin/address/service.go @@ -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 { diff --git a/service/admin/benefactor/get.go b/service/admin/benefactor/get.go index 1f84275a..f652a3ef 100644 --- a/service/admin/benefactor/get.go +++ b/service/admin/benefactor/get.go @@ -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) { diff --git a/service/notification/kindbox_enumerated.go b/service/notification/kindbox_enumerated.go index ecfbb9b7..e916131b 100644 --- a/service/notification/kindbox_enumerated.go +++ b/service/notification/kindbox_enumerated.go @@ -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)) } diff --git a/service/notification/kindbox_registered_emptying_request.go b/service/notification/kindbox_registered_emptying_request.go index 9177a3f1..1292743c 100644 --- a/service/notification/kindbox_registered_emptying_request.go +++ b/service/notification/kindbox_registered_emptying_request.go @@ -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)) } diff --git a/service/notification/kindbox_returned.go b/service/notification/kindbox_returned.go index 747fa4d6..65e3dfeb 100644 --- a/service/notification/kindbox_returned.go +++ b/service/notification/kindbox_returned.go @@ -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)) } diff --git a/service/notification/kindboxreq_accepted.go b/service/notification/kindboxreq_accepted.go index 11e14132..76db87eb 100644 --- a/service/notification/kindboxreq_accepted.go +++ b/service/notification/kindboxreq_accepted.go @@ -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)) } diff --git a/service/notification/kindboxreq_added.go b/service/notification/kindboxreq_added.go index 9a8155f5..7c9544de 100644 --- a/service/notification/kindboxreq_added.go +++ b/service/notification/kindboxreq_added.go @@ -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)) } diff --git a/service/notification/kindboxreq_delivered.go b/service/notification/kindboxreq_delivered.go index 18c336e1..0082460d 100644 --- a/service/notification/kindboxreq_delivered.go +++ b/service/notification/kindboxreq_delivered.go @@ -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)) } diff --git a/service/notification/kindboxreq_rejected.go b/service/notification/kindboxreq_rejected.go index 708bc2ec..18dd62d3 100644 --- a/service/notification/kindboxreq_rejected.go +++ b/service/notification/kindboxreq_rejected.go @@ -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)) } diff --git a/service/service.go b/service/service.go index b75bb027..5ed3fe2c 100644 --- a/service/service.go +++ b/service/service.go @@ -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, diff --git a/validator/admin/kind_box/get_all.go b/validator/admin/kind_box/get_all.go index 0ab8979a..cf6054a1 100644 --- a/validator/admin/kind_box/get_all.go +++ b/validator/admin/kind_box/get_all.go @@ -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", diff --git a/validator/admin/kind_box_req/get_all.go b/validator/admin/kind_box_req/get_all.go index edd1a055..a5679f0e 100644 --- a/validator/admin/kind_box_req/get_all.go +++ b/validator/admin/kind_box_req/get_all.go @@ -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",