46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package productsmodule
|
|
|
|
import (
|
|
productdto "api/application/products/dto"
|
|
"api/models/api"
|
|
)
|
|
|
|
// Controller defines the methods to be exposed in Controller layer
|
|
type Controller interface {
|
|
CreateProduct(userId string, data *productdto.ProductDto) (*api.Response, int, error)
|
|
UpdateProduct(userId string, data *productdto.ProductDto) (*api.Response, int, error)
|
|
VerifyCode(data *productdto.ValidateCodeDto) (*api.Response, int, error)
|
|
GetProducts() (*api.Response, int, error)
|
|
DeleteProduct(data *productdto.DeleteProductDto) (*api.Response, int, error)
|
|
}
|
|
|
|
type controller struct {
|
|
ProductsService
|
|
}
|
|
|
|
func newController(service ProductsService) Controller {
|
|
return &controller{
|
|
ProductsService: service,
|
|
}
|
|
}
|
|
|
|
func (c *controller) CreateProduct(userId string, data *productdto.ProductDto) (*api.Response, int, error) {
|
|
return c.ProductsService.CreateProduct(userId, data)
|
|
}
|
|
|
|
func (c *controller) UpdateProduct(userId string, data *productdto.ProductDto) (*api.Response, int, error) {
|
|
return c.ProductsService.UpdateProduct(userId, data)
|
|
}
|
|
|
|
func (c *controller) VerifyCode(data *productdto.ValidateCodeDto) (*api.Response, int, error) {
|
|
return c.ProductsService.VerifyCode(data)
|
|
}
|
|
|
|
func (c *controller) GetProducts() (*api.Response, int, error) {
|
|
return c.ProductsService.GetProducts()
|
|
}
|
|
|
|
func (c *controller) DeleteProduct(data *productdto.DeleteProductDto) (*api.Response, int, error) {
|
|
return c.ProductsService.DeleteProduct(data)
|
|
}
|