package com.ynfy.buss.article.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynfy.buss.article.entity.Article;
import com.ynfy.buss.article.mapper.ArticleMapper;
import com.ynfy.buss.article.service.IArticleService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: article
 * @Author: jeecg-boot
 * @Date: 2023-12-23
 * @Version: V1.0
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {

    @Override
    public List<Article> listRecommendArticle(Integer limit) {
        LambdaQueryWrapper<Article> query = new LambdaQueryWrapper<>();
        query.eq(Article::getIsRecommend, true).eq(Article::getStatus, 1)
                .last("LIMIT " + limit).orderByDesc(Article::getCreateTime);
        return list(query);
    }
}
