核心功能: - 实现 7 级店铺层级体系(Shop 模型 + 层级校验) - 实现企业管理模型(Enterprise 模型) - 实现个人客户管理模型(PersonalCustomer 模型) - 重构 Account 模型关联关系(基于 EnterpriseID 而非 ParentID) - 完整的 Store 层和 Service 层实现 - 递归查询下级店铺功能(含 Redis 缓存) - 全面的单元测试覆盖(Shop/Enterprise/PersonalCustomer Store + Shop Service) 技术要点: - 显式指定所有 GORM 模型的数据库字段名(column: 标签) - 统一的字段命名规范(数据库用 snake_case,Go 用 PascalCase) - 完整的中文字段注释和业务逻辑说明 - 100% 测试覆盖(20+ 测试用例全部通过) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
45 lines
1.9 KiB
Go
45 lines
1.9 KiB
Go
package model
|
|
|
|
// CreateShopRequest 创建店铺请求
|
|
type CreateShopRequest struct {
|
|
ShopName string `json:"shop_name" validate:"required"` // 店铺名称
|
|
ShopCode string `json:"shop_code"` // 店铺编号
|
|
ParentID *uint `json:"parent_id"` // 上级店铺ID
|
|
ContactName string `json:"contact_name"` // 联系人姓名
|
|
ContactPhone string `json:"contact_phone" validate:"omitempty"` // 联系人电话
|
|
Province string `json:"province"` // 省份
|
|
City string `json:"city"` // 城市
|
|
District string `json:"district"` // 区县
|
|
Address string `json:"address"` // 详细地址
|
|
}
|
|
|
|
// UpdateShopRequest 更新店铺请求
|
|
type UpdateShopRequest struct {
|
|
ShopName *string `json:"shop_name"` // 店铺名称
|
|
ShopCode *string `json:"shop_code"` // 店铺编号
|
|
ContactName *string `json:"contact_name"` // 联系人姓名
|
|
ContactPhone *string `json:"contact_phone"` // 联系人电话
|
|
Province *string `json:"province"` // 省份
|
|
City *string `json:"city"` // 城市
|
|
District *string `json:"district"` // 区县
|
|
Address *string `json:"address"` // 详细地址
|
|
}
|
|
|
|
// ShopResponse 店铺响应
|
|
type ShopResponse struct {
|
|
ID uint `json:"id"`
|
|
ShopName string `json:"shop_name"`
|
|
ShopCode string `json:"shop_code"`
|
|
ParentID *uint `json:"parent_id,omitempty"`
|
|
Level int `json:"level"`
|
|
ContactName string `json:"contact_name"`
|
|
ContactPhone string `json:"contact_phone"`
|
|
Province string `json:"province"`
|
|
City string `json:"city"`
|
|
District string `json:"district"`
|
|
Address string `json:"address"`
|
|
Status int `json:"status"`
|
|
CreatedAt string `json:"created_at"`
|
|
UpdatedAt string `json:"updated_at"`
|
|
}
|