32 lines
934 B
Go
32 lines
934 B
Go
package front
|
|
|
|
import (
|
|
"github.com/ahmetb/go-linq/v3"
|
|
"github.com/gin-gonic/gin"
|
|
"qteam/app/http/controllers"
|
|
"qteam/app/http/entities/front"
|
|
"qteam/app/models/ordermodel"
|
|
"qteam/app/services"
|
|
)
|
|
|
|
func CreateOrder(c *gin.Context) {
|
|
var request = controllers.GetRequest(c).(*front.OrderCreateRequest)
|
|
userId := controllers.GetUserId(c)
|
|
code := services.CreateOrderService(userId, request.ProductId)
|
|
controllers.HandCodeRes(c, nil, code)
|
|
}
|
|
|
|
func OrderQuery(c *gin.Context) {
|
|
var request = controllers.GetRequest(c).(*front.OrderQueryRequest)
|
|
userId := controllers.GetUserId(c)
|
|
code, orderList, count := services.OrderQueryService(userId, request)
|
|
var rsp []front.OrderQueryResponse
|
|
if count > 0 {
|
|
linq.From(orderList).SelectT(func(in ordermodel.Order) (out front.OrderQueryResponse) {
|
|
out.ResponseFromDb(in)
|
|
return out
|
|
}).ToSlice(&rsp)
|
|
}
|
|
controllers.HandCodeRes(c, gin.H{"data": rsp, "count": count}, code)
|
|
}
|