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

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

/**
 * method: [latest_posts, hottest_posts, latest_comments]
 * created by langhsu
 * on 2019/3/12
 */
@Component
public class SidebarDirective extends TemplateDirective {
    /*private final ArticleQuery articleQuery;

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

    @Override
    public String getName() {
        return "sidebar";
    }

    @Override
    public void execute(DirectiveHandler handler) throws Exception {
        //int size = handler.getInteger("size", 5);
        int size = 5;
        String method = handler.getString("method", "post_latests");
        /*switch (method) {
            case "latest_posts":
                handler.put(RESULTS, articleQuery.getLatest(size));
                break;
            case "hottest_posts":
                handler.put(RESULTS, articleQuery.getHottest(size));
                break;
        }*/
        handler.render();
    }
}
