forked from ebhomengo/niki
1
0
Fork 0

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

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

@ -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,6 +2,7 @@ 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"
@ -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

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