mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-23 06:45:43 +00:00
adjust get all phase activity
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
entity "gitlab.com/mbugroup/lti-api.git/internal/entities"
|
||||
@@ -57,8 +58,11 @@ func (s phaseActivityService) GetAll(c *fiber.Ctx, params *validation.Query) ([]
|
||||
if params.Search != "" {
|
||||
db = db.Where("name LIKE ?", "%"+params.Search+"%")
|
||||
}
|
||||
if params.PhaseId != nil {
|
||||
db = db.Where("phase_id = ?", *params.PhaseId)
|
||||
if params.PhaseIDs != "" {
|
||||
ids := parseIDs(params.PhaseIDs)
|
||||
if len(ids) > 0 {
|
||||
db = db.Where("phase_id IN ?", ids)
|
||||
}
|
||||
}
|
||||
return db.Order("created_at DESC").Order("updated_at DESC")
|
||||
})
|
||||
@@ -166,3 +170,18 @@ func (s phaseActivityService) DeleteOne(c *fiber.Ctx, id uint) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseIDs(raw string) []uint {
|
||||
parts := strings.Split(raw, ",")
|
||||
results := make([]uint, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
value := strings.TrimSpace(part)
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
if n, err := strconv.ParseUint(value, 10, 64); err == nil {
|
||||
results = append(results, uint(n))
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user