forked from ebhomengo/niki
1
0
Fork 0

minor change & delete description field from param.KindBoxReqAcceptRequest

This commit is contained in:
Abolfazl Nourzad 2024-01-22 14:13:16 +03:30
parent e3109b1972
commit 12a8e0ecf5
Signed by: abolfazl
GPG Key ID: 183534166EB62E0B
6 changed files with 13 additions and 10 deletions

View File

@ -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)

View File

@ -8,7 +8,6 @@ import (
type KindBoxReqAcceptRequest struct {
ID uint `json:"id"`
Description string `json:"description"`
CountAccepted uint `json:"count_accepted"`
}

View File

@ -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)

View File

@ -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)
}

View File

@ -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)
}