feat(shop-role): 实现店铺角色继承功能和权限检查优化
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m39s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m39s
- 新增店铺角色管理 API 和数据模型 - 实现角色继承和权限检查逻辑 - 添加流程测试框架和集成测试 - 更新权限服务和账号管理逻辑 - 添加数据库迁移脚本 - 归档 OpenSpec 变更文档 Ultraworked with Sisyphus
This commit is contained in:
37
internal/service/account/role_resolver.go
Normal file
37
internal/service/account/role_resolver.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
)
|
||||
|
||||
func (s *Service) GetRoleIDsForAccount(ctx context.Context, accountID uint) ([]uint, error) {
|
||||
account, err := s.accountStore.GetByID(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeInternalError, err, "查询账号失败")
|
||||
}
|
||||
|
||||
if account.UserType == constants.UserTypeSuperAdmin {
|
||||
return []uint{}, nil
|
||||
}
|
||||
|
||||
accountRoles, err := s.accountRoleStore.GetRoleIDsByAccountID(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeInternalError, err, "查询账号角色失败")
|
||||
}
|
||||
if len(accountRoles) > 0 {
|
||||
return accountRoles, nil
|
||||
}
|
||||
|
||||
if account.UserType == constants.UserTypeAgent && account.ShopID != nil {
|
||||
shopRoles, err := s.shopRoleStore.GetRoleIDsByShopID(ctx, *account.ShopID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeInternalError, err, "查询店铺角色失败")
|
||||
}
|
||||
return shopRoles, nil
|
||||
}
|
||||
|
||||
return []uint{}, nil
|
||||
}
|
||||
211
internal/service/account/role_resolver_test.go
Normal file
211
internal/service/account/role_resolver_test.go
Normal file
@@ -0,0 +1,211 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/tests/testutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetRoleIDsForAccount(t *testing.T) {
|
||||
tx := testutils.NewTestTransaction(t)
|
||||
rdb := testutils.GetTestRedis(t)
|
||||
testutils.CleanTestRedisKeys(t, rdb)
|
||||
|
||||
accountStore := postgres.NewAccountStore(tx, rdb)
|
||||
roleStore := postgres.NewRoleStore(tx)
|
||||
accountRoleStore := postgres.NewAccountRoleStore(tx, rdb)
|
||||
shopRoleStore := postgres.NewShopRoleStore(tx, rdb)
|
||||
|
||||
service := New(
|
||||
accountStore,
|
||||
roleStore,
|
||||
accountRoleStore,
|
||||
shopRoleStore,
|
||||
nil,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
t.Run("超级管理员返回空数组", func(t *testing.T) {
|
||||
account := &model.Account{
|
||||
Username: "admin_roletest",
|
||||
Phone: "13800010001",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypeSuperAdmin,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, roleIDs)
|
||||
})
|
||||
|
||||
t.Run("平台用户返回账号级角色", func(t *testing.T) {
|
||||
account := &model.Account{
|
||||
Username: "platform_roletest",
|
||||
Phone: "13800010002",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypePlatform,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
role := &model.Role{
|
||||
RoleName: "平台管理员",
|
||||
RoleType: constants.RoleTypePlatform,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, roleStore.Create(ctx, role))
|
||||
|
||||
accountRole := &model.AccountRole{
|
||||
AccountID: account.ID,
|
||||
RoleID: role.ID,
|
||||
Status: constants.StatusEnabled,
|
||||
Creator: 1,
|
||||
Updater: 1,
|
||||
}
|
||||
require.NoError(t, accountRoleStore.Create(ctx, accountRole))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []uint{role.ID}, roleIDs)
|
||||
})
|
||||
|
||||
t.Run("代理账号有账号级角色,不继承店铺角色", func(t *testing.T) {
|
||||
shopID := uint(1)
|
||||
account := &model.Account{
|
||||
Username: "agent_with_roletest",
|
||||
Phone: "13800010003",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypeAgent,
|
||||
ShopID: &shopID,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
accountRole := &model.Role{
|
||||
RoleName: "账号角色",
|
||||
RoleType: constants.RoleTypeCustomer,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, roleStore.Create(ctx, accountRole))
|
||||
|
||||
shopRole := &model.Role{
|
||||
RoleName: "店铺角色",
|
||||
RoleType: constants.RoleTypeCustomer,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, roleStore.Create(ctx, shopRole))
|
||||
|
||||
require.NoError(t, accountRoleStore.Create(ctx, &model.AccountRole{
|
||||
AccountID: account.ID,
|
||||
RoleID: accountRole.ID,
|
||||
Status: constants.StatusEnabled,
|
||||
Creator: 1,
|
||||
Updater: 1,
|
||||
}))
|
||||
|
||||
require.NoError(t, shopRoleStore.Create(ctx, &model.ShopRole{
|
||||
ShopID: shopID,
|
||||
RoleID: shopRole.ID,
|
||||
Status: constants.StatusEnabled,
|
||||
Creator: 1,
|
||||
Updater: 1,
|
||||
}))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []uint{accountRole.ID}, roleIDs)
|
||||
})
|
||||
|
||||
t.Run("代理账号无账号级角色,继承店铺角色", func(t *testing.T) {
|
||||
shopID := uint(2)
|
||||
account := &model.Account{
|
||||
Username: "agent_inheritest",
|
||||
Phone: "13800010004",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypeAgent,
|
||||
ShopID: &shopID,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
shopRole := &model.Role{
|
||||
RoleName: "店铺默认角色",
|
||||
RoleType: constants.RoleTypeCustomer,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, roleStore.Create(ctx, shopRole))
|
||||
|
||||
require.NoError(t, shopRoleStore.Create(ctx, &model.ShopRole{
|
||||
ShopID: shopID,
|
||||
RoleID: shopRole.ID,
|
||||
Status: constants.StatusEnabled,
|
||||
Creator: 1,
|
||||
Updater: 1,
|
||||
}))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []uint{shopRole.ID}, roleIDs)
|
||||
})
|
||||
|
||||
t.Run("代理账号无角色且店铺无角色,返回空数组", func(t *testing.T) {
|
||||
shopID := uint(3)
|
||||
account := &model.Account{
|
||||
Username: "agent_notest",
|
||||
Phone: "13800010005",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypeAgent,
|
||||
ShopID: &shopID,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, roleIDs)
|
||||
})
|
||||
|
||||
t.Run("企业账号返回账号级角色", func(t *testing.T) {
|
||||
enterpriseID := uint(1)
|
||||
account := &model.Account{
|
||||
Username: "enterprise_roletest",
|
||||
Phone: "13800010006",
|
||||
Password: "hashed",
|
||||
UserType: constants.UserTypeEnterprise,
|
||||
EnterpriseID: &enterpriseID,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, accountStore.Create(ctx, account))
|
||||
|
||||
role := &model.Role{
|
||||
RoleName: "企业管理员",
|
||||
RoleType: constants.RoleTypeCustomer,
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
require.NoError(t, roleStore.Create(ctx, role))
|
||||
|
||||
accountRole := &model.AccountRole{
|
||||
AccountID: account.ID,
|
||||
RoleID: role.ID,
|
||||
Status: constants.StatusEnabled,
|
||||
Creator: 1,
|
||||
Updater: 1,
|
||||
}
|
||||
require.NoError(t, accountRoleStore.Create(ctx, accountRole))
|
||||
|
||||
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []uint{role.ID}, roleIDs)
|
||||
})
|
||||
}
|
||||
@@ -22,6 +22,7 @@ type Service struct {
|
||||
accountStore *postgres.AccountStore
|
||||
roleStore *postgres.RoleStore
|
||||
accountRoleStore *postgres.AccountRoleStore
|
||||
shopRoleStore *postgres.ShopRoleStore
|
||||
shopStore middleware.ShopStoreInterface
|
||||
enterpriseStore middleware.EnterpriseStoreInterface
|
||||
auditService AuditServiceInterface
|
||||
@@ -36,6 +37,7 @@ func New(
|
||||
accountStore *postgres.AccountStore,
|
||||
roleStore *postgres.RoleStore,
|
||||
accountRoleStore *postgres.AccountRoleStore,
|
||||
shopRoleStore *postgres.ShopRoleStore,
|
||||
shopStore middleware.ShopStoreInterface,
|
||||
enterpriseStore middleware.EnterpriseStoreInterface,
|
||||
auditService AuditServiceInterface,
|
||||
@@ -44,6 +46,7 @@ func New(
|
||||
accountStore: accountStore,
|
||||
roleStore: roleStore,
|
||||
accountRoleStore: accountRoleStore,
|
||||
shopRoleStore: shopRoleStore,
|
||||
shopStore: shopStore,
|
||||
enterpriseStore: enterpriseStore,
|
||||
auditService: auditService,
|
||||
|
||||
@@ -69,7 +69,7 @@ func TestAccountService_Create_SuperAdminSuccess(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -111,7 +111,7 @@ func TestAccountService_Create_PlatformUserCreatePlatformAccount(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -150,7 +150,7 @@ func TestAccountService_Create_PlatformUserCreateAgentAccount(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -192,7 +192,7 @@ func TestAccountService_Create_AgentCreateSubordinateShopAccount(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
agentShopID := uint(10)
|
||||
subordinateShopID := uint(11)
|
||||
@@ -238,7 +238,7 @@ func TestAccountService_Create_AgentCreateOtherShopAccountForbidden(t *testing.T
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
agentShopID := uint(10)
|
||||
otherShopID := uint(99)
|
||||
@@ -281,7 +281,7 @@ func TestAccountService_Create_AgentCreatePlatformAccountForbidden(t *testing.T)
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -318,7 +318,7 @@ func TestAccountService_Create_EnterpriseUserForbidden(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -355,7 +355,7 @@ func TestAccountService_Create_UsernameDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -404,7 +404,7 @@ func TestAccountService_Create_PhoneDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -453,7 +453,7 @@ func TestAccountService_Create_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -488,7 +488,7 @@ func TestAccountService_Update_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -534,7 +534,7 @@ func TestAccountService_Update_NotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -565,7 +565,7 @@ func TestAccountService_Update_AgentUnauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -619,7 +619,7 @@ func TestAccountService_Update_UsernameDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -676,7 +676,7 @@ func TestAccountService_Update_PhoneDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -735,7 +735,7 @@ func TestAccountService_Delete_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -778,7 +778,7 @@ func TestAccountService_Delete_NotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -804,7 +804,7 @@ func TestAccountService_Delete_AgentUnauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -855,7 +855,7 @@ func TestAccountService_AssignRoles_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -906,7 +906,7 @@ func TestAccountService_AssignRoles_SuperAdminForbidden(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -947,7 +947,7 @@ func TestAccountService_AssignRoles_RoleTypeMismatch(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -997,7 +997,7 @@ func TestAccountService_AssignRoles_EmptyArrayClearsRoles(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1049,7 +1049,7 @@ func TestAccountService_RemoveRole_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1104,7 +1104,7 @@ func TestAccountService_RemoveRole_AccountNotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1132,7 +1132,7 @@ func TestAccountService_GetRoles_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1183,7 +1183,7 @@ func TestAccountService_GetRoles_EmptyArray(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1224,7 +1224,7 @@ func TestAccountService_List_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1269,7 +1269,7 @@ func TestAccountService_List_FilterByUsername(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1318,7 +1318,7 @@ func TestAccountService_ValidatePassword_Correct(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1357,7 +1357,7 @@ func TestAccountService_ValidatePassword_Incorrect(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1398,7 +1398,7 @@ func TestAccountService_UpdatePassword_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1449,7 +1449,7 @@ func TestAccountService_UpdateStatus_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1494,7 +1494,7 @@ func TestAccountService_Get_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1534,7 +1534,7 @@ func TestAccountService_Get_NotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1560,7 +1560,7 @@ func TestAccountService_UpdatePassword_AccountNotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1586,7 +1586,7 @@ func TestAccountService_UpdateStatus_AccountNotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1612,7 +1612,7 @@ func TestAccountService_UpdatePassword_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1635,7 +1635,7 @@ func TestAccountService_UpdateStatus_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1658,7 +1658,7 @@ func TestAccountService_Delete_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1681,7 +1681,7 @@ func TestAccountService_AssignRoles_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1704,7 +1704,7 @@ func TestAccountService_RemoveRole_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1727,7 +1727,7 @@ func TestAccountService_Update_Unauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -1755,7 +1755,7 @@ func TestAccountService_AssignRoles_NotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1781,7 +1781,7 @@ func TestAccountService_GetRoles_NotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1807,7 +1807,7 @@ func TestAccountService_List_FilterByUserType(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1854,7 +1854,7 @@ func TestAccountService_List_FilterByStatus(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1901,7 +1901,7 @@ func TestAccountService_List_FilterByPhone(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1947,7 +1947,7 @@ func TestAccountService_Update_UpdatePassword(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -1993,7 +1993,7 @@ func TestAccountService_Update_UpdateStatus(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2037,7 +2037,7 @@ func TestAccountService_Update_UpdatePhone(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2081,7 +2081,7 @@ func TestAccountService_AssignRoles_AgentUnauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2130,7 +2130,7 @@ func TestAccountService_Create_EnterpriseAccountSuccess(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2173,7 +2173,7 @@ func TestAccountService_Create_AgentMissingShopID(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2209,7 +2209,7 @@ func TestAccountService_Create_EnterpriseMissingEnterpriseID(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2245,7 +2245,7 @@ func TestAccountService_RemoveRole_AgentUnauthorized(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2294,7 +2294,7 @@ func TestAccountService_AssignRoles_MultipleRoles(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2353,7 +2353,7 @@ func TestAccountService_Update_AllFields(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2409,7 +2409,7 @@ func TestAccountService_ListPlatformAccounts_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2454,7 +2454,7 @@ func TestAccountService_CreateSystemAccount_Success(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2486,7 +2486,7 @@ func TestAccountService_CreateSystemAccount_MissingUsername(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2517,7 +2517,7 @@ func TestAccountService_CreateSystemAccount_MissingPhone(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2548,7 +2548,7 @@ func TestAccountService_CreateSystemAccount_MissingPassword(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2579,7 +2579,7 @@ func TestAccountService_CreateSystemAccount_UsernameDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2625,7 +2625,7 @@ func TestAccountService_CreateSystemAccount_PhoneDuplicate(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -2671,7 +2671,7 @@ func TestAccountService_ListPlatformAccounts_FilterByUsername(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2717,7 +2717,7 @@ func TestAccountService_ListPlatformAccounts_FilterByPhone(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2763,7 +2763,7 @@ func TestAccountService_ListPlatformAccounts_FilterByStatus(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2810,7 +2810,7 @@ func TestAccountService_Create_PlatformUserCreateEnterpriseAccount(t *testing.T)
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2852,7 +2852,7 @@ func TestAccountService_List_DefaultPagination(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2882,7 +2882,7 @@ func TestAccountService_ListPlatformAccounts_DefaultPagination(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2912,7 +2912,7 @@ func TestAccountService_AssignRoles_RoleNotFound(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2953,7 +2953,7 @@ func TestAccountService_Update_SameUsername(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -2996,7 +2996,7 @@ func TestAccountService_Update_SamePhone(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3039,7 +3039,7 @@ func TestAccountService_AssignRoles_DuplicateRoles(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3086,7 +3086,7 @@ func TestAccountService_Create_PlatformUserCreateAgentWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3129,7 +3129,7 @@ func TestAccountService_AssignRoles_CustomerAccountType(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3179,7 +3179,7 @@ func TestAccountService_Delete_AgentAccountWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3231,7 +3231,7 @@ func TestAccountService_Update_AgentAccountWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3286,7 +3286,7 @@ func TestAccountService_AssignRoles_AgentAccountWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3344,7 +3344,7 @@ func TestAccountService_RemoveRole_AgentAccountWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3408,7 +3408,7 @@ func TestAccountService_Create_EnterpriseAccountWithShop(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
ctx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3454,7 +3454,7 @@ func TestAccountService_Delete_PlatformAccountByAgent(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3501,7 +3501,7 @@ func TestAccountService_Update_PlatformAccountByAgent(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3553,7 +3553,7 @@ func TestAccountService_AssignRoles_PlatformAccountByAgent(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
@@ -3600,7 +3600,7 @@ func TestAccountService_RemoveRole_PlatformAccountByAgent(t *testing.T) {
|
||||
mockShop := new(MockShopStore)
|
||||
mockEnterprise := new(MockEnterpriseStore)
|
||||
|
||||
svc := New(accountStore, roleStore, accountRoleStore, mockShop, mockEnterprise, mockAudit)
|
||||
svc := New(accountStore, roleStore, accountRoleStore, nil, mockShop, mockEnterprise, mockAudit)
|
||||
|
||||
superAdminCtx := middleware.SetUserContext(context.Background(), &middleware.UserContextInfo{
|
||||
UserID: 1,
|
||||
|
||||
Reference in New Issue
Block a user