17 lines
430 B
Go
17 lines
430 B
Go
|
package product
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"net/http"
|
||
|
"tel-commerce/ent"
|
||
|
"tel-commerce/ent/product"
|
||
|
)
|
||
|
|
||
|
func (controller ProductController) ShowProducts(ctx *gin.Context) {
|
||
|
if products, err := controller.Client.Product.Query().Order(ent.Asc(product.FieldID)).All(controller.Ctx); err != nil {
|
||
|
ctx.IndentedJSON(http.StatusInternalServerError, err.Error())
|
||
|
} else {
|
||
|
ctx.IndentedJSON(http.StatusOK, products)
|
||
|
}
|
||
|
}
|