mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 14:55:42 +00:00
feat(BE): fix delete project flock budget and uniformity, and fix uniformity with update purchase document
This commit is contained in:
@@ -74,7 +74,6 @@ type UniformityListDTO struct {
|
||||
MeanDown float64 `json:"mean_down"`
|
||||
StandardMeanWeight *float64 `json:"standard_mean_weight"`
|
||||
StandardUniformity *float64 `json:"standard_uniformity"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
CreatedBy uint `json:"created_by"`
|
||||
LatestApproval *approvalDTO.ApprovalRelationDTO `json:"latest_approval"`
|
||||
}
|
||||
@@ -154,7 +153,6 @@ func ToUniformityListDTOs(items []entity.ProjectFlockKandangUniformity) []Unifor
|
||||
UniformQty: item.UniformQty,
|
||||
MeanUp: item.MeanUp,
|
||||
MeanDown: item.MeanDown,
|
||||
CreatedAt: item.CreatedAt,
|
||||
CreatedBy: item.CreatedBy,
|
||||
LatestApproval: latestApproval,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/common/repository"
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
"gorm.io/gorm"
|
||||
@@ -8,6 +10,7 @@ import (
|
||||
|
||||
type UniformityRepository interface {
|
||||
repository.BaseRepository[entity.ProjectFlockKandangUniformity]
|
||||
DeleteByProjectFlockKandangIDs(ctx context.Context, projectFlockKandangIDs []uint) error
|
||||
}
|
||||
|
||||
type UniformityRepositoryImpl struct {
|
||||
@@ -19,3 +22,13 @@ func NewUniformityRepository(db *gorm.DB) UniformityRepository {
|
||||
BaseRepositoryImpl: repository.NewBaseRepository[entity.ProjectFlockKandangUniformity](db),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *UniformityRepositoryImpl) DeleteByProjectFlockKandangIDs(ctx context.Context, projectFlockKandangIDs []uint) error {
|
||||
if len(projectFlockKandangIDs) == 0 {
|
||||
return nil
|
||||
}
|
||||
return r.DB().WithContext(ctx).
|
||||
Unscoped().
|
||||
Where("project_flock_kandang_id IN ?", projectFlockKandangIDs).
|
||||
Delete(&entity.ProjectFlockKandangUniformity{}).Error
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ func (s uniformityService) GetAll(c *fiber.Ctx, params *validation.Query) ([]ent
|
||||
if params.Week != 0 {
|
||||
db = db.Where("week = ?", params.Week)
|
||||
}
|
||||
return db.Order("uniform_date DESC").Order("created_at DESC")
|
||||
return db.Order("uniform_date DESC").Order("id DESC")
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user