diff --git a/delivery/http_server/admin/kind_box_req/accept.go b/delivery/http_server/admin/kind_box_req/accept.go index 1e3f7d4..b5f3075 100644 --- a/delivery/http_server/admin/kind_box_req/accept.go +++ b/delivery/http_server/admin/kind_box_req/accept.go @@ -1,6 +1,7 @@ package adminkindboxreqhandler import ( + errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" "net/http" "strconv" @@ -14,7 +15,10 @@ func (h Handler) Accept(c echo.Context) error { if bErr := c.Bind(&req); bErr != nil { return echo.NewHTTPError(http.StatusBadRequest) } - num, _ := strconv.ParseUint(c.Param("id"), 36, 10) + num, cErr := strconv.ParseUint(c.Param("id"), 10, 64) + if cErr != nil { + return c.JSON(http.StatusBadRequest, errmsg.ErrorMsgInvalidInput) + } req.ID = uint(num) // if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetRequest(req); err != nil { // msg, code := httpmsg.Error(err) diff --git a/param/admin/kind_box_req/accept.go b/param/admin/kind_box_req/accept.go index ad480bb..60573b9 100644 --- a/param/admin/kind_box_req/accept.go +++ b/param/admin/kind_box_req/accept.go @@ -7,9 +7,8 @@ import ( ) type KindBoxReqAcceptRequest struct { - ID uint `json:"id"` - Description string `json:"description"` - CountAccepted uint `json:"count_accepted"` + ID uint `json:"id"` + CountAccepted uint `json:"count_accepted"` } type KindBoxReqAcceptResponse struct { diff --git a/repository/mysql/kind_box_req/kind_box_req.go b/repository/mysql/kind_box_req/kind_box_req.go index 88291e2..cbe7fea 100644 --- a/repository/mysql/kind_box_req/kind_box_req.go +++ b/repository/mysql/kind_box_req/kind_box_req.go @@ -25,15 +25,15 @@ func (d DB) AddKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) (en return kindBoxReq, nil } -func (d DB) AcceptKindBoxReq(ctx context.Context, kindBoxReqID uint, countAccepted uint, description string) error { +func (d DB) AcceptKindBoxReq(ctx context.Context, kindBoxReqID uint, countAccepted uint) error { op := richerror.Op("mysqlkindboxreq.AcceptKindBoxReq") statement, err := d.conn.Conn(). - Prepare(`update kind_box_reqs set count_accepted = ? , description = ? , status = ? where id = ?`) + Prepare(`update kind_box_reqs set count_accepted = ? , status = ? where id = ?`) if err != nil { return richerror.New(op).WithErr(err). WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) } - _, eErr := statement.ExecContext(ctx, countAccepted, description, entity.KindBoxReqAcceptedStatus.String(), kindBoxReqID) + _, eErr := statement.ExecContext(ctx, countAccepted, entity.KindBoxReqAcceptedStatus.String(), kindBoxReqID) if eErr != nil { return richerror.New(op).WithErr(eErr). WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) diff --git a/service/admin/kind_box_req/accept.go b/service/admin/kind_box_req/accept.go index dc8efb9..54f3960 100644 --- a/service/admin/kind_box_req/accept.go +++ b/service/admin/kind_box_req/accept.go @@ -8,7 +8,7 @@ import ( func (s Service) Accept(ctx context.Context, req param.KindBoxReqAcceptRequest) (param.KindBoxReqAcceptResponse, error) { const op = "adminkindboxreqservice.Accept" - err := s.repo.AcceptKindBoxReq(ctx, req.ID, req.CountAccepted, req.Description) + err := s.repo.AcceptKindBoxReq(ctx, req.ID, req.CountAccepted) if err != nil { return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(err) } diff --git a/service/admin/kind_box_req/service.go b/service/admin/kind_box_req/service.go index 118707a..878b03e 100644 --- a/service/admin/kind_box_req/service.go +++ b/service/admin/kind_box_req/service.go @@ -12,7 +12,7 @@ type Repository interface { // DeleteKindBoxReq(ctx context.Context, kindBoxReqID uint) error // GetAllKindBoxReq(ctx context.Context) ([]entity.KindBoxReq, error) // GetKindBoxReq(ctx context.Context, kindBoxReqID uint) (entity.KindBoxReq, error) - AcceptKindBoxReq(ctx context.Context, kindBoxReqID uint, countAccepted uint, description string) error + AcceptKindBoxReq(ctx context.Context, kindBoxReqID uint, countAccepted uint) error FindByID(ctx context.Context, id uint) (entity.KindBoxReq, error) } diff --git a/service/admin/kind_box_req/update.go b/service/admin/kind_box_req/update.go index 72f6998..0cd9d0e 100644 --- a/service/admin/kind_box_req/update.go +++ b/service/admin/kind_box_req/update.go @@ -9,7 +9,7 @@ package adminkindboxreqservice // richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" //) // -// func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) { +//func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) { // // TODO: can benefactor update its request ? // // TODO: Is Update Mothod Service Responsible to check which kindboxreqID belongs to benefactorID ? // // TODO: updating data(s) may have side-effect on other entities by masood-keshvary accepted -> rejected