优化结构
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user