优化结构

This commit is contained in:
Yvan
2026-08-28 11:51:37 +08:00
parent 5b04998731
commit 33ba777137
25 changed files with 163 additions and 125 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ func (r *announcementRepo) List(ctx context.Context, filter system.AnnouncementF
if filter.StartCreatedAt != nil && filter.EndCreatedAt != nil {
db = db.Where("created_at BETWEEN ? AND ?", filter.StartCreatedAt, filter.EndCreatedAt)
}
return listRows(db.Order("id desc"), filter.Page, filter.PageSize, filter.PageSize > 0, func(po announcementPO) *system.Announcement {
return listRows(db.Order("id desc"), filter.Page, filter.PageSize, rowQueryOptions{Paginate: filter.PageSize > 0}, func(po announcementPO) *system.Announcement {
return announcementToBiz(po)
})
}
@@ -83,7 +83,7 @@ func (r *announcementRepo) UserOptions(ctx context.Context) ([]system.UserOption
}
// The generated data-source endpoint is best effort: return collected
// options even when the underlying scan reports an error.
_ = r.data.DB().WithContext(ctx).Table("sys_users").Select("nick_name AS label, id AS value").Scan(&rows).Error
_ = r.data.DB().WithContext(ctx).Model(&userPO{}).Select("nick_name AS label, id AS value").Scan(&rows).Error
items := make([]system.UserOption, 0, len(rows))
for _, row := range rows {
items = append(items, system.UserOption{Label: row.Label, Value: row.Value})