feat: 添加订单提供者,优化路由注册,增强用户角色管理
This commit is contained in:
@@ -25,6 +25,13 @@ func Provide(opts ...opt.Option) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := container.Container.Provide(func() (*order, error) {
|
||||||
|
obj := &order{}
|
||||||
|
|
||||||
|
return obj, nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := container.Container.Provide(func(
|
if err := container.Container.Provide(func(
|
||||||
auth *auth,
|
auth *auth,
|
||||||
middlewares *middlewares.Middlewares,
|
middlewares *middlewares.Middlewares,
|
||||||
@@ -54,13 +61,6 @@ func Provide(opts ...opt.Option) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := container.Container.Provide(func() (*order, error) {
|
|
||||||
obj := &order{}
|
|
||||||
|
|
||||||
return obj, nil
|
|
||||||
}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := container.Container.Provide(func() (*tenant, error) {
|
if err := container.Container.Provide(func() (*tenant, error) {
|
||||||
obj := &tenant{}
|
obj := &tenant{}
|
||||||
|
|
||||||
|
|||||||
@@ -66,27 +66,22 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
r.order.detail,
|
r.order.detail,
|
||||||
PathParam[int64]("orderID"),
|
PathParam[int64]("orderID"),
|
||||||
))
|
))
|
||||||
|
r.log.Debugf("Registering route: Get /super/v1/orders/statistics -> order.statistics")
|
||||||
|
router.Get("/super/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
||||||
|
r.order.statistics,
|
||||||
|
))
|
||||||
r.log.Debugf("Registering route: Post /super/v1/orders/:orderID/refund -> order.refund")
|
r.log.Debugf("Registering route: Post /super/v1/orders/:orderID/refund -> order.refund")
|
||||||
router.Post("/super/v1/orders/:orderID/refund"[len(r.Path()):], DataFunc2(
|
router.Post("/super/v1/orders/:orderID/refund"[len(r.Path()):], DataFunc2(
|
||||||
r.order.refund,
|
r.order.refund,
|
||||||
PathParam[int64]("orderID"),
|
PathParam[int64]("orderID"),
|
||||||
Body[dto.SuperOrderRefundForm]("form"),
|
Body[dto.SuperOrderRefundForm]("form"),
|
||||||
))
|
))
|
||||||
r.log.Debugf("Registering route: Get /super/v1/orders/statistics -> order.statistics")
|
|
||||||
router.Get("/super/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
|
||||||
r.order.statistics,
|
|
||||||
))
|
|
||||||
// Register routes for controller: tenant
|
// Register routes for controller: tenant
|
||||||
r.log.Debugf("Registering route: Get /super/v1/tenants -> tenant.list")
|
r.log.Debugf("Registering route: Get /super/v1/tenants -> tenant.list")
|
||||||
router.Get("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
router.Get("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
||||||
r.tenant.list,
|
r.tenant.list,
|
||||||
Query[dto.TenantFilter]("filter"),
|
Query[dto.TenantFilter]("filter"),
|
||||||
))
|
))
|
||||||
r.log.Debugf("Registering route: Post /super/v1/tenants -> tenant.create")
|
|
||||||
router.Post("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
|
||||||
r.tenant.create,
|
|
||||||
Body[dto.TenantCreateForm]("form"),
|
|
||||||
))
|
|
||||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID/users -> tenant.users")
|
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID/users -> tenant.users")
|
||||||
router.Get("/super/v1/tenants/:tenantID/users"[len(r.Path()):], DataFunc2(
|
router.Get("/super/v1/tenants/:tenantID/users"[len(r.Path()):], DataFunc2(
|
||||||
r.tenant.users,
|
r.tenant.users,
|
||||||
@@ -109,6 +104,11 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
PathParam[int64]("tenantID"),
|
PathParam[int64]("tenantID"),
|
||||||
Body[dto.TenantStatusUpdateForm]("form"),
|
Body[dto.TenantStatusUpdateForm]("form"),
|
||||||
))
|
))
|
||||||
|
r.log.Debugf("Registering route: Post /super/v1/tenants -> tenant.create")
|
||||||
|
router.Post("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
||||||
|
r.tenant.create,
|
||||||
|
Body[dto.TenantCreateForm]("form"),
|
||||||
|
))
|
||||||
// Register routes for controller: user
|
// Register routes for controller: user
|
||||||
r.log.Debugf("Registering route: Get /super/v1/users -> user.list")
|
r.log.Debugf("Registering route: Get /super/v1/users -> user.list")
|
||||||
router.Get("/super/v1/users"[len(r.Path()):], DataFunc1(
|
router.Get("/super/v1/users"[len(r.Path()):], DataFunc1(
|
||||||
@@ -129,18 +129,18 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
router.Get("/super/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
router.Get("/super/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
||||||
r.user.statusList,
|
r.user.statusList,
|
||||||
))
|
))
|
||||||
r.log.Debugf("Registering route: Patch /super/v1/users/:userID/status -> user.updateStatus")
|
|
||||||
router.Patch("/super/v1/users/:userID/status"[len(r.Path()):], Func2(
|
|
||||||
r.user.updateStatus,
|
|
||||||
PathParam[int64]("userID"),
|
|
||||||
Body[dto.UserStatusUpdateForm]("form"),
|
|
||||||
))
|
|
||||||
r.log.Debugf("Registering route: Patch /super/v1/users/:userID/roles -> user.updateRoles")
|
r.log.Debugf("Registering route: Patch /super/v1/users/:userID/roles -> user.updateRoles")
|
||||||
router.Patch("/super/v1/users/:userID/roles"[len(r.Path()):], Func2(
|
router.Patch("/super/v1/users/:userID/roles"[len(r.Path()):], Func2(
|
||||||
r.user.updateRoles,
|
r.user.updateRoles,
|
||||||
PathParam[int64]("userID"),
|
PathParam[int64]("userID"),
|
||||||
Body[dto.UserRolesUpdateForm]("form"),
|
Body[dto.UserRolesUpdateForm]("form"),
|
||||||
))
|
))
|
||||||
|
r.log.Debugf("Registering route: Patch /super/v1/users/:userID/status -> user.updateStatus")
|
||||||
|
router.Patch("/super/v1/users/:userID/status"[len(r.Path()):], Func2(
|
||||||
|
r.user.updateStatus,
|
||||||
|
PathParam[int64]("userID"),
|
||||||
|
Body[dto.UserStatusUpdateForm]("form"),
|
||||||
|
))
|
||||||
|
|
||||||
r.log.Info("Successfully registered all routes")
|
r.log.Info("Successfully registered all routes")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package middlewares
|
package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"quyun/v2/app/errorx"
|
"quyun/v2/app/errorx"
|
||||||
"quyun/v2/app/services"
|
"quyun/v2/app/services"
|
||||||
"quyun/v2/database/models"
|
"quyun/v2/database/models"
|
||||||
"quyun/v2/pkg/consts"
|
"quyun/v2/pkg/consts"
|
||||||
"quyun/v2/providers/jwt"
|
"quyun/v2/providers/jwt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func (t *UserTestSuite) Test_Create() {
|
|||||||
m := &models.User{
|
m := &models.User{
|
||||||
Username: "test-user",
|
Username: "test-user",
|
||||||
Password: "test-password",
|
Password: "test-password",
|
||||||
Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
Roles: types.NewArray([]consts.Role{consts.RoleUser, consts.RoleSuperAdmin}),
|
||||||
Status: consts.UserStatusPendingVerify,
|
Status: consts.UserStatusPendingVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ func (t *UserTestSuite) Test_FindByUsername() {
|
|||||||
m := &models.User{
|
m := &models.User{
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: "test-password",
|
Password: "test-password",
|
||||||
Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
Roles: types.NewArray([]consts.Role{consts.RoleUser, consts.RoleSuperAdmin}),
|
||||||
Status: consts.UserStatusPendingVerify,
|
Status: consts.UserStatusPendingVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ func (t *UserTestSuite) Test_Page() {
|
|||||||
m := &models.User{
|
m := &models.User{
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: "test-password",
|
Password: "test-password",
|
||||||
Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
Roles: types.NewArray([]consts.Role{consts.RoleUser, consts.RoleSuperAdmin}),
|
||||||
Status: consts.UserStatusPendingVerify,
|
Status: consts.UserStatusPendingVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ func (t *UserTestSuite) Test_Page() {
|
|||||||
m := &models.User{
|
m := &models.User{
|
||||||
Username: username,
|
Username: username,
|
||||||
Password: "test-password",
|
Password: "test-password",
|
||||||
Roles: types.NewArray([]consts.Role{consts.RoleUser}),
|
Roles: types.NewArray([]consts.Role{consts.RoleUser, consts.RoleSuperAdmin}),
|
||||||
Status: consts.UserStatusPendingVerify,
|
Status: consts.UserStatusPendingVerify,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user