PaymentCenter/app/http/controllers/backend/order.go

52 lines
1.4 KiB
Go

package backend
import (
"PaymentCenter/app/constants/errorcode"
"PaymentCenter/app/http/controllers"
"PaymentCenter/app/http/entities"
"PaymentCenter/app/http/entities/backend"
"PaymentCenter/app/models/orderlogmodel"
"PaymentCenter/app/models/ordersmodel"
"PaymentCenter/app/services"
"github.com/ahmetb/go-linq/v3"
"github.com/gin-gonic/gin"
)
func OrderList(c *gin.Context) {
req, _ := controllers.GetRequest(c).(*backend.OrderListRequest)
filter, err := req.ValidateRequest()
if err != nil {
controllers.Error(c, errorcode.ParamError, err.Error())
return
}
orderList, total, code := services.OrderList(filter)
result := make([]backend.OrdersResponse, 0, len(orderList))
linq.From(orderList).SelectT(func(in ordersmodel.OrdersBackendList) (out backend.OrdersResponse) {
out.ResponseFromDb(in)
return
}).ToSlice(&result)
data := entities.PageRsp{
Total: total,
Data: result,
}
controllers.HandCodeRes(c, data, code)
}
func OrderLogsList(c *gin.Context) {
req, _ := controllers.GetRequest(c).(*backend.OrderLogsListRequest)
req.SetDefault()
orderLogList, total, code := services.OrderLogsList(*req)
result := make([]backend.OrderLogResponse, 0, len(orderLogList))
linq.From(orderLogList).SelectT(func(in orderlogmodel.OrderLog) (out backend.OrderLogResponse) {
out.ResponseFromDb(in)
return
}).ToSlice(&result)
data := entities.PageRsp{
Total: total,
Data: result,
}
controllers.HandCodeRes(c, data, code)
}