完成任务4

This commit is contained in:
2025-10-30 17:15:14 +08:00
parent f0982839e0
commit d235130d11
11 changed files with 531 additions and 765 deletions

View File

@@ -2,7 +2,7 @@ package management
import (
"git.huangwc.com/pig/pig-farm-controller/internal/app/dto"
"github.com/gin-gonic/gin"
"github.com/labstack/echo/v4"
)
// SellPigs godoc
@@ -16,13 +16,13 @@ import (
// @Param body body dto.SellPigsRequest true "卖猪请求信息"
// @Success 200 {object} controller.Response "卖猪成功"
// @Router /api/v1/pig-batches/sell-pigs/{id} [post]
func (c *PigBatchController) SellPigs(ctx *gin.Context) {
func (c *PigBatchController) SellPigs(ctx echo.Context) error {
const action = "卖猪"
var req dto.SellPigsRequest
handleAPIRequest(
return handleAPIRequest(
c, ctx, action, &req,
func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.SellPigsRequest) error {
func(ctx echo.Context, operatorID uint, primaryID uint, req *dto.SellPigsRequest) error {
return c.service.SellPigs(primaryID, req.PenID, req.Quantity, req.UnitPrice, req.TotalPrice, req.TraderName, req.TradeDate, req.Remarks, operatorID)
},
"卖猪成功",
@@ -41,13 +41,13 @@ func (c *PigBatchController) SellPigs(ctx *gin.Context) {
// @Param body body dto.BuyPigsRequest true "买猪请求信息"
// @Success 200 {object} controller.Response "买猪成功"
// @Router /api/v1/pig-batches/buy-pigs/{id} [post]
func (c *PigBatchController) BuyPigs(ctx *gin.Context) {
func (c *PigBatchController) BuyPigs(ctx echo.Context) error {
const action = "买猪"
var req dto.BuyPigsRequest
handleAPIRequest(
return handleAPIRequest(
c, ctx, action, &req,
func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.BuyPigsRequest) error {
func(ctx echo.Context, operatorID uint, primaryID uint, req *dto.BuyPigsRequest) error {
return c.service.BuyPigs(primaryID, req.PenID, req.Quantity, req.UnitPrice, req.TotalPrice, req.TraderName, req.TradeDate, req.Remarks, operatorID)
},
"买猪成功",