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" // 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 // var req param.KindBoxGetRequest
// if bErr := c.Bind(&req); bErr != nil { // if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest) // return echo.NewHTTPError(http.StatusBadRequest)

View File

@ -9,7 +9,7 @@ package adminkindboxhandler
// echo "github.com/labstack/echo/v4" // 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 // var req param.KindBoxGetAllRequest
// if bErr := c.Bind(&req); bErr != nil { // if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest) // return echo.NewHTTPError(http.StatusBadRequest)

View File

@ -4,9 +4,8 @@ import (
echo "github.com/labstack/echo/v4" 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.POST("/", h.Add).Name = "admin-addkindbox"
// r.GET("/:id", h.Get).Name = "admin-getkindboxbyid" // r.GET("/:id", h.Get).Name = "admin-getkindboxbyid"
// r.GET("/", h.GetAll).Name = "admin-getallkindbox" // r.GET("/", h.GetAll).Name = "admin-getallkindbox"

View File

@ -8,7 +8,7 @@ package adminkindboxhandler
// echo "github.com/labstack/echo/v4" // 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 // var req param.KindBoxUpdateRequest
// if bErr := c.Bind(&req); bErr != nil { // if bErr := c.Bind(&req); bErr != nil {
// return echo.NewHTTPError(http.StatusBadRequest) // return echo.NewHTTPError(http.StatusBadRequest)

View File

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

View File

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

View File

@ -6,6 +6,7 @@ import (
"errors" "errors"
"git.gocasts.ir/ebhomengo/niki/entity" "git.gocasts.ir/ebhomengo/niki/entity"
"git.gocasts.ir/ebhomengo/niki/logger"
errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" 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") op := richerror.Op("mysqlkindboxreq.AcceptKindBoxReq")
statement, err := d.conn.Conn(). statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set count_accepted = ? , status = ? where id = ?`) 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 { if err != nil {
return richerror.New(op).WithErr(err). return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) 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") op := richerror.Op("mysqlkindboxreq.RejectKindBoxReq")
statement, err := d.conn.Conn(). statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set description = ? , status = ? where id = ?`) 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 { if err != nil {
return richerror.New(op).WithErr(err). return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) 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") op := richerror.Op("mysqlkindboxreq.RollbackKindBoxRequestStatus")
statement, err := d.conn.Conn(). statement, err := d.conn.Conn().
Prepare(`update kind_box_reqs set status = ? where id = ?`) 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 { if err != nil {
return richerror.New(op).WithErr(err). return richerror.New(op).WithErr(err).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) 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). return richerror.New(op).WithErr(eErr).
WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected)
} }
return nil return nil
} }

View File

@ -2,13 +2,14 @@ package adminkindboxreqservice
import ( import (
"context" "context"
"git.gocasts.ir/ebhomengo/niki/logger" "git.gocasts.ir/ebhomengo/niki/logger"
adminkindboxparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" adminkindboxparam "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box"
param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" 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, // 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? // 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 // log error
logger.L().Error(rErr.Error()) logger.L().Error(rErr.Error())
} }
return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(kErr) return param.KindBoxReqAcceptResponse{}, richerror.New(op).WithErr(kErr)
} }

View File

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

View File

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