-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f419da
commit 44baaa2
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
"github.com/alireza-fa/golang-car-shop/api/dto" | ||
"github.com/alireza-fa/golang-car-shop/config" | ||
"github.com/alireza-fa/golang-car-shop/constants" | ||
"github.com/alireza-fa/golang-car-shop/data/db" | ||
"github.com/alireza-fa/golang-car-shop/data/models" | ||
"github.com/alireza-fa/golang-car-shop/pkg/logging" | ||
) | ||
|
||
type CarModelCommentService struct { | ||
base *BaseService[models.CarModelComment, dto.CreateCarModelCommentRequest, dto.UpdateCarModelCommentRequest, dto.CarModelCommentResponse] | ||
} | ||
|
||
func NewCarModelCommentService(cfg *config.Config) *CarModelCommentService { | ||
return &CarModelCommentService{ | ||
base: &BaseService[models.CarModelComment, dto.CreateCarModelCommentRequest, dto.UpdateCarModelCommentRequest, dto.CarModelCommentResponse]{ | ||
Database: db.GetDb(), | ||
Logger: logging.NewLogger(cfg), | ||
Preloads: []preload{ | ||
{string: "User"}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// Create carModelComment | ||
func (s *CarModelCommentService) Create(ctx context.Context, req *dto.CreateCarModelCommentRequest) (*dto.CarModelCommentResponse, error) { | ||
req.UserId = int(ctx.Value(constants.UserIdKey).(float64)) | ||
return s.base.Create(ctx, req) | ||
} | ||
|
||
// Update carModelComment | ||
func (s *CarModelCommentService) Update(ctx context.Context, req *dto.UpdateCarModelCommentRequest, id int) (*dto.CarModelCommentResponse, error) { | ||
return s.base.Update(ctx, id, req) | ||
} | ||
|
||
// Delete carModelComment | ||
func (s *CarModelCommentService) Delete(ctx context.Context, id int) error { | ||
return s.base.Delete(ctx, id) | ||
} | ||
|
||
// GetById carModelComment | ||
func (s *CarModelCommentService) GetById(ctx context.Context, id int) (*dto.CarModelCommentResponse, error) { | ||
return s.base.GetById(ctx, id) | ||
} | ||
|
||
// GetByFilter carModelComment | ||
func (s *CarModelCommentService) GetByFilter(ctx context.Context, req *dto.PaginationInputWithFilter) (*dto.PagedList[dto.CarModelCommentResponse], error) { | ||
return s.base.GetByFilter(ctx, req) | ||
} |