📄 fwxxdaoimpl.java
字号:
package com.accp.dao;
import java.util.Date;
import java.util.List;
import com.accp.entity.TblFwxx;
import com.accp.forms.FwxxForm;
public class FwxxDAOImpl extends BaseHibernateDAO implements IFwxxDAO
{
/**
* 删除房屋信息
*/
public boolean deleteFwxx(Integer id)
{
TblFwxx fwxx = (TblFwxx) super.findByPK(TblFwxx.class, id);
return super.deleteObj(fwxx);
}
/**
* 查找所有房屋信息
*/
public List findAll(int pageNo, int pageSize)
{
String hql = "from TblFwxx";
return super.getList(pageNo, pageSize, hql);
}
/**
* 按主键查找房屋信息
*/
public TblFwxx findByPK(Integer id)
{
TblFwxx fwxx = (TblFwxx) super.findByPK(TblFwxx.class, id);
return fwxx;
}
/**
* 添加房屋信息
*/
public boolean saveFwxx(TblFwxx fwxx)
{
return super.addObject(fwxx);
}
/**
* 更新房屋信息
*/
public boolean updateFwxx(TblFwxx fwxx)
{
return super.updateObj(fwxx);
}
/**
* 获得总页数
*/
public int getTotalPage(int pageSize)
{
int totalLine = (Integer) super
.getUniqueResult("select count(*) from TblFwxx");
int totalPage = (totalLine % pageSize == 0) ? (totalLine / pageSize)
: (totalLine / pageSize + 1);
return totalPage;
}
/**
* 按标题查询
*/
public TblFwxx findByTitle(String title)
{
TblFwxx fwxx=(TblFwxx)super.getUniqueResult("from TblFwxx like title="+title+"");
return fwxx;
}
public List findByUser(int id)
{
List list=super.getAll("from TblFwxx where uid='"+id+"'");
return list;
}
/**
* 根据用户输入的条件查询
*/
public List search(FwxxForm condition)
{
StringBuffer hql=new StringBuffer("");
hql.append("from TblFwxx where 1=1");
//加入用户的查询条件
//如果用户输入了查询条件,构建查询条件
if(null !=condition.getTitle()&&!"".equals(condition.getTitle()))
{
hql.append("and title like '%"+condition.getTitle()+"%'");
}
if(0!=condition.getJdid())
{
hql.append("and jdid='"+condition.getJdid()+"'");
}
if(0!=condition.getMinzj())
{
hql.append("and zj>="+condition.getMinzj()+"");
}
if(0!=condition.getMaxzj())
{
hql.append("and zj<="+condition.getMaxzj()+"");
}
if(null!=condition.getLxid())
{
String str="";
int [] array=condition.getLxid();
for(int i=0;i<array.length;i++)
{
if(array.length-1==i)
str+=array[i];
else
str+=array[i]+",";
}
hql.append("and lxid in ("+str+")");
}
if(null!=condition.getDate())
{
//获得用户输入的提前的天数
Date day=condition.getDate();
Date d=new Date();
// d.setDate(d.getDate()-day);
hql.append("and date>='"+d.toLocaleString()+"'");
}
hql.append("order by date desc");
//获得结果
List list =super.getAll(hql.toString());
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -