uint/uint64全部改为uint32
This commit is contained in:
@@ -18,19 +18,19 @@ import (
|
||||
type PigFarmService interface {
|
||||
// PigHouse methods
|
||||
CreatePigHouse(ctx context.Context, name, description string) (*dto.PigHouseResponse, error)
|
||||
GetPigHouseByID(ctx context.Context, id uint) (*dto.PigHouseResponse, error)
|
||||
GetPigHouseByID(ctx context.Context, id uint32) (*dto.PigHouseResponse, error)
|
||||
ListPigHouses(ctx context.Context) ([]dto.PigHouseResponse, error)
|
||||
UpdatePigHouse(ctx context.Context, id uint, name, description string) (*dto.PigHouseResponse, error)
|
||||
DeletePigHouse(ctx context.Context, id uint) error
|
||||
UpdatePigHouse(ctx context.Context, id uint32, name, description string) (*dto.PigHouseResponse, error)
|
||||
DeletePigHouse(ctx context.Context, id uint32) error
|
||||
|
||||
// Pen methods
|
||||
CreatePen(ctx context.Context, penNumber string, houseID uint, capacity int) (*dto.PenResponse, error)
|
||||
GetPenByID(ctx context.Context, id uint) (*dto.PenResponse, error)
|
||||
CreatePen(ctx context.Context, penNumber string, houseID uint32, capacity int) (*dto.PenResponse, error)
|
||||
GetPenByID(ctx context.Context, id uint32) (*dto.PenResponse, error)
|
||||
ListPens(ctx context.Context) ([]*dto.PenResponse, error)
|
||||
UpdatePen(ctx context.Context, id uint, penNumber string, houseID uint, capacity int, status models.PenStatus) (*dto.PenResponse, error)
|
||||
DeletePen(ctx context.Context, id uint) error
|
||||
UpdatePen(ctx context.Context, id uint32, penNumber string, houseID uint32, capacity int, status models.PenStatus) (*dto.PenResponse, error)
|
||||
DeletePen(ctx context.Context, id uint32) error
|
||||
// UpdatePenStatus 更新猪栏状态
|
||||
UpdatePenStatus(ctx context.Context, id uint, newStatus models.PenStatus) (*dto.PenResponse, error)
|
||||
UpdatePenStatus(ctx context.Context, id uint32, newStatus models.PenStatus) (*dto.PenResponse, error)
|
||||
}
|
||||
|
||||
type pigFarmService struct {
|
||||
@@ -79,7 +79,7 @@ func (s *pigFarmService) CreatePigHouse(ctx context.Context, name, description s
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) GetPigHouseByID(ctx context.Context, id uint) (*dto.PigHouseResponse, error) {
|
||||
func (s *pigFarmService) GetPigHouseByID(ctx context.Context, id uint32) (*dto.PigHouseResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "GetPigHouseByID")
|
||||
house, err := s.farmRepository.GetPigHouseByID(serviceCtx, id)
|
||||
if err != nil {
|
||||
@@ -109,10 +109,10 @@ func (s *pigFarmService) ListPigHouses(ctx context.Context) ([]dto.PigHouseRespo
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) UpdatePigHouse(ctx context.Context, id uint, name, description string) (*dto.PigHouseResponse, error) {
|
||||
func (s *pigFarmService) UpdatePigHouse(ctx context.Context, id uint32, name, description string) (*dto.PigHouseResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "UpdatePigHouse")
|
||||
house := &models.PigHouse{
|
||||
Model: gorm.Model{ID: id},
|
||||
Model: models.Model{ID: id},
|
||||
Name: name,
|
||||
Description: description,
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func (s *pigFarmService) UpdatePigHouse(ctx context.Context, id uint, name, desc
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) DeletePigHouse(ctx context.Context, id uint) error {
|
||||
func (s *pigFarmService) DeletePigHouse(ctx context.Context, id uint32) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "DeletePigHouse")
|
||||
// 业务逻辑:检查猪舍是否包含猪栏
|
||||
penCount, err := s.farmRepository.CountPensInHouse(serviceCtx, id)
|
||||
@@ -159,7 +159,7 @@ func (s *pigFarmService) DeletePigHouse(ctx context.Context, id uint) error {
|
||||
|
||||
// --- Pen Implementation ---
|
||||
|
||||
func (s *pigFarmService) CreatePen(ctx context.Context, penNumber string, houseID uint, capacity int) (*dto.PenResponse, error) {
|
||||
func (s *pigFarmService) CreatePen(ctx context.Context, penNumber string, houseID uint32, capacity int) (*dto.PenResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "CreatePen")
|
||||
// 业务逻辑:验证所属猪舍是否存在
|
||||
_, err := s.farmRepository.GetPigHouseByID(serviceCtx, houseID)
|
||||
@@ -189,7 +189,7 @@ func (s *pigFarmService) CreatePen(ctx context.Context, penNumber string, houseI
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) GetPenByID(ctx context.Context, id uint) (*dto.PenResponse, error) {
|
||||
func (s *pigFarmService) GetPenByID(ctx context.Context, id uint32) (*dto.PenResponse, error) {
|
||||
serviceCtx, logger := logs.Trace(ctx, s.ctx, "GetPenByID")
|
||||
pen, err := s.penRepository.GetPenByID(serviceCtx, id)
|
||||
if err != nil {
|
||||
@@ -251,7 +251,7 @@ func (s *pigFarmService) ListPens(ctx context.Context) ([]*dto.PenResponse, erro
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) UpdatePen(ctx context.Context, id uint, penNumber string, houseID uint, capacity int, status models.PenStatus) (*dto.PenResponse, error) {
|
||||
func (s *pigFarmService) UpdatePen(ctx context.Context, id uint32, penNumber string, houseID uint32, capacity int, status models.PenStatus) (*dto.PenResponse, error) {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "UpdatePen")
|
||||
// 业务逻辑:验证所属猪舍是否存在
|
||||
_, err := s.farmRepository.GetPigHouseByID(serviceCtx, houseID)
|
||||
@@ -263,7 +263,7 @@ func (s *pigFarmService) UpdatePen(ctx context.Context, id uint, penNumber strin
|
||||
}
|
||||
|
||||
pen := &models.Pen{
|
||||
Model: gorm.Model{ID: id},
|
||||
Model: models.Model{ID: id},
|
||||
PenNumber: penNumber,
|
||||
HouseID: houseID,
|
||||
Capacity: capacity,
|
||||
@@ -291,7 +291,7 @@ func (s *pigFarmService) UpdatePen(ctx context.Context, id uint, penNumber strin
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *pigFarmService) DeletePen(ctx context.Context, id uint) error {
|
||||
func (s *pigFarmService) DeletePen(ctx context.Context, id uint32) error {
|
||||
serviceCtx := logs.AddFuncName(ctx, s.ctx, "DeletePen")
|
||||
// 业务逻辑:检查猪栏是否被活跃批次使用
|
||||
pen, err := s.penRepository.GetPenByID(serviceCtx, id)
|
||||
@@ -327,7 +327,7 @@ func (s *pigFarmService) DeletePen(ctx context.Context, id uint) error {
|
||||
}
|
||||
|
||||
// UpdatePenStatus 更新猪栏状态
|
||||
func (s *pigFarmService) UpdatePenStatus(ctx context.Context, id uint, newStatus models.PenStatus) (*dto.PenResponse, error) {
|
||||
func (s *pigFarmService) UpdatePenStatus(ctx context.Context, id uint32, newStatus models.PenStatus) (*dto.PenResponse, error) {
|
||||
serviceCtx, logger := logs.Trace(ctx, s.ctx, "UpdatePenStatus")
|
||||
var updatedPen *models.Pen
|
||||
err := s.uow.ExecuteInTransaction(serviceCtx, func(tx *gorm.DB) error {
|
||||
|
||||
Reference in New Issue
Block a user