优化结构

This commit is contained in:
Yvan
2026-08-28 09:19:54 +08:00
parent 03a4131f6e
commit 279692375b
57 changed files with 778 additions and 799 deletions
+3 -4
View File
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"kra/internal/biz/system"
"kra/pkg/database/pagination"
"time"
"gorm.io/gorm"
@@ -83,10 +84,7 @@ func (r *positionRepo) ListPositions(ctx context.Context, page, size int, q *sys
return nil, 0, err
}
var pos []positionPO
// The compatible position endpoint applies the supplied LIMIT/OFFSET
// directly (it does not normalize missing page values through the shared
// pagination helper).
if err := db.Order("sort").Limit(size).Offset(size * (page - 1)).Find(&pos).Error; err != nil {
if err := pagination.ApplyRequired(db.Order("sort"), page, size, 100).Find(&pos).Error; err != nil {
return nil, 0, err
}
out := make([]*system.Position, 0, len(pos))
@@ -95,6 +93,7 @@ func (r *positionRepo) ListPositions(ctx context.Context, page, size int, q *sys
}
return out, total, nil
}
func (r *positionRepo) PositionUserIDs(ctx context.Context, id uint) ([]uint, error) {
var ids []uint
err := r.data.DB().WithContext(ctx).Model(&userPositionPO{}).Where("sys_position_id = ?", id).Pluck("sys_user_id", &ids).Error