| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package ctxhelper
- import (
- "context"
- "math"
- "perms-system-server/internal/consts"
- "perms-system-server/internal/loaders"
- "perms-system-server/internal/middleware"
- )
- func SuperAdminCtx() context.Context {
- return middleware.WithUserDetails(context.Background(), &loaders.UserDetails{
- UserId: 1,
- Username: "superadmin",
- IsSuperAdmin: true,
- MemberType: consts.MemberTypeSuperAdmin,
- Status: consts.StatusEnabled,
- ProductCode: "test_product",
- MinPermsLevel: math.MaxInt64,
- })
- }
- func SuperAdminCtxWithUserId(userId int64) context.Context {
- return middleware.WithUserDetails(context.Background(), &loaders.UserDetails{
- UserId: userId,
- Username: "superadmin",
- IsSuperAdmin: true,
- MemberType: consts.MemberTypeSuperAdmin,
- Status: consts.StatusEnabled,
- ProductCode: "test_product",
- MinPermsLevel: math.MaxInt64,
- })
- }
- func AdminCtx(productCode string) context.Context {
- return middleware.WithUserDetails(context.Background(), &loaders.UserDetails{
- UserId: 2,
- Username: "admin",
- IsSuperAdmin: false,
- MemberType: consts.MemberTypeAdmin,
- Status: consts.StatusEnabled,
- ProductCode: productCode,
- DeptId: 1,
- DeptPath: "/1/",
- MinPermsLevel: math.MaxInt64,
- })
- }
- func DeveloperCtx(productCode string) context.Context {
- return middleware.WithUserDetails(context.Background(), &loaders.UserDetails{
- UserId: 3,
- Username: "developer",
- IsSuperAdmin: false,
- MemberType: consts.MemberTypeDeveloper,
- Status: consts.StatusEnabled,
- ProductCode: productCode,
- DeptId: 1,
- DeptPath: "/1/",
- MinPermsLevel: math.MaxInt64,
- })
- }
- func MemberCtx(productCode string) context.Context {
- return middleware.WithUserDetails(context.Background(), &loaders.UserDetails{
- UserId: 4,
- Username: "member",
- IsSuperAdmin: false,
- MemberType: consts.MemberTypeMember,
- Status: consts.StatusEnabled,
- ProductCode: productCode,
- DeptId: 1,
- DeptPath: "/1/",
- MinPermsLevel: 100,
- })
- }
- func CustomCtx(ud *loaders.UserDetails) context.Context {
- return middleware.WithUserDetails(context.Background(), ud)
- }
|