refactor: 将 DTO 文件从 internal/model 移动到 internal/model/dto 目录
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:
2026-01-22 10:15:04 +08:00
parent 23be0a7d3e
commit 46e4e5f4f1
73 changed files with 531 additions and 501 deletions

View File

@@ -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,
}