generated from PenaSide/GolangTemplate
fix linter
This commit is contained in:
parent
8b1a064e26
commit
87bc32ca80
@ -23,7 +23,6 @@ type TemplateClient struct {
|
||||
}
|
||||
|
||||
func NewTemplateClient(deps TemplateClientDeps) *TemplateClient {
|
||||
|
||||
if deps.Logger == nil {
|
||||
log.Panicln("logger is nil on <NewTemplateClient>")
|
||||
}
|
||||
@ -72,7 +71,7 @@ func (receiver *TemplateClient) SendData(ctx context.Context, data models.RespGe
|
||||
return errors.New(err, errors.ErrInternalError)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", tmplURL, body)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, tmplURL, body)
|
||||
if err != nil {
|
||||
return errors.New(err, errors.ErrInternalError)
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ type VerificationClient struct {
|
||||
}
|
||||
|
||||
func NewVerificationClient(deps VerificationClientDeps) *VerificationClient {
|
||||
|
||||
if deps.Logger == nil {
|
||||
log.Panicln("logger is nil on <NewVerificationClient>")
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
type historyService interface {
|
||||
GetHistoryList(context.Context, *dto.GetHistories) (*models.PaginationResponse[models.History], errors.Error)
|
||||
GetRecentTariffs(context.Context, string) ([]models.TariffID, errors.Error) // new
|
||||
GetHistoryById(context.Context, string) errors.Error // new
|
||||
GetHistoryByID(context.Context, string) errors.Error // new
|
||||
}
|
||||
|
||||
type Deps struct {
|
||||
@ -98,7 +98,7 @@ func (receiver *Controller) GetRecentTariffs(ctx echo.Context) error {
|
||||
func (receiver *Controller) SendReport(ctx echo.Context) error {
|
||||
historyID := ctx.Param("id")
|
||||
|
||||
err := receiver.historyService.GetHistoryById(ctx.Request().Context(), historyID)
|
||||
err := receiver.historyService.GetHistoryByID(ctx.Request().Context(), historyID)
|
||||
if err != nil {
|
||||
receiver.logger.Error("failed to send report on <SendReport> of <HistoryController>", zap.Error(err))
|
||||
return errors.HTTP(ctx, err)
|
||||
|
@ -157,7 +157,7 @@ func (receiver *HistoryRepository) GetRecentTariffs(ctx context.Context, userID
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// TODO:tests
|
||||
// TODO:tests.
|
||||
func (receiver *HistoryRepository) GetHistoryById(ctx context.Context, historyID string) (*models.ReportHistory, errors.Error) {
|
||||
history := &models.ReportHistory{}
|
||||
err := receiver.mongoDB.FindOne(ctx, bson.M{"_id": historyID}).Decode(history)
|
||||
@ -184,7 +184,7 @@ func (receiver *HistoryRepository) GetHistoryById(ctx context.Context, historyID
|
||||
return history, nil
|
||||
}
|
||||
|
||||
// TODO:tests
|
||||
// TODO:tests.
|
||||
func (receiver *HistoryRepository) GetDocNumber(ctx context.Context, userID string) (map[string]int, errors.Error) {
|
||||
findOptions := options.Find()
|
||||
findOptions.SetSort(bson.D{{Key: "createdAt", Value: 1}})
|
||||
@ -204,7 +204,15 @@ func (receiver *HistoryRepository) GetDocNumber(ctx context.Context, userID stri
|
||||
errors.ErrInternalError,
|
||||
)
|
||||
}
|
||||
defer cursor.Close(ctx)
|
||||
|
||||
defer func() {
|
||||
if err := cursor.Close(ctx); err != nil {
|
||||
receiver.logger.Error("failed to close cursor on <GetDocNumber> of <HistoryRepository>",
|
||||
zap.String("userId", userID),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
}()
|
||||
|
||||
result := make(map[string]int)
|
||||
var count int
|
||||
|
@ -15,5 +15,5 @@ type Verification struct {
|
||||
|
||||
type VerificationFile struct {
|
||||
Name string `json:"name" bson:"name"`
|
||||
Url string `json:"url" bson:"url"`
|
||||
URL string `json:"url" bson:"url"`
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func (receiver *Service) GetRecentTariffs(ctx context.Context, userID string) ([
|
||||
return tariffs, nil
|
||||
}
|
||||
|
||||
func (receiver *Service) GetHistoryById(ctx context.Context, historyID string) errors.Error {
|
||||
func (receiver *Service) GetHistoryByID(ctx context.Context, historyID string) errors.Error {
|
||||
if historyID == "" {
|
||||
receiver.logger.Error("history id is missing in <GetHistoryById> of <HistoryService>")
|
||||
return errors.New(
|
||||
|
Loading…
Reference in New Issue
Block a user