package com.chenyang.nse.bussiness.dao.table.console;

import com.chenyang.nse.bussiness.dao.BaseDao;
import com.chenyang.nse.bussiness.dao.PageInfo;
import com.chenyang.nse.bussiness.entity.orm.table.console.TConsoleFastManage;
import java.math.BigInteger;
import java.util.List;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

@Repository
public class TConsoleFastManageDao extends BaseDao<TConsoleFastManage, String> {
   public void updatefast(TConsoleFastManage tConsoleFastManage, String date1) {
      String sql = "update T_CONSOLE_FASTMANAGE set fastexport = '" + tConsoleFastManage.getFastexport() + "',fastimport = '" + tConsoleFastManage.getFastimport() + "',createtime = '" + date1 + "'where id ='" + tConsoleFastManage.getId() + "'";
      this.getSession().createNativeQuery(sql).executeUpdate();
   }

   public List<TConsoleFastManage> queryByPageDesc(PageInfo pageInfo) {
      String sql1 = "select count(1) from  t_console_fastmanage ";
      long count = (long)((BigInteger)this.getSession().createNativeQuery(sql1).getSingleResult()).intValue();
      pageInfo.setCount(count);
      String sql = "select id as id,databasetype,fastexport,fastimport from t_console_fastmanage order by createtime desc ";
      List<TConsoleFastManage> list = this.getSession().createNativeQuery(sql).setFirstResult(pageInfo.getOffset()).setMaxResults(pageInfo.getPagesize()).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).getResultList();
      return list;
   }
}
