fix linter errors

This commit is contained in:
Abolfazl Nourzad 2024-01-25 21:29:18 +03:30
parent 96eb93bb69
commit 6853ddaf64
Signed by: abolfazl
GPG Key ID: 183534166EB62E0B
10 changed files with 27 additions and 14 deletions

View File

@ -8,7 +8,7 @@ package adminkindboxhandler
// echo "github.com/labstack/echo/v4"
//)
//
//func (h Handler) Get(c echo.Context) error {
// func (h Handler) Get(c echo.Context) error {
// var req param.KindBoxGetRequest
// if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest)

View File

@ -9,7 +9,7 @@ package adminkindboxhandler
// echo "github.com/labstack/echo/v4"
//)
//
//func (h Handler) GetAll(c echo.Context) error {
// func (h Handler) GetAll(c echo.Context) error {
// var req param.KindBoxGetAllRequest
// if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest)

View File

@ -4,9 +4,8 @@ import (
echo "github.com/labstack/echo/v4"
)
func (h Handler) SetRoutes(e *echo.Echo) {
func (h Handler) SetRoutes(_ *echo.Echo) {
//nolint
// r.POST("/", h.Add).Name = "admin-addkindbox"
// r.GET("/:id", h.Get).Name = "admin-getkindboxbyid"
// r.GET("/", h.GetAll).Name = "admin-getallkindbox"

View File

@ -8,7 +8,7 @@ package adminkindboxhandler
// echo "github.com/labstack/echo/v4"
//)
//
//func (h Handler) Update(c echo.Context) error {
// func (h Handler) Update(c echo.Context) error {
// var req param.KindBoxUpdateRequest
// if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest)

View File

@ -63,7 +63,6 @@ func setupServices(cfg config.Config) (
adminSvc adminservice.Service, adminVld adminvalidator.Validator,
adminAuthSvc adminauthservice.Service,
adminKindBoxReqSvc adminkindboxreqservice.Service, adminKindBoxReqVld adminkindboxreqvalidator.Validator,
) {
authSvc = authservice.New(cfg.Auth)

View File

@ -2,6 +2,7 @@ package mysqlkindbox
import (
"context"
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/logger"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"

View File

@ -6,6 +6,7 @@ import (
"errors"
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/logger"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
@ -32,7 +33,11 @@ func (d DB) AcceptKindBoxReq(ctx context.Context, kindBoxReqID, countAccepted ui
op := richerror.Op("mysqlkindboxreq.AcceptKindBoxReq")
statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set count_accepted = ? , status = ? where id = ?`)
defer statement.Close()
defer func() {
dErr := statement.Close()
logger.L().Error(dErr.Error())
}()
if err != nil {
return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
@ -78,7 +83,10 @@ func (d DB) RejectKindBoxReq(ctx context.Context, kindBoxReqID uint, description
op := richerror.Op("mysqlkindboxreq.RejectKindBoxReq")
statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set description = ? , status = ? where id = ?`)
defer statement.Close()
defer func() {
dErr := statement.Close()
logger.L().Error(dErr.Error())
}()
if err != nil {
return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
@ -96,7 +104,10 @@ func (d DB) RollbackKindBoxRequestStatus(ctx context.Context, id uint) error {
op := richerror.Op("mysqlkindboxreq.RollbackKindBoxRequestStatus")
statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set status = ? where id = ?`)
defer statement.Close()
defer func() {
dErr := statement.Close()
logger.L().Error(dErr.Error())
}()
if err != nil {
return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
@ -106,5 +117,6 @@ func (d DB) RollbackKindBoxRequestStatus(ctx context.Context, id uint) error {
return richerror.New(op).WithErr(eErr).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
}
return nil
}

View File

@ -2,13 +2,14 @@ package adminkindboxreqservice
import (
"context"
"git.gocasts.ir/ebhomengo/niki/logger"
adminkindboxparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
//@see
// @see
// When confirming a request, should the senderID field, which represents the person sending the kind-box to the beneficiary,
// be filled at the same time? Or is it acceptable to confirm the request first and fill in the senderID field later?
//
@ -38,6 +39,7 @@ func (s Service) Accept(ctx context.Context, req param.KindBoxReqAcceptRequest)
// log error
logger.L().Error(rErr.Error())
}
return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(kErr)
}

View File

@ -57,7 +57,7 @@ func New(repo Repository) Validator {
// return nil
//}
//
//func (v Validator) doesKindBoxExist(value interface{}) error {
// func (v Validator) doesKindBoxExist(value interface{}) error {
// kindboxID, ok := value.(uint)
// if !ok {
// return fmt.Errorf(errmsg.ErrorMsgNotFound)
@ -70,7 +70,7 @@ func New(repo Repository) Validator {
// return nil
//}
//
//func (v Validator) doesKindBoxBelongToBenefactor(benefactorID uint) validation.RuleFunc {
// func (v Validator) doesKindBoxBelongToBenefactor(benefactorID uint) validation.RuleFunc {
// return func(value interface{}) error {
// kbID, ok := value.(uint)
// if !ok {

View File

@ -4,8 +4,8 @@ import (
"context"
"errors"
"fmt"
"git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/entity"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
)