优化结构

This commit is contained in:
Yvan
2026-08-25 00:20:29 +08:00
parent 969afee284
commit ee179d6b34
49 changed files with 289 additions and 591 deletions
+3 -11
View File
@@ -9,14 +9,6 @@ import (
"kra/internal/service/dto"
)
type AnnouncementInput struct {
ID uint
Title string
Content string
UserID *int
Attachments json.RawMessage
}
type AnnouncementService struct{ uc *system.AnnouncementUsecase }
func NewAnnouncementService(uc *system.AnnouncementUsecase) *AnnouncementService {
@@ -27,15 +19,15 @@ func announcementDTO(item *system.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 announcementDO(in AnnouncementInput) *system.Announcement {
func announcementDO(in *dto.AnnouncementRequest) *system.Announcement {
return &system.Announcement{ID: in.ID, Title: in.Title, Content: in.Content, UserID: in.UserID, Attachments: in.Attachments}
}
func (s *AnnouncementService) Create(ctx context.Context, in AnnouncementInput) error {
func (s *AnnouncementService) Create(ctx context.Context, in *dto.AnnouncementRequest) error {
return s.uc.Create(ctx, announcementDO(in))
}
func (s *AnnouncementService) Update(ctx context.Context, in AnnouncementInput) error {
func (s *AnnouncementService) Update(ctx context.Context, in *dto.AnnouncementRequest) error {
return s.uc.Update(ctx, announcementDO(in))
}