优化结构

This commit is contained in:
Yvan
2026-08-21 08:54:29 +08:00
parent c968f9f24e
commit 77e192b6c0
167 changed files with 3657 additions and 1528 deletions
+8 -9
View File
@@ -6,7 +6,6 @@ import (
"time"
"kra/app/system/internal/biz"
"kra/app/system/internal/dto"
)
type AnnouncementInput struct {
@@ -23,8 +22,8 @@ func NewAnnouncementService(uc *biz.AnnouncementUsecase) *AnnouncementService {
return &AnnouncementService{uc: uc}
}
func announcementDTO(item *biz.Announcement) *dto.AnnouncementResponse {
return &dto.AnnouncementResponse{ID: item.ID, CreatedAt: item.CreatedAt, UpdatedAt: item.UpdatedAt, DeletedAt: nil, Title: item.Title, Content: item.Content, UserID: item.UserID, Attachments: json.RawMessage(item.Attachments)}
func announcementDTO(item *biz.Announcement) *AnnouncementResponse {
return &AnnouncementResponse{ID: item.ID, CreatedAt: item.CreatedAt, UpdatedAt: item.UpdatedAt, DeletedAt: nil, Title: item.Title, Content: item.Content, UserID: item.UserID, Attachments: json.RawMessage(item.Attachments)}
}
func announcementDO(in AnnouncementInput) *biz.Announcement {
@@ -47,7 +46,7 @@ func (s *AnnouncementService) DeleteByIDs(ctx context.Context, ids []string) err
return s.uc.DeleteByIDs(ctx, ids)
}
func (s *AnnouncementService) Find(ctx context.Context, id string) (*dto.AnnouncementResponse, error) {
func (s *AnnouncementService) Find(ctx context.Context, id string) (*AnnouncementResponse, error) {
item, err := s.uc.Find(ctx, id)
if err != nil {
return nil, err
@@ -55,26 +54,26 @@ func (s *AnnouncementService) Find(ctx context.Context, id string) (*dto.Announc
return announcementDTO(item), nil
}
func (s *AnnouncementService) List(ctx context.Context, page, pageSize int, start, end *time.Time) ([]*dto.AnnouncementResponse, int64, error) {
func (s *AnnouncementService) List(ctx context.Context, page, pageSize int, start, end *time.Time) ([]*AnnouncementResponse, int64, error) {
items, total, err := s.uc.List(ctx, biz.AnnouncementFilter{Page: page, PageSize: pageSize, StartCreatedAt: start, EndCreatedAt: end})
if err != nil {
return nil, 0, err
}
result := make([]*dto.AnnouncementResponse, 0, len(items))
result := make([]*AnnouncementResponse, 0, len(items))
for _, item := range items {
result = append(result, announcementDTO(item))
}
return result, total, nil
}
func (s *AnnouncementService) UserOptions(ctx context.Context) ([]*dto.SelectOptionResponse, error) {
func (s *AnnouncementService) UserOptions(ctx context.Context) ([]*SelectOptionResponse, error) {
items, err := s.uc.UserOptions(ctx)
if err != nil {
return nil, err
}
result := make([]*dto.SelectOptionResponse, 0, len(items))
result := make([]*SelectOptionResponse, 0, len(items))
for _, item := range items {
result = append(result, &dto.SelectOptionResponse{Label: item.Label, Value: item.Value})
result = append(result, &SelectOptionResponse{Label: item.Label, Value: item.Value})
}
return result, nil
}