forked from ebhomengo/niki
fix(service): add ctx to kind_box and kind_box_req services
This commit is contained in:
parent
7d76ea2d50
commit
72bdffc962
|
@ -1,14 +1,16 @@
|
|||
package kindboxservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) Add(req param.KindBoxAddRequest) (param.KindBoxAddResponse, error) {
|
||||
func (s Service) Add(ctx context.Context, req param.KindBoxAddRequest) (param.KindBoxAddResponse, error) {
|
||||
const op = "kindboxservice.Add"
|
||||
kindBox, err := s.repo.AddKindBox(entity.KindBox{
|
||||
kindBox, err := s.repo.AddKindBox(ctx, entity.KindBox{
|
||||
KindBoxReqID: req.KindBoxReqID,
|
||||
SenderID: req.SenderID,
|
||||
SerialNumber: req.SerialNumber,
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package kindboxservice
|
||||
|
||||
import param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func (s Service) Delete(param.KindBoxDeleteRequest) error {
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
)
|
||||
|
||||
func (s Service) Delete(ctx context.Context, req param.KindBoxDeleteRequest) error {
|
||||
// some code
|
||||
panic("not implemented")
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package kindboxservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) GetAll() (param.KindBoxGetAllResponse, error) {
|
||||
func (s Service) GetAll(ctx context.Context) (param.KindBoxGetAllResponse, error) {
|
||||
const op = "kindboxservice.GetAll"
|
||||
allKindBox, err := s.repo.GetAllKindBox()
|
||||
allKindBox, err := s.repo.GetAllKindBox(ctx)
|
||||
if err != nil {
|
||||
return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package kindboxservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) GetByID(req param.KindBoxGetByIDRequest) (param.KindBoxGetByIDResponse, error) {
|
||||
func (s Service) GetByID(ctx context.Context, req param.KindBoxGetByIDRequest) (param.KindBoxGetByIDResponse, error) {
|
||||
const op = "kindboxservice.GetByID"
|
||||
kindBox, err := s.repo.GetKindBoxByID(req.KindBoxID)
|
||||
kindBox, err := s.repo.GetKindBoxByID(ctx, req.KindBoxID)
|
||||
if err != nil {
|
||||
return param.KindBoxGetByIDResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package kindboxservice
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type Repository interface {
|
||||
AddKindBox(kindBox entity.KindBox) (entity.KindBox, error)
|
||||
EditKindBox(kindBoxID uint, kindBoxInput entity.KindBox) (entity.KindBox, error)
|
||||
DeleteKindBox(kindBoxID uint) error
|
||||
GetAllKindBox() ([]entity.KindBox, error)
|
||||
GetKindBoxByID(kindBox uint) (entity.KindBox, error)
|
||||
AddKindBox(ctx context.Context, kindBox entity.KindBox) (entity.KindBox, error)
|
||||
EditKindBox(ctx context.Context, kindBoxID uint, kindBoxInput entity.KindBox) (entity.KindBox, error)
|
||||
DeleteKindBox(ctx context.Context, kindBoxID uint) error
|
||||
GetAllKindBox(ctx context.Context) ([]entity.KindBox, error)
|
||||
GetKindBoxByID(ctx context.Context, kindBox uint) (entity.KindBox, error)
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package kindboxservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box"
|
||||
)
|
||||
|
||||
func (s Service) Update(updatedKindBox param.KindBoxUpdateRequest) (param.KindBoxUpdateResponse, error) {
|
||||
func (s Service) Update(ctx context.Context, req param.KindBoxUpdateRequest) (param.KindBoxUpdateResponse, error) {
|
||||
// some code
|
||||
panic("not implement")
|
||||
}
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
entity "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) Add(req param.KindBoxReqAddRequest) (param.KindBoxReqAddResponse, error) {
|
||||
func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param.KindBoxReqAddResponse, error) {
|
||||
const op = "kindboxreqservice.Add"
|
||||
kindBoxReq, err := s.repo.AddKindBoxReq(entity.KindBoxReq{
|
||||
kindBoxReq, err := s.repo.AddKindBoxReq(ctx, entity.KindBoxReq{
|
||||
TypeID: req.TypeID,
|
||||
CountRequested: req.CountRequested,
|
||||
BenefactorID: req.BenefactorID,
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func (s Service) Delete(kindBoxReqID param.KindBoxReqDeleteRequest) error {
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
)
|
||||
|
||||
func (s Service) Delete(ctx context.Context, req param.KindBoxReqDeleteRequest) error {
|
||||
// some code
|
||||
panic("not implemented")
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) GetAll() (param.KindBoxReqGetAllResponse, error) {
|
||||
func (s Service) GetAll(ctx context.Context) (param.KindBoxReqGetAllResponse, error) {
|
||||
const op = "kindboxreqservice.GetAll"
|
||||
allKindBoxReq, err := s.repo.GetAllKindBoxReq()
|
||||
allKindBoxReq, err := s.repo.GetAllKindBoxReq(ctx)
|
||||
if err != nil {
|
||||
return param.KindBoxReqGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
||||
)
|
||||
|
||||
func (s Service) GetByID(req param.KindBoxReqGetByIDRequest) (param.KindBoxReqGetByIDResponse, error) {
|
||||
func (s Service) GetByID(ctx context.Context, req param.KindBoxReqGetByIDRequest) (param.KindBoxReqGetByIDResponse, error) {
|
||||
const op = "kindboxreqservice.GetByID"
|
||||
kindBoxReq, err := s.repo.GetKindBoxReqByID(req.KindBoxReqID)
|
||||
kindBoxReq, err := s.repo.GetKindBoxReqByID(ctx, req.KindBoxReqID)
|
||||
if err != nil {
|
||||
return param.KindBoxReqGetByIDResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
||||
}
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import "git.gocasts.ir/ebhomengo/niki/entity"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.gocasts.ir/ebhomengo/niki/entity"
|
||||
)
|
||||
|
||||
type Repository interface {
|
||||
AddKindBoxReq(kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error)
|
||||
EditKindBoxReq(kindBoxReqID uint, kindBoxReqInput entity.KindBoxReq) (entity.KindBoxReq, error)
|
||||
DeleteKindBoxReq(kindBoxReqID uint) error
|
||||
GetAllKindBoxReq() ([]entity.KindBoxReq, error)
|
||||
GetKindBoxReqByID(kindBoxReq uint) (entity.KindBoxReq, error)
|
||||
AddKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error)
|
||||
EditKindBoxReq(ctx context.Context, kindBoxReqID uint, kindBoxReqInput entity.KindBoxReq) (entity.KindBoxReq, error)
|
||||
DeleteKindBoxReq(ctx context.Context, kindBoxReqID uint) error
|
||||
GetAllKindBoxReq(ctx context.Context) ([]entity.KindBoxReq, error)
|
||||
GetKindBoxReqByID(ctx context.Context, kindBoxReq uint) (entity.KindBoxReq, error)
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package kindboxreqservice
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
param "git.gocasts.ir/ebhomengo/niki/param/kind_box_req"
|
||||
// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error".
|
||||
)
|
||||
|
||||
func (s Service) Update(req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) {
|
||||
func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) {
|
||||
// const op = "kindboxreqservice.Update"
|
||||
// kindBoxReq, err := s.repo.EditKindBoxReq(req.KindBoxReq.ID, req.KindBoxReq)
|
||||
// if err != nil {
|
||||
|
|
Loading…
Reference in New Issue