package com.gameplatform.server.model.dto.admin;

import com.gameplatform.server.model.entity.admin.Announcement;

public class AnnouncementConverter {
    
    /**
     * 将请求DTO转换为实体
     */
    public static Announcement toEntity(AnnouncementRequest request) {
        if (request == null) {
            return null;
        }
        
        Announcement announcement = new Announcement();
        announcement.setTitle(request.getTitle());
        announcement.setContent(request.getContent());
        announcement.setEnabled(request.getEnabled());
        announcement.setJumpUrl(request.getJumpUrl());
        announcement.setBelongId(request.getBelongId());
        
        return announcement;
    }
    
    /**
     * 将实体转换为响应DTO
     */
    public static AnnouncementResponse toResponse(Announcement announcement) {
        if (announcement == null) {
            return null;
        }
        
        AnnouncementResponse response = new AnnouncementResponse();
        response.setId(announcement.getId());
        response.setTitle(announcement.getTitle());
        response.setContent(announcement.getContent());
        response.setEnabled(announcement.getEnabled());
        response.setJumpUrl(announcement.getJumpUrl());
        response.setCreatedAt(announcement.getCreatedAt());
        response.setUpdatedAt(announcement.getUpdatedAt());
        response.setBelongId(announcement.getBelongId());
        
        return response;
    }
}
