删除原有食物逻辑和模型
新增原料和营养价值表和原料库存日志和营养表定义
This commit is contained in:
@@ -173,9 +173,6 @@ func (a *API) setupRoutes() {
|
||||
monitorGroup.GET("/task-execution-logs", a.monitorController.ListTaskExecutionLogs)
|
||||
monitorGroup.GET("/pending-collections", a.monitorController.ListPendingCollections)
|
||||
monitorGroup.GET("/user-action-logs", a.monitorController.ListUserActionLogs)
|
||||
monitorGroup.GET("/raw-material-purchases", a.monitorController.ListRawMaterialPurchases)
|
||||
monitorGroup.GET("raw-material-stock-logs", a.monitorController.ListRawMaterialStockLogs)
|
||||
monitorGroup.GET("/feed-usage-records", a.monitorController.ListFeedUsageRecords)
|
||||
monitorGroup.GET("/medication-logs", a.monitorController.ListMedicationLogs)
|
||||
monitorGroup.GET("/pig-batch-logs", a.monitorController.ListPigBatchLogs)
|
||||
monitorGroup.GET("/weighing-batches", a.monitorController.ListWeighingBatches)
|
||||
|
||||
@@ -231,108 +231,6 @@ func (c *Controller) ListUserActionLogs(ctx echo.Context) error {
|
||||
return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取用户操作日志成功", resp, actionType, "获取用户操作日志成功", req)
|
||||
}
|
||||
|
||||
// ListRawMaterialPurchases godoc
|
||||
// @Summary 获取原料采购记录列表
|
||||
// @Description 根据提供的过滤条件,分页获取原料采购记录
|
||||
// @Tags 数据监控
|
||||
// @Security BearerAuth
|
||||
// @Produce json
|
||||
// @Param query query dto.ListRawMaterialPurchaseRequest true "查询参数"
|
||||
// @Success 200 {object} controller.Response{data=dto.ListRawMaterialPurchaseResponse}
|
||||
// @Router /api/v1/monitor/raw-material-purchases [get]
|
||||
func (c *Controller) ListRawMaterialPurchases(ctx echo.Context) error {
|
||||
reqCtx, logger := logs.Trace(ctx.Request().Context(), c.ctx, "ListRawMaterialPurchases")
|
||||
const actionType = "获取原料采购记录列表"
|
||||
|
||||
var req dto.ListRawMaterialPurchaseRequest
|
||||
if err := ctx.Bind(&req); err != nil {
|
||||
logger.Errorf("%s: 参数绑定失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
|
||||
}
|
||||
|
||||
resp, err := c.monitorService.ListRawMaterialPurchases(reqCtx, &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, repository.ErrInvalidPagination) {
|
||||
logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的分页参数: "+err.Error(), actionType, "无效分页参数", req)
|
||||
}
|
||||
|
||||
logger.Errorf("%s: 服务层查询失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料采购记录失败: "+err.Error(), actionType, "服务层查询失败", req)
|
||||
}
|
||||
|
||||
logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
|
||||
return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料采购记录成功", resp, actionType, "获取原料采购记录成功", req)
|
||||
}
|
||||
|
||||
// ListRawMaterialStockLogs godoc
|
||||
// @Summary 获取原料库存日志列表
|
||||
// @Description 根据提供的过滤条件,分页获取原料库存日志
|
||||
// @Tags 数据监控
|
||||
// @Security BearerAuth
|
||||
// @Produce json
|
||||
// @Param query query dto.ListRawMaterialStockLogRequest true "查询参数"
|
||||
// @Success 200 {object} controller.Response{data=dto.ListRawMaterialStockLogResponse}
|
||||
// @Router /api/v1/monitor/raw-material-stock-logs [get]
|
||||
func (c *Controller) ListRawMaterialStockLogs(ctx echo.Context) error {
|
||||
reqCtx, logger := logs.Trace(ctx.Request().Context(), c.ctx, "ListRawMaterialStockLogs")
|
||||
const actionType = "获取原料库存日志列表"
|
||||
|
||||
var req dto.ListRawMaterialStockLogRequest
|
||||
if err := ctx.Bind(&req); err != nil {
|
||||
logger.Errorf("%s: 参数绑定失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
|
||||
}
|
||||
|
||||
resp, err := c.monitorService.ListRawMaterialStockLogs(reqCtx, &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, repository.ErrInvalidPagination) {
|
||||
logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的分页参数: "+err.Error(), actionType, "无效分页参数", req)
|
||||
}
|
||||
|
||||
logger.Errorf("%s: 服务层查询失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取原料库存日志失败: "+err.Error(), actionType, "服务层查询失败", req)
|
||||
}
|
||||
|
||||
logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
|
||||
return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取原料库存日志成功", resp, actionType, "获取原料库存日志成功", req)
|
||||
}
|
||||
|
||||
// ListFeedUsageRecords godoc
|
||||
// @Summary 获取饲料使用记录列表
|
||||
// @Description 根据提供的过滤条件,分页获取饲料使用记录
|
||||
// @Tags 数据监控
|
||||
// @Security BearerAuth
|
||||
// @Produce json
|
||||
// @Param query query dto.ListFeedUsageRecordRequest true "查询参数"
|
||||
// @Success 200 {object} controller.Response{data=dto.ListFeedUsageRecordResponse}
|
||||
// @Router /api/v1/monitor/feed-usage-records [get]
|
||||
func (c *Controller) ListFeedUsageRecords(ctx echo.Context) error {
|
||||
reqCtx, logger := logs.Trace(ctx.Request().Context(), c.ctx, "ListFeedUsageRecords")
|
||||
const actionType = "获取饲料使用记录列表"
|
||||
|
||||
var req dto.ListFeedUsageRecordRequest
|
||||
if err := ctx.Bind(&req); err != nil {
|
||||
logger.Errorf("%s: 参数绑定失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的查询参数: "+err.Error(), actionType, "参数绑定失败", req)
|
||||
}
|
||||
|
||||
resp, err := c.monitorService.ListFeedUsageRecords(reqCtx, &req)
|
||||
if err != nil {
|
||||
if errors.Is(err, repository.ErrInvalidPagination) {
|
||||
logger.Warnf("%s: 无效的分页参数: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeBadRequest, "无效的分页参数: "+err.Error(), actionType, "无效分页参数", req)
|
||||
}
|
||||
|
||||
logger.Errorf("%s: 服务层查询失败: %v", actionType, err)
|
||||
return controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "获取饲料使用记录失败: "+err.Error(), actionType, "服务层查询失败", req)
|
||||
}
|
||||
|
||||
logger.Infof("%s: 成功, 获取到 %d 条记录, 总计 %d 条", actionType, len(resp.List), resp.Pagination.Total)
|
||||
return controller.SendSuccessWithAudit(ctx, controller.CodeSuccess, "获取饲料使用记录成功", resp, actionType, "获取饲料使用记录成功", req)
|
||||
}
|
||||
|
||||
// ListMedicationLogs godoc
|
||||
// @Summary 获取用药记录列表
|
||||
// @Description 根据提供的过滤条件,分页获取用药记录
|
||||
|
||||
@@ -170,94 +170,6 @@ func NewListUserActionLogResponse(data []models.UserActionLog, total int64, page
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRawMaterialPurchaseResponse 从模型数据创建列表响应 DTO
|
||||
func NewListRawMaterialPurchaseResponse(data []models.RawMaterialPurchase, total int64, page, pageSize int) *ListRawMaterialPurchaseResponse {
|
||||
dtos := make([]RawMaterialPurchaseDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = RawMaterialPurchaseDTO{
|
||||
ID: item.ID,
|
||||
RawMaterialID: item.RawMaterialID,
|
||||
RawMaterial: RawMaterialDTO{
|
||||
ID: item.RawMaterial.ID,
|
||||
Name: item.RawMaterial.Name,
|
||||
},
|
||||
Supplier: item.Supplier,
|
||||
Amount: item.Amount,
|
||||
UnitPrice: item.UnitPrice,
|
||||
TotalPrice: item.TotalPrice,
|
||||
PurchaseDate: item.PurchaseDate,
|
||||
CreatedAt: item.CreatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListRawMaterialPurchaseResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListRawMaterialStockLogResponse 从模型数据创建列表响应 DTO
|
||||
func NewListRawMaterialStockLogResponse(data []models.RawMaterialStockLog, total int64, page, pageSize int) *ListRawMaterialStockLogResponse {
|
||||
dtos := make([]RawMaterialStockLogDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = RawMaterialStockLogDTO{
|
||||
ID: item.ID,
|
||||
RawMaterialID: item.RawMaterialID,
|
||||
ChangeAmount: item.ChangeAmount,
|
||||
SourceType: item.SourceType,
|
||||
SourceID: item.SourceID,
|
||||
HappenedAt: item.HappenedAt,
|
||||
Remarks: item.Remarks,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListRawMaterialStockLogResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListFeedUsageRecordResponse 从模型数据创建列表响应 DTO
|
||||
func NewListFeedUsageRecordResponse(data []models.FeedUsageRecord, total int64, page, pageSize int) *ListFeedUsageRecordResponse {
|
||||
dtos := make([]FeedUsageRecordDTO, len(data))
|
||||
for i, item := range data {
|
||||
dtos[i] = FeedUsageRecordDTO{
|
||||
ID: item.ID,
|
||||
PenID: item.PenID,
|
||||
Pen: PenDTO{
|
||||
ID: item.Pen.ID,
|
||||
Name: item.Pen.PenNumber,
|
||||
},
|
||||
FeedFormulaID: item.FeedFormulaID,
|
||||
FeedFormula: FeedFormulaDTO{
|
||||
ID: item.FeedFormula.ID,
|
||||
Name: item.FeedFormula.Name,
|
||||
},
|
||||
Amount: item.Amount,
|
||||
RecordedAt: item.RecordedAt,
|
||||
OperatorID: item.OperatorID,
|
||||
Remarks: item.Remarks,
|
||||
}
|
||||
}
|
||||
|
||||
return &ListFeedUsageRecordResponse{
|
||||
List: dtos,
|
||||
Pagination: PaginationDTO{
|
||||
Total: total,
|
||||
Page: page,
|
||||
PageSize: pageSize,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// NewListMedicationLogResponse 从模型数据创建列表响应 DTO
|
||||
func NewListMedicationLogResponse(data []models.MedicationLog, total int64, page, pageSize int) *ListMedicationLogResponse {
|
||||
dtos := make([]MedicationLogDTO, len(data))
|
||||
|
||||
@@ -202,120 +202,6 @@ type ListUserActionLogResponse struct {
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- RawMaterialPurchase ---
|
||||
|
||||
// ListRawMaterialPurchaseRequest 定义了获取原料采购列表的请求参数
|
||||
type ListRawMaterialPurchaseRequest struct {
|
||||
Page int `json:"page" query:"page"`
|
||||
PageSize int `json:"page_size" query:"page_size"`
|
||||
RawMaterialID *uint32 `json:"raw_material_id" query:"raw_material_id"`
|
||||
Supplier *string `json:"supplier" query:"supplier"`
|
||||
StartTime *time.Time `json:"start_time" query:"start_time"`
|
||||
EndTime *time.Time `json:"end_time" query:"end_time"`
|
||||
OrderBy string `json:"order_by" query:"order_by"`
|
||||
}
|
||||
|
||||
// RawMaterialDTO 是用于API响应的简化版原料结构
|
||||
type RawMaterialDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// RawMaterialPurchaseDTO 是用于API响应的原料采购结构
|
||||
type RawMaterialPurchaseDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
RawMaterialID uint32 `json:"raw_material_id"`
|
||||
RawMaterial RawMaterialDTO `json:"raw_material"`
|
||||
Supplier string `json:"supplier"`
|
||||
Amount float32 `json:"amount"`
|
||||
UnitPrice float32 `json:"unit_price"`
|
||||
TotalPrice float32 `json:"total_price"`
|
||||
PurchaseDate time.Time `json:"purchase_date"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ListRawMaterialPurchaseResponse 是获取原料采购列表的响应结构
|
||||
type ListRawMaterialPurchaseResponse struct {
|
||||
List []RawMaterialPurchaseDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- RawMaterialStockLog ---
|
||||
|
||||
// ListRawMaterialStockLogRequest 定义了获取原料库存日志列表的请求参数
|
||||
type ListRawMaterialStockLogRequest struct {
|
||||
Page int `json:"page" query:"page"`
|
||||
PageSize int `json:"page_size" query:"page_size"`
|
||||
RawMaterialID *uint32 `json:"raw_material_id" query:"raw_material_id"`
|
||||
SourceType *string `json:"source_type" query:"source_type"`
|
||||
SourceID *uint32 `json:"source_id" query:"source_id"`
|
||||
StartTime *time.Time `json:"start_time" query:"start_time"`
|
||||
EndTime *time.Time `json:"end_time" query:"end_time"`
|
||||
OrderBy string `json:"order_by" query:"order_by"`
|
||||
}
|
||||
|
||||
// RawMaterialStockLogDTO 是用于API响应的原料库存日志结构
|
||||
type RawMaterialStockLogDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
RawMaterialID uint32 `json:"raw_material_id"`
|
||||
ChangeAmount float32 `json:"change_amount"`
|
||||
SourceType models.StockLogSourceType `json:"source_type"`
|
||||
SourceID uint32 `json:"source_id"`
|
||||
HappenedAt time.Time `json:"happened_at"`
|
||||
Remarks string `json:"remarks"`
|
||||
}
|
||||
|
||||
// ListRawMaterialStockLogResponse 是获取原料库存日志列表的响应结构
|
||||
type ListRawMaterialStockLogResponse struct {
|
||||
List []RawMaterialStockLogDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- FeedUsageRecord ---
|
||||
|
||||
// ListFeedUsageRecordRequest 定义了获取饲料使用记录列表的请求参数
|
||||
type ListFeedUsageRecordRequest struct {
|
||||
Page int `json:"page" query:"page"`
|
||||
PageSize int `json:"page_size" query:"page_size"`
|
||||
PenID *uint32 `json:"pen_id" query:"pen_id"`
|
||||
FeedFormulaID *uint32 `json:"feed_formula_id" query:"feed_formula_id"`
|
||||
OperatorID *uint32 `json:"operator_id" query:"operator_id"`
|
||||
StartTime *time.Time `json:"start_time" query:"start_time"`
|
||||
EndTime *time.Time `json:"end_time" query:"end_time"`
|
||||
OrderBy string `json:"order_by" query:"order_by"`
|
||||
}
|
||||
|
||||
// PenDTO 是用于API响应的简化版猪栏结构
|
||||
type PenDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// FeedFormulaDTO 是用于API响应的简化版饲料配方结构
|
||||
type FeedFormulaDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// FeedUsageRecordDTO 是用于API响应的饲料使用记录结构
|
||||
type FeedUsageRecordDTO struct {
|
||||
ID uint32 `json:"id"`
|
||||
PenID uint32 `json:"pen_id"`
|
||||
Pen PenDTO `json:"pen"`
|
||||
FeedFormulaID uint32 `json:"feed_formula_id"`
|
||||
FeedFormula FeedFormulaDTO `json:"feed_formula"`
|
||||
Amount float32 `json:"amount"`
|
||||
RecordedAt time.Time `json:"recorded_at"`
|
||||
OperatorID uint32 `json:"operator_id"`
|
||||
Remarks string `json:"remarks"`
|
||||
}
|
||||
|
||||
// ListFeedUsageRecordResponse 是获取饲料使用记录列表的响应结构
|
||||
type ListFeedUsageRecordResponse struct {
|
||||
List []FeedUsageRecordDTO `json:"list"`
|
||||
Pagination PaginationDTO `json:"pagination"`
|
||||
}
|
||||
|
||||
// --- MedicationLog ---
|
||||
|
||||
// ListMedicationLogRequest 定义了获取用药记录列表的请求参数
|
||||
|
||||
@@ -17,9 +17,6 @@ type MonitorService interface {
|
||||
ListTaskExecutionLogs(ctx context.Context, req *dto.ListTaskExecutionLogRequest) (*dto.ListTaskExecutionLogResponse, error)
|
||||
ListPendingCollections(ctx context.Context, req *dto.ListPendingCollectionRequest) (*dto.ListPendingCollectionResponse, error)
|
||||
ListUserActionLogs(ctx context.Context, req *dto.ListUserActionLogRequest) (*dto.ListUserActionLogResponse, error)
|
||||
ListRawMaterialPurchases(ctx context.Context, req *dto.ListRawMaterialPurchaseRequest) (*dto.ListRawMaterialPurchaseResponse, error)
|
||||
ListRawMaterialStockLogs(ctx context.Context, req *dto.ListRawMaterialStockLogRequest) (*dto.ListRawMaterialStockLogResponse, error)
|
||||
ListFeedUsageRecords(ctx context.Context, req *dto.ListFeedUsageRecordRequest) (*dto.ListFeedUsageRecordResponse, error)
|
||||
ListMedicationLogs(ctx context.Context, req *dto.ListMedicationLogRequest) (*dto.ListMedicationLogResponse, error)
|
||||
ListPigBatchLogs(ctx context.Context, req *dto.ListPigBatchLogRequest) (*dto.ListPigBatchLogResponse, error)
|
||||
ListWeighingBatches(ctx context.Context, req *dto.ListWeighingBatchRequest) (*dto.ListWeighingBatchResponse, error)
|
||||
@@ -40,7 +37,6 @@ type monitorService struct {
|
||||
planRepository repository.PlanRepository
|
||||
pendingCollectionRepo repository.PendingCollectionRepository
|
||||
userActionLogRepo repository.UserActionLogRepository
|
||||
rawMaterialRepo repository.RawMaterialRepository
|
||||
medicationRepo repository.MedicationLogRepository
|
||||
pigBatchRepo repository.PigBatchRepository
|
||||
pigBatchLogRepo repository.PigBatchLogRepository
|
||||
@@ -59,7 +55,6 @@ func NewMonitorService(
|
||||
planRepository repository.PlanRepository,
|
||||
pendingCollectionRepo repository.PendingCollectionRepository,
|
||||
userActionLogRepo repository.UserActionLogRepository,
|
||||
rawMaterialRepo repository.RawMaterialRepository,
|
||||
medicationRepo repository.MedicationLogRepository,
|
||||
pigBatchRepo repository.PigBatchRepository,
|
||||
pigBatchLogRepo repository.PigBatchLogRepository,
|
||||
@@ -76,7 +71,6 @@ func NewMonitorService(
|
||||
planRepository: planRepository,
|
||||
pendingCollectionRepo: pendingCollectionRepo,
|
||||
userActionLogRepo: userActionLogRepo,
|
||||
rawMaterialRepo: rawMaterialRepo,
|
||||
medicationRepo: medicationRepo,
|
||||
pigBatchRepo: pigBatchRepo,
|
||||
pigBatchLogRepo: pigBatchLogRepo,
|
||||
@@ -236,68 +230,6 @@ func (s *monitorService) ListUserActionLogs(ctx context.Context, req *dto.ListUs
|
||||
return dto.NewListUserActionLogResponse(data, total, req.Page, req.PageSize), nil
|
||||
}
|
||||
|
||||
// ListRawMaterialPurchases 负责处理查询原料采购记录列表的业务逻辑
|
||||
func (s *monitorService) ListRawMaterialPurchases(ctx context.Context, req *dto.ListRawMaterialPurchaseRequest) (*dto.ListRawMaterialPurchaseResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListRawMaterialPurchases")
|
||||
opts := repository.RawMaterialPurchaseListOptions{
|
||||
RawMaterialID: req.RawMaterialID,
|
||||
Supplier: req.Supplier,
|
||||
OrderBy: req.OrderBy,
|
||||
StartTime: req.StartTime,
|
||||
EndTime: req.EndTime,
|
||||
}
|
||||
|
||||
data, total, err := s.rawMaterialRepo.ListRawMaterialPurchases(serviceCtx, opts, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dto.NewListRawMaterialPurchaseResponse(data, total, req.Page, req.PageSize), nil
|
||||
}
|
||||
|
||||
// ListRawMaterialStockLogs 负责处理查询原料库存日志列表的业务逻辑
|
||||
func (s *monitorService) ListRawMaterialStockLogs(ctx context.Context, req *dto.ListRawMaterialStockLogRequest) (*dto.ListRawMaterialStockLogResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListRawMaterialStockLogs")
|
||||
opts := repository.RawMaterialStockLogListOptions{
|
||||
RawMaterialID: req.RawMaterialID,
|
||||
SourceID: req.SourceID,
|
||||
OrderBy: req.OrderBy,
|
||||
StartTime: req.StartTime,
|
||||
EndTime: req.EndTime,
|
||||
}
|
||||
if req.SourceType != nil {
|
||||
sourceType := models.StockLogSourceType(*req.SourceType)
|
||||
opts.SourceType = &sourceType
|
||||
}
|
||||
|
||||
data, total, err := s.rawMaterialRepo.ListRawMaterialStockLogs(serviceCtx, opts, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dto.NewListRawMaterialStockLogResponse(data, total, req.Page, req.PageSize), nil
|
||||
}
|
||||
|
||||
// ListFeedUsageRecords 负责处理查询饲料使用记录列表的业务逻辑
|
||||
func (s *monitorService) ListFeedUsageRecords(ctx context.Context, req *dto.ListFeedUsageRecordRequest) (*dto.ListFeedUsageRecordResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListFeedUsageRecords")
|
||||
opts := repository.FeedUsageRecordListOptions{
|
||||
PenID: req.PenID,
|
||||
FeedFormulaID: req.FeedFormulaID,
|
||||
OperatorID: req.OperatorID,
|
||||
OrderBy: req.OrderBy,
|
||||
StartTime: req.StartTime,
|
||||
EndTime: req.EndTime,
|
||||
}
|
||||
|
||||
data, total, err := s.rawMaterialRepo.ListFeedUsageRecords(serviceCtx, opts, req.Page, req.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return dto.NewListFeedUsageRecordResponse(data, total, req.Page, req.PageSize), nil
|
||||
}
|
||||
|
||||
// ListMedicationLogs 负责处理查询用药记录列表的业务逻辑
|
||||
func (s *monitorService) ListMedicationLogs(ctx context.Context, req *dto.ListMedicationLogRequest) (*dto.ListMedicationLogResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "ListMedicationLogs")
|
||||
|
||||
Reference in New Issue
Block a user