All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m45s
- 新增单卡分配/回收 API(支持 ICCID 列表、号段范围、筛选条件三种选卡方式) - 新增资产分配记录查询 API(支持多条件筛选和分页) - 新增 AssetAllocationRecord 模型、Store、Service、Handler 完整实现 - 扩展 IotCardStore 新增批量更新、号段查询、筛选查询等方法 - 修复 GORM Callback 处理 slice 类型(BatchCreate)的问题 - 新增完整的单元测试和集成测试 - 同步 OpenSpec 规范并归档 change
109 lines
5.3 KiB
Go
109 lines
5.3 KiB
Go
package dto
|
||
|
||
// ========== 选卡方式常量 ==========
|
||
|
||
const (
|
||
// SelectionTypeList ICCID列表选择
|
||
SelectionTypeList = "list"
|
||
// SelectionTypeRange 号段范围选择
|
||
SelectionTypeRange = "range"
|
||
// SelectionTypeFilter 筛选条件选择
|
||
SelectionTypeFilter = "filter"
|
||
)
|
||
|
||
// ========== 分配请求/响应 ==========
|
||
|
||
// AllocateStandaloneCardsRequest 分配单卡请求
|
||
type AllocateStandaloneCardsRequest struct {
|
||
// ToShopID 目标店铺ID(必填,必须是直属下级)
|
||
ToShopID uint `json:"to_shop_id" validate:"required,min=1" required:"true" minimum:"1" description:"目标店铺ID"`
|
||
|
||
// SelectionType 选卡方式(必填)
|
||
// list: ICCID列表选择
|
||
// range: 号段范围选择
|
||
// filter: 筛选条件选择
|
||
SelectionType string `json:"selection_type" validate:"required,oneof=list range filter" required:"true" enum:"list,range,filter" description:"选卡方式 (list:ICCID列表, range:号段范围, filter:筛选条件)"`
|
||
|
||
// ===== selection_type=list 时使用 =====
|
||
// ICCIDs ICCID列表(最多1000个)
|
||
ICCIDs []string `json:"iccids" validate:"required_if=SelectionType list,omitempty,max=1000,dive,required,max=20" description:"ICCID列表(selection_type=list时必填,最多1000个)"`
|
||
|
||
// ===== selection_type=range 时使用 =====
|
||
// ICCIDStart 起始ICCID
|
||
ICCIDStart string `json:"iccid_start" validate:"required_if=SelectionType range,omitempty,max=20" maxLength:"20" description:"起始ICCID(selection_type=range时必填)"`
|
||
// ICCIDEnd 结束ICCID
|
||
ICCIDEnd string `json:"iccid_end" validate:"required_if=SelectionType range,omitempty,max=20" maxLength:"20" description:"结束ICCID(selection_type=range时必填)"`
|
||
|
||
// ===== selection_type=filter 时使用 =====
|
||
// CarrierID 运营商ID
|
||
CarrierID *uint `json:"carrier_id" description:"运营商ID(selection_type=filter时可选)"`
|
||
// BatchNo 批次号
|
||
BatchNo string `json:"batch_no" validate:"omitempty,max=100" maxLength:"100" description:"批次号(selection_type=filter时可选)"`
|
||
// Status 卡状态
|
||
Status *int `json:"status" validate:"omitempty,min=1,max=4" minimum:"1" maximum:"4" description:"卡状态 (1:在库, 2:已分销)(selection_type=filter时可选)"`
|
||
|
||
// Remark 备注
|
||
Remark string `json:"remark" validate:"omitempty,max=500" maxLength:"500" description:"备注"`
|
||
}
|
||
|
||
// AllocateStandaloneCardsResponse 分配单卡响应
|
||
type AllocateStandaloneCardsResponse struct {
|
||
// TotalCount 待分配总数
|
||
TotalCount int `json:"total_count" description:"待分配总数"`
|
||
// SuccessCount 成功数
|
||
SuccessCount int `json:"success_count" description:"成功数"`
|
||
// FailCount 失败数
|
||
FailCount int `json:"fail_count" description:"失败数"`
|
||
// AllocationNo 分配单号
|
||
AllocationNo string `json:"allocation_no" description:"分配单号"`
|
||
// FailedItems 失败项列表
|
||
FailedItems []AllocationFailedItem `json:"failed_items" description:"失败项列表"`
|
||
}
|
||
|
||
// AllocationFailedItem 分配失败项
|
||
type AllocationFailedItem struct {
|
||
// ICCID 卡ICCID
|
||
ICCID string `json:"iccid" description:"ICCID"`
|
||
// Reason 失败原因
|
||
Reason string `json:"reason" description:"失败原因"`
|
||
}
|
||
|
||
// ========== 回收请求/响应 ==========
|
||
|
||
// RecallStandaloneCardsRequest 回收单卡请求
|
||
type RecallStandaloneCardsRequest struct {
|
||
// FromShopID 来源店铺ID(必填,被回收方,必须是直属下级)
|
||
FromShopID uint `json:"from_shop_id" validate:"required,min=1" required:"true" minimum:"1" description:"来源店铺ID(被回收方)"`
|
||
|
||
// SelectionType 选卡方式(必填)
|
||
SelectionType string `json:"selection_type" validate:"required,oneof=list range filter" required:"true" enum:"list,range,filter" description:"选卡方式 (list:ICCID列表, range:号段范围, filter:筛选条件)"`
|
||
|
||
// ===== selection_type=list 时使用 =====
|
||
ICCIDs []string `json:"iccids" validate:"required_if=SelectionType list,omitempty,max=1000,dive,required,max=20" description:"ICCID列表(selection_type=list时必填,最多1000个)"`
|
||
|
||
// ===== selection_type=range 时使用 =====
|
||
ICCIDStart string `json:"iccid_start" validate:"required_if=SelectionType range,omitempty,max=20" maxLength:"20" description:"起始ICCID(selection_type=range时必填)"`
|
||
ICCIDEnd string `json:"iccid_end" validate:"required_if=SelectionType range,omitempty,max=20" maxLength:"20" description:"结束ICCID(selection_type=range时必填)"`
|
||
|
||
// ===== selection_type=filter 时使用 =====
|
||
CarrierID *uint `json:"carrier_id" description:"运营商ID(selection_type=filter时可选)"`
|
||
BatchNo string `json:"batch_no" validate:"omitempty,max=100" maxLength:"100" description:"批次号(selection_type=filter时可选)"`
|
||
|
||
// Remark 备注
|
||
Remark string `json:"remark" validate:"omitempty,max=500" maxLength:"500" description:"备注"`
|
||
}
|
||
|
||
// RecallStandaloneCardsResponse 回收单卡响应
|
||
type RecallStandaloneCardsResponse struct {
|
||
// TotalCount 待回收总数
|
||
TotalCount int `json:"total_count" description:"待回收总数"`
|
||
// SuccessCount 成功数
|
||
SuccessCount int `json:"success_count" description:"成功数"`
|
||
// FailCount 失败数
|
||
FailCount int `json:"fail_count" description:"失败数"`
|
||
// AllocationNo 回收单号
|
||
AllocationNo string `json:"allocation_no" description:"回收单号"`
|
||
// FailedItems 失败项列表
|
||
FailedItems []AllocationFailedItem `json:"failed_items" description:"失败项列表"`
|
||
}
|