feat: add TenantLedger model and query generation

- Introduced TenantLedger model with fields for managing tenant transactions, including ID, TenantID, UserID, OrderID, transaction Type, Amount, and balance details.
- Implemented CRUD operations for TenantLedger with methods for Create, Update, Delete, and Reload.
- Generated query methods for TenantLedger to facilitate database interactions, including filtering, pagination, and aggregation functions.
- Established relationships with Order model for foreign key references.
This commit is contained in:
2025-12-18 13:12:26 +08:00
parent f93caefcb2
commit 1da84f2af3
42 changed files with 6468 additions and 265 deletions

View File

@@ -19,7 +19,7 @@ import (
// Routes implements the HttpRoute contract and provides route registration
// for all controllers in the tenant module.
//
// @provider contracts.HttpRoute atom.GroupRoutes
// @provider contracts.HttpRoute atom.GroupRoutes
type Routes struct {
log *log.Entry `inject:"false"`
middlewares *middlewares.Middlewares
@@ -27,6 +27,9 @@ type Routes struct {
content *content
contentAdmin *contentAdmin
me *me
order *order
orderAdmin *orderAdmin
orderMe *orderMe
}
// Prepare initializes the routes provider with logging configuration.
@@ -113,6 +116,53 @@ func (r *Routes) Register(router fiber.Router) {
Local[*models.User]("user"),
Local[*models.TenantUser]("tenant_user"),
))
// Register routes for controller: order
r.log.Debugf("Registering route: Post /t/:tenantCode/v1/contents/:contentID/purchase -> order.purchaseContent")
router.Post("/t/:tenantCode/v1/contents/:contentID/purchase"[len(r.Path()):], DataFunc4(
r.order.purchaseContent,
Local[*models.Tenant]("tenant"),
Local[*models.User]("user"),
PathParam[int64]("contentID"),
Body[dto.PurchaseContentForm]("form"),
))
// Register routes for controller: orderAdmin
r.log.Debugf("Registering route: Get /t/:tenantCode/v1/admin/orders -> orderAdmin.adminOrderList")
router.Get("/t/:tenantCode/v1/admin/orders"[len(r.Path()):], DataFunc3(
r.orderAdmin.adminOrderList,
Local[*models.Tenant]("tenant"),
Local[*models.TenantUser]("tenant_user"),
Query[dto.AdminOrderListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /t/:tenantCode/v1/admin/orders/:orderID -> orderAdmin.adminOrderDetail")
router.Get("/t/:tenantCode/v1/admin/orders/:orderID"[len(r.Path()):], DataFunc3(
r.orderAdmin.adminOrderDetail,
Local[*models.Tenant]("tenant"),
Local[*models.TenantUser]("tenant_user"),
PathParam[int64]("orderID"),
))
r.log.Debugf("Registering route: Post /t/:tenantCode/v1/admin/orders/:orderID/refund -> orderAdmin.adminRefund")
router.Post("/t/:tenantCode/v1/admin/orders/:orderID/refund"[len(r.Path()):], DataFunc4(
r.orderAdmin.adminRefund,
Local[*models.Tenant]("tenant"),
Local[*models.TenantUser]("tenant_user"),
PathParam[int64]("orderID"),
Body[dto.AdminOrderRefundForm]("form"),
))
// Register routes for controller: orderMe
r.log.Debugf("Registering route: Get /t/:tenantCode/v1/orders -> orderMe.myOrders")
router.Get("/t/:tenantCode/v1/orders"[len(r.Path()):], DataFunc3(
r.orderMe.myOrders,
Local[*models.Tenant]("tenant"),
Local[*models.User]("user"),
Query[dto.MyOrderListFilter]("filter"),
))
r.log.Debugf("Registering route: Get /t/:tenantCode/v1/orders/:orderID -> orderMe.myOrderDetail")
router.Get("/t/:tenantCode/v1/orders/:orderID"[len(r.Path()):], DataFunc3(
r.orderMe.myOrderDetail,
Local[*models.Tenant]("tenant"),
Local[*models.User]("user"),
PathParam[int64]("orderID"),
))
r.log.Info("Successfully registered all routes")
}