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); } }

李清清 LV2
2024年11月6日
lxm2440226414 LV2
2024年6月10日
云着殇 LV9
2024年6月5日
lzx602 LV3
2024年4月15日
微信网友_6906962132258816 LV7
2024年3月16日
zhangjilu LV18
2024年1月1日
磊哥哥哥哥 LV13
2023年12月26日
heweimin LV13
2023年12月12日
hapilong LV6
2023年12月11日
蹇金金 LV7
2023年10月31日

Maomaoyun
6月10日
暂无贡献等级
zxy111111
6月8日
暂无贡献等级
微信网友_7520905278033920 LV1
5月22日
xianyu091012 LV5
2024年12月26日
言123456
2024年12月24日
暂无贡献等级
3375276400
2024年12月24日
暂无贡献等级
TTThai LV1
2024年12月17日
微信网友_7298641941385216
2024年12月16日
暂无贡献等级
Daima000 LV4
2024年12月5日
李清清 LV2
2024年11月6日