/**
*
*/
package com.cl.service;
import java.util.List;
import java.util.Map;
import org.nutz.dao.Condition;
import org.nutz.dao.Dao;
import org.nutz.dao.pager.Pager;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.service.IdEntityService;
import com.cl.util.ReturnUtil;
/**
* @author dp-004
*
/
@IocBean(args = { "refer:dao" }) /* * 指定构造函数注入对象 * */
public class BaseService extends IdEntityService {
public BaseService() {
super();
// TODO Auto-generated constructor stub
}
public BaseService(Dao dao, Class<T> entityType) {
super(dao, entityType);
// TODO Auto-generated constructor stub
}
public BaseService(Dao dao) {
super(dao);
// TODO Auto-generated constructor stub
}
public void save(T t) {
dao().insert(t);
}
public void update(T t) {
dao().update(t);
}
public Map<String, Object> parseEasyui(Class<?> _class, Condition cri, int row, int page) {
Map<String, Object> map = ReturnUtil.returnSuccess("ok");
Pager pager = dao().createPager(page, row);
@SuppressWarnings("unchecked")
List<T> list = (List<T>) dao().query(_class, cri, pager);
pager.setRecordCount(dao().count(_class, cri));
map.put("rows", list);
map.put("total", pager.getRecordCount());
map.put("pager", pager);
return map;
}
}