package cn.reghao.bnt.web.template.directive;

import cn.reghao.bnt.web.template.DirectiveHandler;
import cn.reghao.bnt.web.template.TemplateDirective;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;

/**
 * 文章内容查询
 * <p>
 * 示例：
 * 请求：http://mtons.com/index?order=newest&pn=2
 * 使用：@contents group=x pn=pn order=order
 *
 * @author langhsu
 */
@Component
public class ContentsDirective extends TemplateDirective {
    /*private final ArticleQuery articleQuery;

    public ContentsDirective(ArticleQuery articleQuery) {
        this.articleQuery = articleQuery;
    }*/

    /**
     * 处理 ftl 模板中的 @contents 标签
     *
     * @param
     * @return
     * @date 2023-04-11 16:31:08
     */
    @Override
    public String getName() {
        return "contents";
    }

    @Override
    public void execute(DirectiveHandler handler) throws Exception {
        Integer channelCode = handler.getInteger("channelCode", 0);
        String order = handler.getString("order", "newest");
        Integer pageNumber = handler.getInteger("pageNo", 1);

        //Page<UserArticle> page = articleQuery.findUserArticleByPage(10, pageNumber);
        handler.put(RESULTS, Page.empty()).render();
    }
}
