package com.jfinal.club._front;

import com.jfinal.club.common.controller.BaseController;
import com.jfinal.club.common.model.Ideas;
import com.jfinal.club.common.model.IdeasType;
import com.jfinal.club.common.model.Recommend;

import java.util.HashMap;
import java.util.List;

/**
 * @Auther: LiuChao
 * @Date: 2021/2/27 20:31
 * @Description:
 */
public class PeifangController extends BaseController {

    public void index(){
        List<IdeasType> ideasTypes = IdeasType.dao.find("select * from ideas_type order by sort desc,create_time desc");
        set("ideasTypesList",ideasTypes);
        render("peifang.html");
    }

    public void list(){

        Integer type = getInt(0);
        List<Ideas> ideasList = Ideas.dao.find("select * from ideas where type = ? order by sort desc,create_time desc", type);
        set("ideasList",ideasList);
        set("ideasTypesList",IdeasType.dao.find("select * from ideas_type order by sort desc,create_time desc"));

        set("type",type);
        render("peifang_list.html");
    }

    public void detail(){
        Integer id = getInt(0);

        Ideas ideas = Ideas.dao.findById(id);
        set("ideas",ideas);

        List<Recommend> recommentIdeasList = Recommend.dao.find("select * from recommend where pid = ? order by sort desc,create_time desc ",id);
        set("recommentIdeasList",recommentIdeasList);

        render("peifang_detail.html");
    }
}
