package com.zioinfo.cms.content.mapper;

import com.zioinfo.cms.content.CmsContent;
import com.zioinfo.cms.content.CmsContentVersion;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ContentMapper {

    List<CmsContent> findAll(@Param("contentType") String contentType,
                             @Param("status") String status,
                             @Param("locale") String locale,
                             @Param("keyword") String keyword);

    CmsContent findById(@Param("id") Long id);

    CmsContent findPublishedBySlug(@Param("slug") String slug, @Param("locale") String locale);

    int countBySlug(@Param("slug") String slug, @Param("locale") String locale, @Param("excludeId") Long excludeId);

    int insert(CmsContent c);

    int update(CmsContent c);

    int updateStatus(@Param("id") Long id, @Param("status") String status, @Param("updatedBy") String updatedBy);

    int updatePublished(@Param("id") Long id, @Param("status") String status);

    int delete(@Param("id") Long id);

    // 예약 게시 — 예약 시각 도래한 APPROVED 콘텐츠
    List<CmsContent> findDueScheduled();

    // ── 버전 ──
    int insertVersion(CmsContentVersion v);

    List<CmsContentVersion> findVersions(@Param("contentId") Long contentId);

    CmsContentVersion findVersion(@Param("contentId") Long contentId, @Param("version") Integer version);
}
