package com.gameplatform.server.mapper.admin;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gameplatform.server.model.entity.admin.Announcement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface AnnouncementMapper extends BaseMapper<Announcement> {
    Announcement findById(@Param("id") Long id);
    
    int insert(Announcement announcement);
    
    int update(Announcement announcement);
    
    int deleteById(@Param("id") Long id);
    
    List<Announcement> findAll(@Param("size") int size,
                              @Param("offset") int offset);
    
    long countAll();
    
    List<Announcement> findByEnabled(@Param("enabled") Boolean enabled,
                                   @Param("size") int size,
                                   @Param("offset") int offset);
    
    long countByEnabled(@Param("enabled") Boolean enabled);
    
    int updateEnabled(@Param("id") Long id, @Param("enabled") Boolean enabled);
    
    List<Announcement> findByBelongId(@Param("belongId") Integer belongId,
                                     @Param("size") int size,
                                     @Param("offset") int offset);
    
    long countByBelongId(@Param("belongId") Integer belongId);
    
    List<Announcement> findByBelongIdAndEnabled(@Param("belongId") Integer belongId,
                                               @Param("enabled") Boolean enabled,
                                               @Param("size") int size,
                                               @Param("offset") int offset);
    
    long countByBelongIdAndEnabled(@Param("belongId") Integer belongId,
                                  @Param("enabled") Boolean enabled);
}
