package com.ischoolbar.programmer.dao; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import com.ischoolbar.programmer.model.Clazz; import com.ischoolbar.programmer.model.Page; import com.ischoolbar.programmer.util.StringUtil; /** * * @author llq *班级信息数据库操作 */ public class ClazzDao extends BaseDao { public List<Clazz> getClazzList(Clazz clazz,Page page){ List<Clazz> ret = new ArrayList<Clazz>(); String sql = "select * from s_clazz "; if(!StringUtil.isEmpty(clazz.getName())){ sql += "where name like '%" + clazz.getName() + "%'"; } sql += " limit " + page.getStart() + "," + page.getPageSize(); ResultSet resultSet = query(sql); try { while(resultSet.next()){ Clazz cl = new Clazz(); cl.setId(resultSet.getInt("id")); cl.setName(resultSet.getString("name")); cl.setInfo(resultSet.getString("info")); ret.add(cl); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ret; } public int getClazzListTotal(Clazz clazz){ int total = 0; String sql = "select count(*)as total from s_clazz "; if(!StringUtil.isEmpty(clazz.getName())){ sql += "where name like '%" + clazz.getName() + "%'"; } ResultSet resultSet = query(sql); try { while(resultSet.next()){ total = resultSet.getInt("total"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return total; } public boolean addClazz(Clazz clazz){ String sql = "insert into s_clazz values(null,'"+clazz.getName()+"','"+clazz.getInfo()+"') "; return update(sql); } public boolean deleteClazz(int id){ String sql = "delete from s_clazz where id = "+id; return update(sql); } public boolean editClazz(Clazz clazz) { // TODO Auto-generated method stub String sql = "update s_clazz set name = '"+clazz.getName()+"',info = '"+clazz.getInfo()+"' where id = " + clazz.getId(); return update(sql); } }
最近下载更多
微信网友_6906962132258816 LV4
3月16日
zhangjilu LV18
1月1日
磊哥哥哥哥 LV13
2023年12月26日
heweimin LV12
2023年12月12日
hapilong LV5
2023年12月11日
蹇金金 LV7
2023年10月31日
卢本伟不开挂 LV4
2023年10月22日
skook7 LV2
2023年10月6日
刘洋66666 LV1
2023年9月19日
uni-code_0123 LV1
2023年8月8日
最近浏览更多
dameir
3月26日
暂无贡献等级
alphaeix
3月18日
暂无贡献等级
微信网友_6906962132258816 LV4
3月16日
WBelong LV6
3月8日
潘潘123456 LV2
3月2日
杨豫川 LV12
1月12日
暂无贡献等级
山海雾众生安 LV1
1月4日
202210040203 LV1
1月3日
一磕小橙子 LV1
1月2日