2025-11-21 16:02:06 +08:00
|
|
|
|
package dto
|
|
|
|
|
|
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 营养种类 (Nutrient) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// CreateNutrientRequest 创建营养种类的请求体
|
|
|
|
|
|
type CreateNutrientRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 营养素名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateNutrientRequest 更新营养种类的请求体
|
|
|
|
|
|
type UpdateNutrientRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 营养素名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-21 16:37:09 +08:00
|
|
|
|
// NutrientRawMaterialDTO 用于在营养素信息中展示关联的原料及其含量
|
|
|
|
|
|
type NutrientRawMaterialDTO struct {
|
|
|
|
|
|
ID uint32 `json:"id"` // 原料ID
|
|
|
|
|
|
Name string `json:"name"` // 原料名称
|
|
|
|
|
|
Value float32 `json:"value"` // 该原料中此营养素的含量
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-21 16:02:06 +08:00
|
|
|
|
// NutrientResponse 营养种类响应体
|
|
|
|
|
|
type NutrientResponse struct {
|
2025-11-21 16:37:09 +08:00
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
|
RawMaterials []NutrientRawMaterialDTO `json:"raw_materials"` // 包含此营养的原料列表
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListNutrientRequest 定义了获取营养种类列表的请求参数
|
|
|
|
|
|
type ListNutrientRequest struct {
|
2025-11-21 17:23:57 +08:00
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
Name *string `json:"name" query:"name"` // 按营养名称模糊查询
|
|
|
|
|
|
RawMaterialName *string `json:"raw_material_name" query:"raw_material_name"` // 按原料名称模糊查询
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListNutrientResponse 是获取营养种类列表的响应结构
|
|
|
|
|
|
type ListNutrientResponse struct {
|
|
|
|
|
|
List []NutrientResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 原料 (RawMaterial) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// CreateRawMaterialRequest 创建原料的请求体
|
|
|
|
|
|
type CreateRawMaterialRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 原料名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateRawMaterialRequest 更新原料的请求体
|
|
|
|
|
|
type UpdateRawMaterialRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 原料名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RawMaterialNutrientDTO 原料营养素响应体
|
|
|
|
|
|
type RawMaterialNutrientDTO struct {
|
2025-11-22 16:44:22 +08:00
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
NutrientID uint32 `json:"nutrient_id"`
|
|
|
|
|
|
Nutrient string `json:"nutrient_name"` // 营养素名称
|
|
|
|
|
|
Value float32 `json:"value"` // 营养价值含量
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RawMaterialResponse 原料响应体
|
|
|
|
|
|
type RawMaterialResponse struct {
|
|
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
|
RawMaterialNutrients []RawMaterialNutrientDTO `json:"raw_material_nutrients"` // 关联的营养素信息
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListRawMaterialRequest 定义了获取原料列表的请求参数
|
|
|
|
|
|
type ListRawMaterialRequest struct {
|
2025-11-21 17:23:57 +08:00
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
Name *string `json:"name" query:"name"` // 按原料名称模糊查询
|
|
|
|
|
|
NutrientName *string `json:"nutrient_name" query:"nutrient_name"` // 按营养名称模糊查询
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListRawMaterialResponse 是获取原料列表的响应结构
|
|
|
|
|
|
type ListRawMaterialResponse struct {
|
|
|
|
|
|
List []RawMaterialResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-22 16:44:22 +08:00
|
|
|
|
// UpdateRawMaterialNutrientsRequest 更新原料营养成分的请求体
|
|
|
|
|
|
type UpdateRawMaterialNutrientsRequest struct {
|
|
|
|
|
|
Nutrients []RawMaterialNutrientItem `json:"nutrients" validate:"required,dive"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RawMaterialNutrientItem 代表一个营养成分及其含量
|
|
|
|
|
|
type RawMaterialNutrientItem struct {
|
|
|
|
|
|
NutrientID uint32 `json:"nutrient_id" validate:"required"` // 营养素ID
|
|
|
|
|
|
Value float32 `json:"value" validate:"gte=0"` // 含量值,必须大于等于0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-21 16:02:06 +08:00
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 猪品种 (PigBreed) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// CreatePigBreedRequest 创建猪品种的请求体
|
|
|
|
|
|
type CreatePigBreedRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=50"` // 品种名称
|
|
|
|
|
|
Description string `json:"description"` // 其他描述
|
|
|
|
|
|
ParentInfo string `json:"parent_info"` // 父母信息
|
|
|
|
|
|
AppearanceFeatures string `json:"appearance_features"` // 外貌特征
|
|
|
|
|
|
BreedAdvantages string `json:"breed_advantages"` // 品种优点
|
|
|
|
|
|
BreedDisadvantages string `json:"breed_disadvantages"` // 品种缺点
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdatePigBreedRequest 更新猪品种的请求体
|
|
|
|
|
|
type UpdatePigBreedRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=50"` // 品种名称
|
|
|
|
|
|
Description string `json:"description"` // 其他描述
|
|
|
|
|
|
ParentInfo string `json:"parent_info"` // 父母信息
|
|
|
|
|
|
AppearanceFeatures string `json:"appearance_features"` // 外貌特征
|
|
|
|
|
|
BreedAdvantages string `json:"breed_advantages"` // 品种优点
|
|
|
|
|
|
BreedDisadvantages string `json:"breed_disadvantages"` // 品种缺点
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PigBreedResponse 猪品种响应体
|
|
|
|
|
|
type PigBreedResponse struct {
|
2025-11-22 16:44:22 +08:00
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
|
ParentInfo string `json:"parent_info"`
|
|
|
|
|
|
AppearanceFeatures string `json:"appearance_features"`
|
|
|
|
|
|
BreedAdvantages string `json:"breed_advantages"`
|
|
|
|
|
|
BreedDisadvantages string `json:"breed_disadvantages"`
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigBreedRequest 定义了获取猪品种列表的请求参数
|
|
|
|
|
|
type ListPigBreedRequest struct {
|
|
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
Name *string `json:"name" query:"name"` // 按名称模糊查询
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigBreedResponse 是获取猪品种列表的响应结构
|
|
|
|
|
|
type ListPigBreedResponse struct {
|
|
|
|
|
|
List []PigBreedResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 猪年龄阶段 (PigAgeStage) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// CreatePigAgeStageRequest 创建猪年龄阶段的请求体
|
|
|
|
|
|
type CreatePigAgeStageRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=50"` // 年龄阶段名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 阶段描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdatePigAgeStageRequest 更新猪年龄阶段的请求体
|
|
|
|
|
|
type UpdatePigAgeStageRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=50"` // 年龄阶段名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 阶段描述
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PigAgeStageResponse 猪年龄阶段响应体
|
|
|
|
|
|
type PigAgeStageResponse struct {
|
2025-11-22 16:44:22 +08:00
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
Description string `json:"description"`
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigAgeStageRequest 定义了获取猪年龄阶段列表的请求参数
|
|
|
|
|
|
type ListPigAgeStageRequest struct {
|
|
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
Name *string `json:"name" query:"name"` // 按名称模糊查询
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigAgeStageResponse 是获取猪年龄阶段列表的响应结构
|
|
|
|
|
|
type ListPigAgeStageResponse struct {
|
|
|
|
|
|
List []PigAgeStageResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 猪类型 (PigType) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// CreatePigTypeRequest 创建猪类型的请求体
|
|
|
|
|
|
type CreatePigTypeRequest struct {
|
|
|
|
|
|
BreedID uint32 `json:"breed_id" validate:"required"` // 关联的猪品种ID
|
|
|
|
|
|
AgeStageID uint32 `json:"age_stage_id" validate:"required"` // 关联的猪年龄阶段ID
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 该猪类型的描述或特点
|
|
|
|
|
|
DailyFeedIntake float32 `json:"daily_feed_intake"` // 理论日均食量 (g/天)
|
|
|
|
|
|
DailyGainWeight float32 `json:"daily_gain_weight"` // 理论日增重 (g/天)
|
|
|
|
|
|
MinDays uint32 `json:"min_days"` // 该猪类型在该年龄阶段的最小日龄
|
|
|
|
|
|
MaxDays uint32 `json:"max_days"` // 该猪类型在该年龄阶段的最大日龄
|
|
|
|
|
|
MinWeight float32 `json:"min_weight"` // 该猪类型在该年龄阶段的最小体重 (g)
|
|
|
|
|
|
MaxWeight float32 `json:"max_weight"` // 该猪类型在该年龄阶段的最大体重 (g)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdatePigTypeRequest 更新猪类型的请求体
|
|
|
|
|
|
type UpdatePigTypeRequest struct {
|
|
|
|
|
|
BreedID uint32 `json:"breed_id" validate:"required"` // 关联的猪品种ID
|
|
|
|
|
|
AgeStageID uint32 `json:"age_stage_id" validate:"required"` // 关联的猪年龄阶段ID
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 该猪类型的描述或特点
|
|
|
|
|
|
DailyFeedIntake float32 `json:"daily_feed_intake"` // 理论日均食量 (g/天)
|
|
|
|
|
|
DailyGainWeight float32 `json:"daily_gain_weight"` // 理论日增重 (g/天)
|
|
|
|
|
|
MinDays uint32 `json:"min_days"` // 该猪类型在该年龄阶段的最小日龄
|
|
|
|
|
|
MaxDays uint32 `json:"max_days"` // 该猪类型在该年龄阶段的最大日龄
|
|
|
|
|
|
MinWeight float32 `json:"min_weight"` // 该猪类型在该年龄阶段的最小体重 (g)
|
|
|
|
|
|
MaxWeight float32 `json:"max_weight"` // 该猪类型在该年龄阶段的最大体重 (g)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PigNutrientRequirementDTO 猪营养需求响应体
|
|
|
|
|
|
type PigNutrientRequirementDTO struct {
|
2025-11-22 16:44:22 +08:00
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
NutrientID uint32 `json:"nutrient_id"`
|
|
|
|
|
|
NutrientName string `json:"nutrient_name"` // 营养素名称
|
|
|
|
|
|
MinRequirement float32 `json:"min_requirement"` // 最低营养需求量
|
|
|
|
|
|
MaxRequirement float32 `json:"max_requirement"` // 最高营养需求量
|
2025-11-21 16:02:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PigTypeResponse 猪类型响应体
|
|
|
|
|
|
type PigTypeResponse struct {
|
|
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
BreedID uint32 `json:"breed_id"`
|
|
|
|
|
|
BreedName string `json:"breed_name"` // 猪品种名称
|
|
|
|
|
|
AgeStageID uint32 `json:"age_stage_id"`
|
|
|
|
|
|
AgeStageName string `json:"age_stage_name"` // 猪年龄阶段名称
|
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
|
DailyFeedIntake float32 `json:"daily_feed_intake"`
|
|
|
|
|
|
DailyGainWeight float32 `json:"daily_gain_weight"`
|
|
|
|
|
|
MinDays uint32 `json:"min_days"`
|
|
|
|
|
|
MaxDays uint32 `json:"max_days"`
|
|
|
|
|
|
MinWeight float32 `json:"min_weight"`
|
|
|
|
|
|
MaxWeight float32 `json:"max_weight"`
|
|
|
|
|
|
PigNutrientRequirements []PigNutrientRequirementDTO `json:"pig_nutrient_requirements"` // 关联的营养需求
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigTypeRequest 定义了获取猪类型列表的请求参数
|
|
|
|
|
|
type ListPigTypeRequest struct {
|
|
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
BreedID *uint32 `json:"breed_id" query:"breed_id"` // 关联的猪品种ID
|
|
|
|
|
|
AgeStageID *uint32 `json:"age_stage_id" query:"age_stage_id"` // 关联的猪年龄阶段ID
|
|
|
|
|
|
BreedName *string `json:"breed_name" query:"breed_name"` // 关联的猪品种名称 (用于模糊查询)
|
|
|
|
|
|
AgeStageName *string `json:"age_stage_name" query:"age_stage_name"` // 关联的猪年龄阶段名称 (用于模糊查询)
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListPigTypeResponse 是获取猪类型列表的响应结构
|
|
|
|
|
|
type ListPigTypeResponse struct {
|
|
|
|
|
|
List []PigTypeResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|
2025-11-22 17:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
// UpdatePigTypeNutrientRequirementsRequest 更新猪类型营养需求的请求体
|
|
|
|
|
|
type UpdatePigTypeNutrientRequirementsRequest struct {
|
|
|
|
|
|
NutrientRequirements []PigNutrientRequirementItem `json:"nutrient_requirements" validate:"required,dive"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PigNutrientRequirementItem 代表一个营养需求项
|
|
|
|
|
|
type PigNutrientRequirementItem struct {
|
|
|
|
|
|
NutrientID uint32 `json:"nutrient_id" validate:"required"` // 营养素ID
|
|
|
|
|
|
MinRequirement float32 `json:"min_requirement" validate:"gte=0"` // 最低营养需求量
|
|
|
|
|
|
MaxRequirement float32 `json:"max_requirement" validate:"gte=0"` // 最高营养需求量
|
|
|
|
|
|
}
|
2025-11-24 13:25:15 +08:00
|
|
|
|
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
// 配方 (Recipe) 相关 DTO
|
|
|
|
|
|
// =============================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
// RecipeIngredientDto 代表配方中的一个原料及其百分比
|
|
|
|
|
|
type RecipeIngredientDto struct {
|
|
|
|
|
|
RawMaterialID uint32 `json:"raw_material_id" validate:"required"` // 原料ID
|
|
|
|
|
|
Percentage float32 `json:"percentage" validate:"gte=0,lte=1"` // 原料在配方中的百分比 (0-1之间)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CreateRecipeRequest 创建配方的请求体
|
|
|
|
|
|
type CreateRecipeRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 配方名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 配方描述
|
|
|
|
|
|
RecipeIngredients []RecipeIngredientDto `json:"recipe_ingredients" validate:"dive"` // 配方原料组成
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// UpdateRecipeRequest 更新配方的请求体
|
|
|
|
|
|
type UpdateRecipeRequest struct {
|
|
|
|
|
|
Name string `json:"name" validate:"required,max=100"` // 配方名称
|
|
|
|
|
|
Description string `json:"description" validate:"max=255"` // 配方描述
|
|
|
|
|
|
RecipeIngredients []RecipeIngredientDto `json:"recipe_ingredients" validate:"dive"` // 配方原料组成
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// RecipeResponse 配方响应体
|
|
|
|
|
|
type RecipeResponse struct {
|
|
|
|
|
|
ID uint32 `json:"id"`
|
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
Description string `json:"description"`
|
|
|
|
|
|
RecipeIngredients []RecipeIngredientDto `json:"recipe_ingredients"`
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListRecipeRequest 定义了获取配方列表的请求参数
|
|
|
|
|
|
type ListRecipeRequest struct {
|
|
|
|
|
|
Page int `json:"page" query:"page"` // 页码
|
|
|
|
|
|
PageSize int `json:"page_size" query:"page_size"` // 每页数量
|
|
|
|
|
|
Name *string `json:"name" query:"name"` // 按名称模糊查询
|
|
|
|
|
|
OrderBy string `json:"order_by" query:"order_by"` // 排序字段,例如 "id DESC"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ListRecipeResponse 是获取配方列表的响应结构
|
|
|
|
|
|
type ListRecipeResponse struct {
|
|
|
|
|
|
List []RecipeResponse `json:"list"`
|
|
|
|
|
|
Pagination PaginationDTO `json:"pagination"`
|
|
|
|
|
|
}
|