package com.service;


import com.jfinal.plugin.activerecord.Page;
import com.model.Booktype;

import java.util.ArrayList;
import java.util.List;

/**
 * 五大类
 * 2018-10-22
 * zj
 */
public class BookTypeService {

	public static final BookTypeService me = new BookTypeService();
	private Booktype dao = new Booktype().dao();

	public Page<Booktype> paginate(int pageNumber,int pagesize, String type){

		String select = "SELECT id,`name` ";
		StringBuilder where = new StringBuilder(" from t_booktype WHERE parentid =? ");
		return dao.paginate(pageNumber, pagesize,select,where.toString(), type);
	}


	public List<String> booktype(){
		List<Booktype> booktypeList=dao.find("   SELECT id,name FROM t_booktype ");
		List<String> list =new ArrayList<String>();
		for (Booktype booktype : booktypeList) {
			list.add(booktype.getId());
		}
		return list;
	}
}
