package com.cclotus.cms.service

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.cclotus.cms.domain.CmsPostMeta
import com.cclotus.cms.mapper.CmsPostMetaMapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class CmsPostMetaService {

    @Autowired
    lateinit var cmsPostMetaMapper: CmsPostMetaMapper

    /**
     * 根据内容ID列表返回扩展属性列表
     * @param postIds 内容ID列表
     * @return 指定内容ID的扩展属性列表
     */
    fun selectListByPostIds(postIds: List<Int>): List<CmsPostMeta> {
        if (postIds.isEmpty())
            return emptyList()

        return QueryWrapper<CmsPostMeta>()
            .`in`("post_id", postIds)
            .let {
                cmsPostMetaMapper.selectList(it)
            }
    }
}
