refactor: 将 DTO 文件从 internal/model 移动到 internal/model/dto 目录
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m22s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m22s
- 移动 17 个 DTO 文件到 internal/model/dto/ 目录 - 更新所有 DTO 文件的 package 声明从 model 改为 dto - 更新所有引用文件的 import 和类型引用 - Handler 层:admin 和 h5 所有处理器 - Service 层:所有业务服务 - Routes 层:所有路由定义 - Tests 层:单元测试和集成测试 - 清理未使用的 import 语句 - 验证:项目构建成功,测试编译通过,LSP 无错误
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
@@ -183,7 +184,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
||||
createTestAccount(t, env.db, rootAccount)
|
||||
|
||||
t.Run("成功创建平台账号", func(t *testing.T) {
|
||||
reqBody := model.CreateAccountRequest{
|
||||
reqBody := dto.CreateAccountRequest{
|
||||
Username: "platform_user",
|
||||
Phone: "13800000001",
|
||||
Password: "Password123",
|
||||
@@ -221,7 +222,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
||||
createTestAccount(t, env.db, existingAccount)
|
||||
|
||||
// 尝试创建同名账号
|
||||
reqBody := model.CreateAccountRequest{
|
||||
reqBody := dto.CreateAccountRequest{
|
||||
Username: "existing_user",
|
||||
Phone: "13800000003",
|
||||
Password: "Password123",
|
||||
@@ -242,7 +243,7 @@ func TestAccountAPI_Create(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("非root用户缺少parent_id时返回错误", func(t *testing.T) {
|
||||
reqBody := model.CreateAccountRequest{
|
||||
reqBody := dto.CreateAccountRequest{
|
||||
Username: "no_parent_user",
|
||||
Phone: "13800000004",
|
||||
Password: "Password123",
|
||||
@@ -347,7 +348,7 @@ func TestAccountAPI_Update(t *testing.T) {
|
||||
|
||||
t.Run("成功更新账号", func(t *testing.T) {
|
||||
newUsername := "updated_user"
|
||||
reqBody := model.UpdateAccountRequest{
|
||||
reqBody := dto.UpdateAccountRequest{
|
||||
Username: &newUsername,
|
||||
}
|
||||
|
||||
@@ -480,7 +481,7 @@ func TestAccountAPI_AssignRoles(t *testing.T) {
|
||||
env.db.Create(testRole)
|
||||
|
||||
t.Run("成功分配角色", func(t *testing.T) {
|
||||
reqBody := model.AssignRolesRequest{
|
||||
reqBody := dto.AssignRolesRequest{
|
||||
RoleIDs: []uint{testRole.ID},
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
permissionService "github.com/break/junhong_cmp_fiber/internal/service/permission"
|
||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
@@ -148,7 +149,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("成功创建权限", func(t *testing.T) {
|
||||
reqBody := model.CreatePermissionRequest{
|
||||
reqBody := dto.CreatePermissionRequest{
|
||||
PermName: "用户管理",
|
||||
PermCode: "user:manage",
|
||||
PermType: constants.PermissionTypeMenu,
|
||||
@@ -185,7 +186,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
env.db.Create(existingPerm)
|
||||
|
||||
// 尝试创建相同编码的权限
|
||||
reqBody := model.CreatePermissionRequest{
|
||||
reqBody := dto.CreatePermissionRequest{
|
||||
PermName: "新权限",
|
||||
PermCode: "existing:perm",
|
||||
PermType: constants.PermissionTypeMenu,
|
||||
@@ -215,7 +216,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
env.db.Create(parentPerm)
|
||||
|
||||
// 创建子权限
|
||||
reqBody := model.CreatePermissionRequest{
|
||||
reqBody := dto.CreatePermissionRequest{
|
||||
PermName: "用户列表",
|
||||
PermCode: "system:user:list",
|
||||
PermType: constants.PermissionTypeButton,
|
||||
@@ -308,7 +309,7 @@ func TestPermissionAPI_Update(t *testing.T) {
|
||||
|
||||
t.Run("成功更新权限", func(t *testing.T) {
|
||||
newName := "更新后权限"
|
||||
reqBody := model.UpdatePermissionRequest{
|
||||
reqBody := dto.UpdatePermissionRequest{
|
||||
PermName: &newName,
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
accountService "github.com/break/junhong_cmp_fiber/internal/service/account"
|
||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
@@ -147,7 +148,7 @@ func TestPlatformAccountAPI_UpdatePassword(t *testing.T) {
|
||||
db.Create(testAccount)
|
||||
|
||||
t.Run("成功修改密码", func(t *testing.T) {
|
||||
reqBody := model.UpdatePasswordRequest{
|
||||
reqBody := dto.UpdatePasswordRequest{
|
||||
NewPassword: "NewPassword@123",
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -169,7 +170,7 @@ func TestPlatformAccountAPI_UpdatePassword(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("账号不存在返回错误", func(t *testing.T) {
|
||||
reqBody := model.UpdatePasswordRequest{
|
||||
reqBody := dto.UpdatePasswordRequest{
|
||||
NewPassword: "NewPassword@123",
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -221,7 +222,7 @@ func TestPlatformAccountAPI_UpdateStatus(t *testing.T) {
|
||||
db.Create(testAccount)
|
||||
|
||||
t.Run("成功禁用账号", func(t *testing.T) {
|
||||
reqBody := model.UpdateStatusRequest{
|
||||
reqBody := dto.UpdateStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -238,7 +239,7 @@ func TestPlatformAccountAPI_UpdateStatus(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("成功启用账号", func(t *testing.T) {
|
||||
reqBody := model.UpdateStatusRequest{
|
||||
reqBody := dto.UpdateStatusRequest{
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -306,7 +307,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
||||
db.Create(testRole)
|
||||
|
||||
t.Run("超级管理员禁止分配角色", func(t *testing.T) {
|
||||
reqBody := model.AssignRolesRequest{
|
||||
reqBody := dto.AssignRolesRequest{
|
||||
RoleIDs: []uint{testRole.ID},
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -324,7 +325,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("平台用户成功分配角色", func(t *testing.T) {
|
||||
reqBody := model.AssignRolesRequest{
|
||||
reqBody := dto.AssignRolesRequest{
|
||||
RoleIDs: []uint{testRole.ID},
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
@@ -341,7 +342,7 @@ func TestPlatformAccountAPI_AssignRoles(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("空数组清空所有角色", func(t *testing.T) {
|
||||
reqBody := model.AssignRolesRequest{
|
||||
reqBody := dto.AssignRolesRequest{
|
||||
RoleIDs: []uint{},
|
||||
}
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
roleService "github.com/break/junhong_cmp_fiber/internal/service/role"
|
||||
postgresStore "github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
@@ -165,7 +166,7 @@ func TestRoleAPI_Create(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("成功创建角色", func(t *testing.T) {
|
||||
reqBody := model.CreateRoleRequest{
|
||||
reqBody := dto.CreateRoleRequest{
|
||||
RoleName: "测试角色",
|
||||
RoleDesc: "这是一个测试角色",
|
||||
RoleType: constants.RoleTypePlatform,
|
||||
@@ -277,7 +278,7 @@ func TestRoleAPI_Update(t *testing.T) {
|
||||
|
||||
t.Run("成功更新角色", func(t *testing.T) {
|
||||
newName := "更新后角色"
|
||||
reqBody := model.UpdateRoleRequest{
|
||||
reqBody := dto.UpdateRoleRequest{
|
||||
RoleName: &newName,
|
||||
}
|
||||
|
||||
@@ -398,7 +399,7 @@ func TestRoleAPI_AssignPermissions(t *testing.T) {
|
||||
env.db.Create(testPerm)
|
||||
|
||||
t.Run("成功分配权限", func(t *testing.T) {
|
||||
reqBody := model.AssignPermissionsRequest{
|
||||
reqBody := dto.AssignPermissionsRequest{
|
||||
PermIDs: []uint{testPerm.ID},
|
||||
}
|
||||
|
||||
@@ -540,7 +541,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
env.db.Create(testRole)
|
||||
|
||||
t.Run("成功禁用角色", func(t *testing.T) {
|
||||
reqBody := model.UpdateRoleStatusRequest{
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
}
|
||||
|
||||
@@ -564,7 +565,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("成功启用角色", func(t *testing.T) {
|
||||
reqBody := model.UpdateRoleStatusRequest{
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
|
||||
@@ -588,7 +589,7 @@ func TestRoleAPI_UpdateStatus(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("角色不存在返回错误", func(t *testing.T) {
|
||||
reqBody := model.UpdateRoleStatusRequest{
|
||||
reqBody := dto.UpdateRoleStatusRequest{
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/config"
|
||||
@@ -147,7 +148,7 @@ func TestShopAccount_CreateAccount(t *testing.T) {
|
||||
env := setupShopAccountTestEnv(t)
|
||||
defer env.teardown()
|
||||
|
||||
reqBody := model.CreateShopAccountRequest{
|
||||
reqBody := dto.CreateShopAccountRequest{
|
||||
ShopID: env.testShop.ID,
|
||||
Username: "agent001",
|
||||
Phone: "13800138001",
|
||||
@@ -193,7 +194,7 @@ func TestShopAccount_CreateAccount_InvalidShop(t *testing.T) {
|
||||
env := setupShopAccountTestEnv(t)
|
||||
defer env.teardown()
|
||||
|
||||
reqBody := model.CreateShopAccountRequest{
|
||||
reqBody := dto.CreateShopAccountRequest{
|
||||
ShopID: 99999, // 不存在的商户ID
|
||||
Username: "agent002",
|
||||
Phone: "13800138002",
|
||||
@@ -262,7 +263,7 @@ func TestShopAccount_UpdateAccount(t *testing.T) {
|
||||
account := testutil.CreateAgentUser(t, env.db, env.testShop.ID)
|
||||
|
||||
// 更新账号用户名
|
||||
reqBody := model.UpdateShopAccountRequest{
|
||||
reqBody := dto.UpdateShopAccountRequest{
|
||||
Username: "updated_agent",
|
||||
}
|
||||
|
||||
@@ -303,7 +304,7 @@ func TestShopAccount_UpdatePassword(t *testing.T) {
|
||||
|
||||
// 重置密码
|
||||
newPassword := "newpassword456"
|
||||
reqBody := model.UpdateShopAccountPasswordRequest{
|
||||
reqBody := dto.UpdateShopAccountPasswordRequest{
|
||||
NewPassword: newPassword,
|
||||
}
|
||||
|
||||
@@ -349,7 +350,7 @@ func TestShopAccount_UpdateStatus(t *testing.T) {
|
||||
require.Equal(t, 1, account.Status)
|
||||
|
||||
// 禁用账号
|
||||
reqBody := model.UpdateShopAccountStatusRequest{
|
||||
reqBody := dto.UpdateShopAccountStatusRequest{
|
||||
Status: 2, // 禁用
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/auth"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/config"
|
||||
@@ -141,7 +142,7 @@ func TestShopManagement_CreateShop(t *testing.T) {
|
||||
env := setupShopManagementTestEnv(t)
|
||||
defer env.teardown()
|
||||
|
||||
reqBody := model.CreateShopRequest{
|
||||
reqBody := dto.CreateShopRequest{
|
||||
ShopName: "测试商户",
|
||||
ShopCode: "TEST001",
|
||||
InitUsername: "testuser",
|
||||
@@ -191,7 +192,7 @@ func TestShopManagement_CreateShop_DuplicateCode(t *testing.T) {
|
||||
defer env.teardown()
|
||||
|
||||
// 通过 API 创建第一个商户
|
||||
firstReq := model.CreateShopRequest{
|
||||
firstReq := dto.CreateShopRequest{
|
||||
ShopName: "商户1",
|
||||
ShopCode: "DUP001",
|
||||
InitUsername: "dupuser1",
|
||||
@@ -210,7 +211,7 @@ func TestShopManagement_CreateShop_DuplicateCode(t *testing.T) {
|
||||
require.Equal(t, 0, firstResult.Code, "第一个商户应该创建成功")
|
||||
|
||||
// 尝试创建编码重复的商户
|
||||
reqBody := model.CreateShopRequest{
|
||||
reqBody := dto.CreateShopRequest{
|
||||
ShopName: "商户2",
|
||||
ShopCode: "DUP001", // 使用相同编码
|
||||
InitUsername: "dupuser2",
|
||||
@@ -281,7 +282,7 @@ func TestShopManagement_UpdateShop(t *testing.T) {
|
||||
shop := testutil.CreateTestShop(t, env.db, "原始商户", "ORIG001", 1, nil)
|
||||
|
||||
// 更新商户
|
||||
reqBody := model.UpdateShopRequest{
|
||||
reqBody := dto.UpdateShopRequest{
|
||||
ShopName: "更新后的商户",
|
||||
Status: 1,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -36,7 +36,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
||||
t.Run("查询提现申请列表-空结果", func(t *testing.T) {
|
||||
ctx := createWithdrawalTestContext(1)
|
||||
|
||||
req := &model.WithdrawalRequestListReq{
|
||||
req := &dto.WithdrawalRequestListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -51,7 +51,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
||||
ctx := createWithdrawalTestContext(1)
|
||||
|
||||
status := 1
|
||||
req := &model.WithdrawalRequestListReq{
|
||||
req := &dto.WithdrawalRequestListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
Status: &status,
|
||||
@@ -65,7 +65,7 @@ func TestCommissionWithdrawalService_ListWithdrawalRequests(t *testing.T) {
|
||||
t.Run("按时间范围筛选提现申请", func(t *testing.T) {
|
||||
ctx := createWithdrawalTestContext(1)
|
||||
|
||||
req := &model.WithdrawalRequestListReq{
|
||||
req := &dto.WithdrawalRequestListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
StartTime: "2025-01-01 00:00:00",
|
||||
@@ -93,7 +93,7 @@ func TestCommissionWithdrawalService_Approve(t *testing.T) {
|
||||
t.Run("审批不存在的提现申请应失败", func(t *testing.T) {
|
||||
ctx := createWithdrawalTestContext(1)
|
||||
|
||||
req := &model.ApproveWithdrawalReq{
|
||||
req := &dto.ApproveWithdrawalReq{
|
||||
PaymentType: "manual",
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ func TestCommissionWithdrawalService_Reject(t *testing.T) {
|
||||
t.Run("拒绝不存在的提现申请应失败", func(t *testing.T) {
|
||||
ctx := createWithdrawalTestContext(1)
|
||||
|
||||
req := &model.RejectWithdrawalReq{
|
||||
req := &dto.RejectWithdrawalReq{
|
||||
Remark: "测试拒绝原因",
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -33,7 +33,7 @@ func TestCommissionWithdrawalSettingService_Create(t *testing.T) {
|
||||
t.Run("新增提现配置", func(t *testing.T) {
|
||||
ctx := createWithdrawalSettingTestContext(1)
|
||||
|
||||
req := &model.CreateWithdrawalSettingReq{
|
||||
req := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: 5,
|
||||
MinWithdrawalAmount: 10000,
|
||||
FeeRate: 100,
|
||||
@@ -51,7 +51,7 @@ func TestCommissionWithdrawalSettingService_Create(t *testing.T) {
|
||||
t.Run("未授权用户创建配置应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.CreateWithdrawalSettingReq{
|
||||
req := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: 5,
|
||||
MinWithdrawalAmount: 10000,
|
||||
FeeRate: 100,
|
||||
@@ -74,7 +74,7 @@ func TestCommissionWithdrawalSettingService_ConfigSwitch(t *testing.T) {
|
||||
t.Run("配置切换-旧配置自动失效", func(t *testing.T) {
|
||||
ctx := createWithdrawalSettingTestContext(1)
|
||||
|
||||
req1 := &model.CreateWithdrawalSettingReq{
|
||||
req1 := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: 3,
|
||||
MinWithdrawalAmount: 5000,
|
||||
FeeRate: 50,
|
||||
@@ -83,7 +83,7 @@ func TestCommissionWithdrawalSettingService_ConfigSwitch(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.True(t, result1.IsActive)
|
||||
|
||||
req2 := &model.CreateWithdrawalSettingReq{
|
||||
req2 := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: 10,
|
||||
MinWithdrawalAmount: 20000,
|
||||
FeeRate: 200,
|
||||
@@ -114,7 +114,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
||||
t.Run("查询配置列表-空结果", func(t *testing.T) {
|
||||
ctx := createWithdrawalSettingTestContext(1)
|
||||
|
||||
req := &model.WithdrawalSettingListReq{
|
||||
req := &dto.WithdrawalSettingListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
||||
ctx := createWithdrawalSettingTestContext(1)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
req := &model.CreateWithdrawalSettingReq{
|
||||
req := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: i + 1,
|
||||
MinWithdrawalAmount: int64((i + 1) * 1000),
|
||||
FeeRate: int64((i + 1) * 10),
|
||||
@@ -138,7 +138,7 @@ func TestCommissionWithdrawalSettingService_List(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
listReq := &model.WithdrawalSettingListReq{
|
||||
listReq := &dto.WithdrawalSettingListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func TestCommissionWithdrawalSettingService_GetCurrent(t *testing.T) {
|
||||
t.Run("获取当前配置-有配置时正常返回", func(t *testing.T) {
|
||||
ctx := createWithdrawalSettingTestContext(1)
|
||||
|
||||
req := &model.CreateWithdrawalSettingReq{
|
||||
req := &dto.CreateWithdrawalSettingReq{
|
||||
DailyWithdrawalLimit: 5,
|
||||
MinWithdrawalAmount: 10000,
|
||||
FeeRate: 100,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -34,7 +35,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
||||
t.Run("查询账号列表-空结果", func(t *testing.T) {
|
||||
ctx := createCustomerAccountTestContext(1)
|
||||
|
||||
req := &model.CustomerAccountListReq{
|
||||
req := &dto.CustomerAccountListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -61,7 +62,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "测试账号用户",
|
||||
Phone: "13900000001",
|
||||
Password: "Test123456",
|
||||
@@ -70,7 +71,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
||||
_, err = service.Create(ctx, createReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.CustomerAccountListReq{
|
||||
req := &dto.CustomerAccountListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
Username: "测试账号",
|
||||
@@ -98,7 +99,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "店铺筛选账号",
|
||||
Phone: "13900000002",
|
||||
Password: "Test123456",
|
||||
@@ -107,7 +108,7 @@ func TestCustomerAccountService_List(t *testing.T) {
|
||||
_, err = service.Create(ctx, createReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.CustomerAccountListReq{
|
||||
req := &dto.CustomerAccountListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
ShopID: &shop.ID,
|
||||
@@ -146,7 +147,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.CreateCustomerAccountReq{
|
||||
req := &dto.CreateCustomerAccountReq{
|
||||
Username: "新代理账号",
|
||||
Phone: "13900000010",
|
||||
Password: "Test123456",
|
||||
@@ -178,7 +179,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req1 := &model.CreateCustomerAccountReq{
|
||||
req1 := &dto.CreateCustomerAccountReq{
|
||||
Username: "账号一",
|
||||
Phone: "13900000011",
|
||||
Password: "Test123456",
|
||||
@@ -187,7 +188,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
||||
_, err = service.Create(ctx, req1)
|
||||
require.NoError(t, err)
|
||||
|
||||
req2 := &model.CreateCustomerAccountReq{
|
||||
req2 := &dto.CreateCustomerAccountReq{
|
||||
Username: "账号二",
|
||||
Phone: "13900000011",
|
||||
Password: "Test123456",
|
||||
@@ -200,7 +201,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
||||
t.Run("新增账号-店铺不存在应失败", func(t *testing.T) {
|
||||
ctx := createCustomerAccountTestContext(1)
|
||||
|
||||
req := &model.CreateCustomerAccountReq{
|
||||
req := &dto.CreateCustomerAccountReq{
|
||||
Username: "无效店铺账号",
|
||||
Phone: "13900000012",
|
||||
Password: "Test123456",
|
||||
@@ -214,7 +215,7 @@ func TestCustomerAccountService_Create(t *testing.T) {
|
||||
t.Run("新增账号-未授权用户应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.CreateCustomerAccountReq{
|
||||
req := &dto.CreateCustomerAccountReq{
|
||||
Username: "未授权账号",
|
||||
Phone: "13900000013",
|
||||
Password: "Test123456",
|
||||
@@ -252,7 +253,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "待编辑账号",
|
||||
Phone: "13900000020",
|
||||
Password: "Test123456",
|
||||
@@ -262,7 +263,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
newName := "编辑后账号"
|
||||
updateReq := &model.UpdateCustomerAccountReq{
|
||||
updateReq := &dto.UpdateCustomerAccountRequest{
|
||||
Username: &newName,
|
||||
}
|
||||
|
||||
@@ -275,7 +276,7 @@ func TestCustomerAccountService_Update(t *testing.T) {
|
||||
ctx := createCustomerAccountTestContext(1)
|
||||
|
||||
newName := "不存在账号"
|
||||
updateReq := &model.UpdateCustomerAccountReq{
|
||||
updateReq := &dto.UpdateCustomerAccountRequest{
|
||||
Username: &newName,
|
||||
}
|
||||
|
||||
@@ -310,7 +311,7 @@ func TestCustomerAccountService_UpdatePassword(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "密码测试账号",
|
||||
Phone: "13900000030",
|
||||
Password: "OldPass123",
|
||||
@@ -363,7 +364,7 @@ func TestCustomerAccountService_UpdateStatus(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "状态测试账号",
|
||||
Phone: "13900000040",
|
||||
Password: "Test123456",
|
||||
@@ -397,7 +398,7 @@ func TestCustomerAccountService_UpdateStatus(t *testing.T) {
|
||||
err := db.Create(shop).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
createReq := &model.CreateCustomerAccountReq{
|
||||
createReq := &dto.CreateCustomerAccountReq{
|
||||
Username: "启用测试账号",
|
||||
Phone: "13900000041",
|
||||
Password: "Test123456",
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -34,7 +35,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
||||
t.Run("授权预检-企业不存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseCardTestContext(1, 1)
|
||||
|
||||
req := &model.AllocateCardsPreviewReq{
|
||||
req := &dto.AllocateCardsPreviewReq{
|
||||
ICCIDs: []string{"898600000001"},
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
||||
t.Run("授权预检-未授权用户应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.AllocateCardsPreviewReq{
|
||||
req := &dto.AllocateCardsPreviewReq{
|
||||
ICCIDs: []string{"898600000001"},
|
||||
}
|
||||
|
||||
@@ -66,7 +67,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
||||
err := db.Create(ent).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.AllocateCardsPreviewReq{
|
||||
req := &dto.AllocateCardsPreviewReq{
|
||||
ICCIDs: []string{},
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
||||
err := db.Create(ent).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.AllocateCardsPreviewReq{
|
||||
req := &dto.AllocateCardsPreviewReq{
|
||||
ICCIDs: []string{"NON_EXIST_ICCID"},
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ func TestEnterpriseCardService_AllocateCardsPreview(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.AllocateCardsPreviewReq{
|
||||
req := &dto.AllocateCardsPreviewReq{
|
||||
ICCIDs: []string{"898600001234567890"},
|
||||
}
|
||||
|
||||
@@ -148,7 +149,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
||||
t.Run("授权卡-企业不存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseCardTestContext(1, 1)
|
||||
|
||||
req := &model.AllocateCardsReq{
|
||||
req := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600000001"},
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.AllocateCardsReq{
|
||||
req := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600002345678901"},
|
||||
}
|
||||
|
||||
@@ -212,7 +213,7 @@ func TestEnterpriseCardService_AllocateCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.AllocateCardsReq{
|
||||
req := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600003456789012"},
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
||||
t.Run("回收授权-企业不存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseCardTestContext(1, 1)
|
||||
|
||||
req := &model.RecallCardsReq{
|
||||
req := &dto.RecallCardsReq{
|
||||
ICCIDs: []string{"898600000001"},
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.RecallCardsReq{
|
||||
req := &dto.RecallCardsReq{
|
||||
ICCIDs: []string{"898600004567890123"},
|
||||
}
|
||||
|
||||
@@ -306,13 +307,13 @@ func TestEnterpriseCardService_RecallCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
allocReq := &model.AllocateCardsReq{
|
||||
allocReq := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600005678901234"},
|
||||
}
|
||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
recallReq := &model.RecallCardsReq{
|
||||
recallReq := &dto.RecallCardsReq{
|
||||
ICCIDs: []string{"898600005678901234"},
|
||||
}
|
||||
result, err := service.RecallCards(ctx, ent.ID, recallReq)
|
||||
@@ -334,7 +335,7 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
||||
t.Run("查询企业卡列表-企业不存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseCardTestContext(1, 1)
|
||||
|
||||
req := &model.EnterpriseCardListReq{
|
||||
req := &dto.EnterpriseCardListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -356,7 +357,7 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
||||
err := db.Create(ent).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.EnterpriseCardListReq{
|
||||
req := &dto.EnterpriseCardListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -390,13 +391,13 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
allocReq := &model.AllocateCardsReq{
|
||||
allocReq := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600006789012345"},
|
||||
}
|
||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.EnterpriseCardListReq{
|
||||
req := &dto.EnterpriseCardListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -432,13 +433,13 @@ func TestEnterpriseCardService_ListCards(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
allocReq := &model.AllocateCardsReq{
|
||||
allocReq := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600007890123456"},
|
||||
}
|
||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.EnterpriseCardListReq{
|
||||
req := &dto.EnterpriseCardListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
ICCID: "78901",
|
||||
@@ -511,7 +512,7 @@ func TestEnterpriseCardService_SuspendAndResumeCard(t *testing.T) {
|
||||
err = db.Create(card).Error
|
||||
require.NoError(t, err)
|
||||
|
||||
allocReq := &model.AllocateCardsReq{
|
||||
allocReq := &dto.AllocateCardsReq{
|
||||
ICCIDs: []string{"898600009012345678"},
|
||||
}
|
||||
_, err = service.AllocateCards(ctx, ent.ID, allocReq)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -34,7 +35,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
t.Run("创建企业-含账号创建", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
req := &model.CreateEnterpriseReq{
|
||||
req := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "测试企业",
|
||||
EnterpriseCode: "ENT_TEST_001",
|
||||
ContactName: "测试联系人",
|
||||
@@ -55,7 +56,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
t.Run("创建企业-企业编号已存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
req1 := &model.CreateEnterpriseReq{
|
||||
req1 := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "企业一",
|
||||
EnterpriseCode: "ENT_DUP_001",
|
||||
ContactName: "联系人一",
|
||||
@@ -66,7 +67,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
_, err := service.Create(ctx, req1)
|
||||
require.NoError(t, err)
|
||||
|
||||
req2 := &model.CreateEnterpriseReq{
|
||||
req2 := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "企业二",
|
||||
EnterpriseCode: "ENT_DUP_001",
|
||||
ContactName: "联系人二",
|
||||
@@ -81,7 +82,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
t.Run("创建企业-手机号已存在应失败", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
req1 := &model.CreateEnterpriseReq{
|
||||
req1 := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "企业三",
|
||||
EnterpriseCode: "ENT_PHONE_001",
|
||||
ContactName: "联系人三",
|
||||
@@ -92,7 +93,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
_, err := service.Create(ctx, req1)
|
||||
require.NoError(t, err)
|
||||
|
||||
req2 := &model.CreateEnterpriseReq{
|
||||
req2 := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "企业四",
|
||||
EnterpriseCode: "ENT_PHONE_002",
|
||||
ContactName: "联系人四",
|
||||
@@ -107,7 +108,7 @@ func TestEnterpriseService_Create(t *testing.T) {
|
||||
t.Run("创建企业-未授权用户应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.CreateEnterpriseReq{
|
||||
req := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "未授权企业",
|
||||
EnterpriseCode: "ENT_UNAUTH_001",
|
||||
ContactName: "联系人",
|
||||
@@ -134,7 +135,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
||||
t.Run("编辑企业", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
createReq := &model.CreateEnterpriseReq{
|
||||
createReq := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "待编辑企业",
|
||||
EnterpriseCode: "ENT_EDIT_001",
|
||||
ContactName: "原联系人",
|
||||
@@ -147,7 +148,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
||||
|
||||
newName := "编辑后企业"
|
||||
newContact := "新联系人"
|
||||
updateReq := &model.UpdateEnterpriseRequest{
|
||||
updateReq := &dto.UpdateEnterpriseRequest{
|
||||
EnterpriseName: &newName,
|
||||
ContactName: &newContact,
|
||||
}
|
||||
@@ -162,7 +163,7 @@ func TestEnterpriseService_Update(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
newName := "不存在企业"
|
||||
updateReq := &model.UpdateEnterpriseRequest{
|
||||
updateReq := &dto.UpdateEnterpriseRequest{
|
||||
EnterpriseName: &newName,
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ func TestEnterpriseService_UpdateStatus(t *testing.T) {
|
||||
t.Run("禁用企业-账号同步禁用", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
createReq := &model.CreateEnterpriseReq{
|
||||
createReq := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "待禁用企业",
|
||||
EnterpriseCode: "ENT_STATUS_001",
|
||||
ContactName: "联系人",
|
||||
@@ -211,7 +212,7 @@ func TestEnterpriseService_UpdateStatus(t *testing.T) {
|
||||
t.Run("启用企业-账号同步启用", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
createReq := &model.CreateEnterpriseReq{
|
||||
createReq := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "待启用企业",
|
||||
EnterpriseCode: "ENT_STATUS_002",
|
||||
ContactName: "联系人",
|
||||
@@ -259,7 +260,7 @@ func TestEnterpriseService_UpdatePassword(t *testing.T) {
|
||||
t.Run("修改企业账号密码", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
createReq := &model.CreateEnterpriseReq{
|
||||
createReq := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "密码测试企业",
|
||||
EnterpriseCode: "ENT_PWD_001",
|
||||
ContactName: "联系人",
|
||||
@@ -301,7 +302,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
||||
t.Run("查询企业列表-空结果", func(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
req := &model.EnterpriseListReq{
|
||||
req := &dto.EnterpriseListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -316,7 +317,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
createReq := &model.CreateEnterpriseReq{
|
||||
createReq := &dto.CreateEnterpriseReq{
|
||||
EnterpriseName: "列表测试企业",
|
||||
EnterpriseCode: "ENT_LIST_" + string(rune('A'+i)),
|
||||
ContactName: "联系人",
|
||||
@@ -328,7 +329,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
req := &model.EnterpriseListReq{
|
||||
req := &dto.EnterpriseListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
EnterpriseName: "列表测试",
|
||||
@@ -344,7 +345,7 @@ func TestEnterpriseService_List(t *testing.T) {
|
||||
ctx := createEnterpriseTestContext(1)
|
||||
|
||||
status := constants.StatusEnabled
|
||||
req := &model.EnterpriseListReq{
|
||||
req := &dto.EnterpriseListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
Status: &status,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/my_commission"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -110,7 +111,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
||||
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
req := &model.CreateMyWithdrawalReq{
|
||||
req := &dto.CreateMyWithdrawalReq{
|
||||
Amount: 10000,
|
||||
WithdrawalMethod: "alipay",
|
||||
AccountName: "测试用户",
|
||||
@@ -148,7 +149,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
||||
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
req := &model.CreateMyWithdrawalReq{
|
||||
req := &dto.CreateMyWithdrawalReq{
|
||||
Amount: 5000,
|
||||
WithdrawalMethod: "alipay",
|
||||
AccountName: "测试用户",
|
||||
@@ -184,7 +185,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
||||
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
req := &model.CreateMyWithdrawalReq{
|
||||
req := &dto.CreateMyWithdrawalReq{
|
||||
Amount: 50000,
|
||||
WithdrawalMethod: "alipay",
|
||||
AccountName: "测试用户",
|
||||
@@ -198,7 +199,7 @@ func TestMyCommissionService_CreateWithdrawalRequest(t *testing.T) {
|
||||
t.Run("发起提现-非代理商用户应失败", func(t *testing.T) {
|
||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||
|
||||
req := &model.CreateMyWithdrawalReq{
|
||||
req := &dto.CreateMyWithdrawalReq{
|
||||
Amount: 10000,
|
||||
WithdrawalMethod: "alipay",
|
||||
AccountName: "测试用户",
|
||||
@@ -243,7 +244,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
||||
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
req := &model.MyWithdrawalListReq{
|
||||
req := &dto.MyWithdrawalListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -271,7 +272,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
status := 1
|
||||
req := &model.MyWithdrawalListReq{
|
||||
req := &dto.MyWithdrawalListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
Status: &status,
|
||||
@@ -285,7 +286,7 @@ func TestMyCommissionService_ListMyWithdrawalRequests(t *testing.T) {
|
||||
t.Run("查询提现记录-非代理商用户应失败", func(t *testing.T) {
|
||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||
|
||||
req := &model.MyWithdrawalListReq{
|
||||
req := &dto.MyWithdrawalListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -328,7 +329,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
||||
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
req := &model.MyCommissionRecordListReq{
|
||||
req := &dto.MyCommissionRecordListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -356,7 +357,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
||||
ctx := createMyCommissionTestContext(1, shop.ID, constants.UserTypeAgent)
|
||||
|
||||
commissionType := "one_time"
|
||||
req := &model.MyCommissionRecordListReq{
|
||||
req := &dto.MyCommissionRecordListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
CommissionType: &commissionType,
|
||||
@@ -370,7 +371,7 @@ func TestMyCommissionService_ListMyCommissionRecords(t *testing.T) {
|
||||
t.Run("查询佣金明细-非代理商用户应失败", func(t *testing.T) {
|
||||
ctx := createMyCommissionTestContext(1, 1, constants.UserTypePlatform)
|
||||
|
||||
req := &model.MyCommissionRecordListReq{
|
||||
req := &dto.MyCommissionRecordListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/permission"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -42,7 +43,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
||||
|
||||
// 测试查询全部权限(不过滤)
|
||||
t.Run("查询全部权限", func(t *testing.T) {
|
||||
req := &model.PermissionListRequest{
|
||||
req := &dto.PermissionListRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
}
|
||||
@@ -54,7 +55,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
||||
|
||||
// 测试只查询 all 权限
|
||||
t.Run("只查询all端口权限", func(t *testing.T) {
|
||||
req := &model.PermissionListRequest{
|
||||
req := &dto.PermissionListRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
Platform: constants.PlatformAll,
|
||||
@@ -68,7 +69,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
||||
|
||||
// 测试只查询 web 权限
|
||||
t.Run("只查询web端口权限", func(t *testing.T) {
|
||||
req := &model.PermissionListRequest{
|
||||
req := &dto.PermissionListRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
Platform: constants.PlatformWeb,
|
||||
@@ -85,7 +86,7 @@ func TestPermissionPlatformFilter_List(t *testing.T) {
|
||||
|
||||
// 测试只查询 h5 权限
|
||||
t.Run("只查询h5端口权限", func(t *testing.T) {
|
||||
req := &model.PermissionListRequest{
|
||||
req := &dto.PermissionListRequest{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
Platform: constants.PlatformH5,
|
||||
@@ -115,7 +116,7 @@ func TestPermissionPlatformFilter_CreateWithDefaultPlatform(t *testing.T) {
|
||||
ctx = middleware.SetUserContext(ctx, middleware.NewSimpleUserContext(1, constants.UserTypeSuperAdmin, 0))
|
||||
|
||||
// 创建权限时不指定 platform
|
||||
req := &model.CreatePermissionRequest{
|
||||
req := &dto.CreatePermissionRequest{
|
||||
PermName: "测试权限",
|
||||
PermCode: "test:permission",
|
||||
PermType: constants.PermissionTypeMenu,
|
||||
@@ -152,7 +153,7 @@ func TestPermissionPlatformFilter_CreateWithSpecificPlatform(t *testing.T) {
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
req := &model.CreatePermissionRequest{
|
||||
req := &dto.CreatePermissionRequest{
|
||||
PermName: "测试权限_" + tt.platform,
|
||||
PermCode: "test:" + tt.platform,
|
||||
PermType: constants.PermissionTypeMenu,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/shop_account"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -40,7 +41,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
||||
err := shopStore.Create(ctx, shop)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.CreateShopAccountRequest{
|
||||
req := &dto.CreateShopAccountRequest{
|
||||
ShopID: shop.ID,
|
||||
Username: testutils.GenerateUsername("account", 1),
|
||||
Phone: testutils.GeneratePhone("139", 1),
|
||||
@@ -58,7 +59,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
||||
t.Run("创建商户账号-商户不存在应失败", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
req := &model.CreateShopAccountRequest{
|
||||
req := &dto.CreateShopAccountRequest{
|
||||
ShopID: 99999,
|
||||
Username: testutils.GenerateUsername("account", 2),
|
||||
Phone: testutils.GeneratePhone("139", 2),
|
||||
@@ -91,7 +92,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
username := testutils.GenerateUsername("duplicate", 1)
|
||||
req1 := &model.CreateShopAccountRequest{
|
||||
req1 := &dto.CreateShopAccountRequest{
|
||||
ShopID: shop.ID,
|
||||
Username: username,
|
||||
Phone: testutils.GeneratePhone("138", 1),
|
||||
@@ -100,7 +101,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
||||
_, err = service.Create(ctx, req1)
|
||||
require.NoError(t, err)
|
||||
|
||||
req2 := &model.CreateShopAccountRequest{
|
||||
req2 := &dto.CreateShopAccountRequest{
|
||||
ShopID: shop.ID,
|
||||
Username: username,
|
||||
Phone: testutils.GeneratePhone("138", 2),
|
||||
@@ -114,7 +115,7 @@ func TestShopAccountService_Create(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.CreateShopAccountRequest{
|
||||
req := &dto.CreateShopAccountRequest{
|
||||
ShopID: 1,
|
||||
Username: "test",
|
||||
Phone: "13800000000",
|
||||
@@ -167,7 +168,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
||||
err = accountStore.Create(ctx, account)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.UpdateShopAccountRequest{
|
||||
req := &dto.UpdateShopAccountRequest{
|
||||
Username: testutils.GenerateUsername("newuser", 1),
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
||||
t.Run("更新不存在的账号应失败", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
req := &model.UpdateShopAccountRequest{
|
||||
req := &dto.UpdateShopAccountRequest{
|
||||
Username: "newuser",
|
||||
}
|
||||
|
||||
@@ -191,7 +192,7 @@ func TestShopAccountService_Update(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.UpdateShopAccountRequest{
|
||||
req := &dto.UpdateShopAccountRequest{
|
||||
Username: "newuser",
|
||||
}
|
||||
|
||||
@@ -241,7 +242,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
||||
err = accountStore.Create(ctx, account)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.UpdateShopAccountPasswordRequest{
|
||||
req := &dto.UpdateShopAccountPasswordRequest{
|
||||
NewPassword: "newpassword123",
|
||||
}
|
||||
err = service.UpdatePassword(ctx, account.ID, req)
|
||||
@@ -255,7 +256,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
||||
t.Run("更新不存在的账号密码应失败", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
req := &model.UpdateShopAccountPasswordRequest{
|
||||
req := &dto.UpdateShopAccountPasswordRequest{
|
||||
NewPassword: "newpassword",
|
||||
}
|
||||
err := service.UpdatePassword(ctx, 99999, req)
|
||||
@@ -265,7 +266,7 @@ func TestShopAccountService_UpdatePassword(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.UpdateShopAccountPasswordRequest{
|
||||
req := &dto.UpdateShopAccountPasswordRequest{
|
||||
NewPassword: "newpassword",
|
||||
}
|
||||
err := service.UpdatePassword(ctx, 1, req)
|
||||
@@ -313,7 +314,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
||||
err = accountStore.Create(ctx, account)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.UpdateShopAccountStatusRequest{
|
||||
req := &dto.UpdateShopAccountStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
}
|
||||
err = service.UpdateStatus(ctx, account.ID, req)
|
||||
@@ -327,7 +328,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
||||
t.Run("更新不存在的账号状态应失败", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
req := &model.UpdateShopAccountStatusRequest{
|
||||
req := &dto.UpdateShopAccountStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
}
|
||||
err := service.UpdateStatus(ctx, 99999, req)
|
||||
@@ -337,7 +338,7 @@ func TestShopAccountService_UpdateStatus(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.UpdateShopAccountStatusRequest{
|
||||
req := &dto.UpdateShopAccountStatusRequest{
|
||||
Status: constants.StatusDisabled,
|
||||
}
|
||||
err := service.UpdateStatus(ctx, 1, req)
|
||||
@@ -387,7 +388,7 @@ func TestShopAccountService_List(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
req := &model.ShopAccountListRequest{
|
||||
req := &dto.ShopAccountListRequest{
|
||||
ShopID: &shop.ID,
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -51,7 +52,7 @@ func TestShopCommissionService_ListShopCommissionSummary(t *testing.T) {
|
||||
err := shopStore.Create(ctx, shop)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.ShopCommissionSummaryListReq{
|
||||
req := &dto.ShopCommissionSummaryListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -80,7 +81,7 @@ func TestShopCommissionService_ListShopCommissionSummary(t *testing.T) {
|
||||
err := shopStore.Create(ctx, shop)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.ShopCommissionSummaryListReq{
|
||||
req := &dto.ShopCommissionSummaryListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
ShopName: "筛选测试",
|
||||
@@ -122,7 +123,7 @@ func TestShopCommissionService_ListShopWithdrawalRequests(t *testing.T) {
|
||||
err := shopStore.Create(ctx, shop)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.ShopWithdrawalRequestListReq{
|
||||
req := &dto.ShopWithdrawalRequestListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -136,7 +137,7 @@ func TestShopCommissionService_ListShopWithdrawalRequests(t *testing.T) {
|
||||
t.Run("查询不存在的店铺提现记录应失败", func(t *testing.T) {
|
||||
ctx := createCommissionTestContext(1)
|
||||
|
||||
req := &model.ShopWithdrawalRequestListReq{
|
||||
req := &dto.ShopWithdrawalRequestListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -176,7 +177,7 @@ func TestShopCommissionService_ListShopCommissionRecords(t *testing.T) {
|
||||
err := shopStore.Create(ctx, shop)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := &model.ShopCommissionRecordListReq{
|
||||
req := &dto.ShopCommissionRecordListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
@@ -190,7 +191,7 @@ func TestShopCommissionService_ListShopCommissionRecords(t *testing.T) {
|
||||
t.Run("查询不存在的店铺佣金明细应失败", func(t *testing.T) {
|
||||
ctx := createCommissionTestContext(1)
|
||||
|
||||
req := &model.ShopCommissionRecordListReq{
|
||||
req := &dto.ShopCommissionRecordListReq{
|
||||
Page: 1,
|
||||
PageSize: 20,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/internal/service/shop"
|
||||
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
@@ -26,7 +27,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
|
||||
t.Run("创建一级店铺成功", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
req := &model.CreateShopRequest{
|
||||
req := &dto.CreateShopRequest{
|
||||
ShopName: "测试一级店铺",
|
||||
ShopCode: "SHOP_L1_001",
|
||||
ParentID: nil,
|
||||
@@ -71,7 +72,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// 创建二级店铺
|
||||
req := &model.CreateShopRequest{
|
||||
req := &dto.CreateShopRequest{
|
||||
ShopName: "测试二级店铺",
|
||||
ShopCode: "SHOP_L2_001",
|
||||
ParentID: &parent.ID,
|
||||
@@ -123,7 +124,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
assert.Equal(t, 7, shops[6].Level)
|
||||
|
||||
// 尝试创建第 8 级店铺(应该失败)
|
||||
req := &model.CreateShopRequest{
|
||||
req := &dto.CreateShopRequest{
|
||||
ShopName: "第8级店铺",
|
||||
ShopCode: "SHOP_L8_001",
|
||||
ParentID: &shops[6].ID, // 第7级店铺的ID
|
||||
@@ -149,7 +150,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
// 创建第一个店铺
|
||||
req1 := &model.CreateShopRequest{
|
||||
req1 := &dto.CreateShopRequest{
|
||||
ShopName: "店铺A",
|
||||
ShopCode: "UNIQUE_CODE_001",
|
||||
ContactName: "张三",
|
||||
@@ -162,7 +163,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// 尝试创建相同编号的店铺(应该失败)
|
||||
req2 := &model.CreateShopRequest{
|
||||
req2 := &dto.CreateShopRequest{
|
||||
ShopName: "店铺B",
|
||||
ShopCode: "UNIQUE_CODE_001", // 重复编号
|
||||
ContactName: "李四",
|
||||
@@ -186,7 +187,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
nonExistentID := uint(99999)
|
||||
req := &model.CreateShopRequest{
|
||||
req := &dto.CreateShopRequest{
|
||||
ShopName: "测试店铺",
|
||||
ShopCode: "SHOP_INVALID_PARENT",
|
||||
ParentID: &nonExistentID, // 不存在的上级店铺 ID
|
||||
@@ -211,7 +212,7 @@ func TestShopService_Create(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background() // 没有用户 ID 的 context
|
||||
|
||||
req := &model.CreateShopRequest{
|
||||
req := &dto.CreateShopRequest{
|
||||
ShopName: "测试店铺",
|
||||
ShopCode: "SHOP_UNAUTHORIZED",
|
||||
ContactName: "测试",
|
||||
@@ -262,7 +263,7 @@ func TestShopService_Update(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// 更新店铺
|
||||
req := &model.UpdateShopRequest{
|
||||
req := &dto.UpdateShopRequest{
|
||||
ShopName: "更新后的店铺名称",
|
||||
ContactName: "新联系人",
|
||||
ContactPhone: "13900000001",
|
||||
@@ -316,7 +317,7 @@ func TestShopService_Update(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// 尝试更新 shop2 的名称为已存在的名称(应该成功,因为名称不需要唯一性)
|
||||
req := &model.UpdateShopRequest{
|
||||
req := &dto.UpdateShopRequest{
|
||||
ShopName: "店铺1",
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
@@ -330,7 +331,7 @@ func TestShopService_Update(t *testing.T) {
|
||||
t.Run("更新不存在的店铺应失败", func(t *testing.T) {
|
||||
ctx := createContextWithUserID(1)
|
||||
|
||||
req := &model.UpdateShopRequest{
|
||||
req := &dto.UpdateShopRequest{
|
||||
ShopName: "新名称",
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
@@ -347,7 +348,7 @@ func TestShopService_Update(t *testing.T) {
|
||||
t.Run("未授权访问应失败", func(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
req := &model.UpdateShopRequest{
|
||||
req := &dto.UpdateShopRequest{
|
||||
ShopName: "新名称",
|
||||
Status: constants.StatusEnabled,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user