package com.oaoffice.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.oaoffice.util.DbFun;
import com.oaoffice.bean.User;
import com.oaoffice.dao.UserDao;
import com.oaoffice.util.PagingVO;
public class UserDaoImpl implements UserDao{
@SuppressWarnings("resource")
public Integer insert(User bean) {
//user_id,user_name,user_realname,user_pwd,user_sex,phonenumber,user_born
//user_address,user_hobby,user_email,selfassessment,headpic,dept_id
StringBuilder sb = new StringBuilder();
sb.append(" Insert Into User(user_name,user_realname,user_pwd,user_sex,");
sb.append(" phonenumber,user_born,user_address,user_email,headpic,dept_id)");
sb.append("Values(?,?,?,?,?,?,?,?,?,?)");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Integer num = 0;
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setObject(1, bean.getUser_name());
pstmt.setObject(2, bean.getUser_realname());
pstmt.setObject(3, bean.getUser_pwd());
pstmt.setObject(4, bean.getUser_sex());
pstmt.setObject(5, bean.getPhonenumber());
pstmt.setObject(6, bean.getUser_born());
pstmt.setObject(7, bean.getUser_address());
pstmt.setObject(8, bean.getUser_email());
pstmt.setObject(9, bean.getHeadpic());
pstmt.setObject(10, bean.getDept_id());
num = pstmt.executeUpdate();
// 如果受影响行数大于0,说明添加成功;之后,要获取刚刚添加的行的主键值
if (num > 0) {
sql = "Select @@Identity";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
num = rs.getInt(1);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return num;
}
public List<User> list() {
List<User> list = new ArrayList<User>();
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" a.*,");
sb.append(" d.role_name,");
sb.append(" b.dept_name");
sb.append(" FROM" );
sb.append(" USER AS a");
sb.append(" LEFT JOIN dept b ON a.dept_id = b.dept_id ");
sb.append(" LEFT JOIN user_role c ON c.user_id = a.user_id ");
sb.append(" LEFT JOIN role d ON c.role_id = d.role_id ");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
//user_id,user_name,user_realname,user_pwd,user_sex,phonenumber,user_born
//user_address,user_hobby,user_email,selfassessment,headpic,dept_id
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
User tmpbean = null;
while (rs.next()) {
tmpbean = new User();
tmpbean.setUser_id(rs.getInt("user_id"));
tmpbean.setUser_name(rs.getString("user_name"));
tmpbean.setUser_realname(rs.getString("user_realname"));
tmpbean.setUser_pwd(rs.getString("user_pwd"));
tmpbean.setUser_sex(rs.getString("user_sex"));
tmpbean.setPhonenumber(rs.getString("phonenumber"));
tmpbean.setUser_born(rs.getDate("user_born"));
tmpbean.setUser_address(rs.getString("user_address"));
tmpbean.setUser_email(rs.getString("user_email"));
tmpbean.setHeadpic(rs.getString("headpic"));
tmpbean.setDept_id(rs.getInt("dept_id"));
tmpbean.setDept_name(rs.getString("dept_name"));
tmpbean.setRole_name(rs.getString("role_name"));
list.add(tmpbean);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return list;
}
public Integer delete(Integer id) {
StringBuilder sb = new StringBuilder();
sb.append(" delete from User where user_id=?");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Integer num = 0;
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setObject(1, id);
num = pstmt.executeUpdate();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return num;
}
public Integer update(User bean) {
// TODO Auto-generated method stub
StringBuilder sb = new StringBuilder();
sb.append(" update User Set ");
sb.append(" user_name=? ");
sb.append(" ,user_realname=? ");
sb.append(" ,user_pwd=? ");
sb.append(" ,user_sex=? ");
sb.append(" ,phonenumber=? ");
sb.append(" ,user_born=? ");
sb.append(" ,user_address=? ");
sb.append(" ,user_hobby=? ");
sb.append(" ,user_email=? ");
sb.append(" ,selfassessment=? ");
sb.append(" ,headpic=? ");
sb.append(" ,dept_id=? ");
sb.append(" where user_id=?");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Integer num = 0;
//uname,upass,realName,gender,birthday
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setObject(1, bean.getUser_name());
pstmt.setObject(2, bean.getUser_realname());
pstmt.setObject(3, bean.getUser_pwd());
pstmt.setObject(4, bean.getUser_sex());
pstmt.setObject(5, bean.getPhonenumber());
pstmt.setObject(6, bean.getUser_born());
pstmt.setObject(7, bean.getUser_address());
pstmt.setObject(8, bean.getUser_hobby());
pstmt.setObject(9, bean.getUser_email());
pstmt.setObject(10, bean.getSelfassessment());
pstmt.setObject(11, bean.getHeadpic());
pstmt.setObject(12, bean.getDept_id());
pstmt.setObject(13, bean.getUser_id());
num = pstmt.executeUpdate();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return num;
}
public User load(Integer id) {
StringBuilder sb = new StringBuilder();
sb.append("SELECT");
sb.append(" a.*,");
sb.append(" b.dept_name");
sb.append(" FROM" );
sb.append(" USER AS a");
sb.append(" LEFT JOIN dept b ON a.dept_id = b.dept_id ");
sb.append(" Where user_id=?");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
User bean = null;
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setObject(1, id);
rs = pstmt.executeQuery();
if (rs.next()) {
bean = new User();
bean.setUser_id(rs.getInt("user_id"));
bean.setUser_name(rs.getString("user_name"));
bean.setUser_realname(rs.getString("user_realname"));
bean.setUser_pwd(rs.getString("user_pwd"));
bean.setUser_sex(rs.getString("user_sex"));
bean.setPhonenumber(rs.getString("phonenumber"));
bean.setUser_born(rs.getDate("user_born"));
bean.setUser_address(rs.getString("user_address"));
bean.setUser_hobby(rs.getString("user_hobby"));
bean.setUser_email(rs.getString("user_email"));
bean.setSelfassessment(rs.getString("selfassessment"));
bean.setHeadpic(rs.getString("headpic"));
bean.setDept_id(rs.getInt("dept_id"));
bean.setDept_name(rs.getString("dept_name"));
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return bean;
}
public Integer count() {
StringBuilder sb = new StringBuilder();
sb.append(" select count(1) from User");
String sql = sb.toString();
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Integer num = 0;
try {
conn = DbFun.getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()) {
num=rs.getInt(1);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DbFun.close(rs, pstmt, conn);
}
return num;
}
public User loadByName(String name) {
/
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!! 别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!! 别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!!
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM框架+MySQL实现的企业级OA管理系统源码.zip (733个子文件)
PowerDaoImpl.class 11KB
PowerDaoImpl.class 11KB
MeetingapplyDaoImpl.class 11KB
MeetingapplyDaoImpl.class 11KB
UserDaoImpl.class 11KB
UserDaoImpl.class 11KB
UserServlet.class 10KB
UserServlet.class 10KB
VacateDaoImpl.class 10KB
VacateDaoImpl.class 10KB
MeetingDaoImpl.class 9KB
MeetingDaoImpl.class 9KB
DothingDaoImpl.class 9KB
DothingDaoImpl.class 9KB
FloderDaoImpl.class 9KB
FloderDaoImpl.class 9KB
CalendarDaoImpl.class 9KB
CalendarDaoImpl.class 9KB
BulletinDaoImpl.class 9KB
BulletinDaoImpl.class 9KB
MeetingRoomDaoImpl.class 8KB
MeetingRoomDaoImpl.class 8KB
User.class 6KB
User.class 6KB
DeptDaoImpl.class 6KB
DeptDaoImpl.class 6KB
powerFilter.class 6KB
powerFilter.class 6KB
MeetingapplyServlet.class 5KB
MeetingapplyServlet.class 5KB
MeetingServlet.class 5KB
MeetingServlet.class 5KB
DothingServlet.class 5KB
DothingServlet.class 5KB
BulletinServlet.class 5KB
BulletinServlet.class 5KB
CalendarServlet.class 5KB
CalendarServlet.class 5KB
VacateServlet.class 5KB
VacateServlet.class 5KB
PowerServlet.class 4KB
PowerServlet.class 4KB
FloderServlet.class 4KB
FloderServlet.class 4KB
MeetingRoomServlet.class 4KB
MeetingRoomServlet.class 4KB
Vacate.class 4KB
Vacate.class 4KB
DeptServlet.class 4KB
DeptServlet.class 4KB
DbFun.class 4KB
DbFun.class 4KB
Meetingapply.class 4KB
Meetingapply.class 4KB
UploadServlet.class 3KB
UploadServlet.class 3KB
UserListServlet.class 3KB
UserListServlet.class 3KB
loginFilter.class 3KB
loginFilter.class 3KB
PowerServiceImpl.class 3KB
PowerServiceImpl.class 3KB
Bulletin.class 3KB
Bulletin.class 3KB
Power.class 3KB
Power.class 3KB
Meeting.class 3KB
Meeting.class 3KB
Dothing.class 3KB
Dothing.class 3KB
UserServiceImpl.class 3KB
UserServiceImpl.class 3KB
Calendar.class 3KB
Calendar.class 3KB
MeetingapplyServiceImpl.class 3KB
MeetingapplyServiceImpl.class 3KB
MeetingRoomServiceImpl.class 2KB
MeetingRoomServiceImpl.class 2KB
CalendarServiceImpl.class 2KB
BulletinServiceImpl.class 2KB
BulletinServiceImpl.class 2KB
CalendarServiceImpl.class 2KB
DothingServiceImpl.class 2KB
MeetingServiceImpl.class 2KB
MeetingServiceImpl.class 2KB
DothingServiceImpl.class 2KB
FloderServiceImpl.class 2KB
VacateServiceImpl.class 2KB
FloderServiceImpl.class 2KB
VacateServiceImpl.class 2KB
DeptServiceImpl.class 2KB
DeptServiceImpl.class 2KB
Floder.class 2KB
Floder.class 2KB
CharacterFilter.class 2KB
CharacterFilter.class 2KB
PagingVO.class 2KB
PagingVO.class 2KB
MeetingRoom.class 1KB
MeetingRoom.class 1KB
共 733 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
白话机器学习
- 粉丝: 1w+
- 资源: 7670
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 05-培训总结表.xlsx
- 培训评估调查问卷.xlsx
- 培训实践效果反馈与评估表(行动学习反馈).xlsx
- 培训评估反馈表.docx
- 培训评估管理办法(修改).docx
- 柯氏四级培训评估体系.doc.docx
- 基于java的旅游管理系统设计与实现
- 【年度培训】培训效果评估办法行政人事CLUB.docx
- 【年度培训】年度培训计划方案行政人事CLUB.docx
- 【年度培训】年度培训计划 (1)行政人事CLUB.docx
- 【年度培训】集团年度培训计划与方案汇编行政人事CLUB.docx
- 【年度培训】行政办公系统培训资料行政人事CLUB.docx
- 【年度培训】企业培训效果评估表行政人事CLUB.doc
- 【年度培训】培训效果评估报告分析行政人事CLUB.doc
- 打印機設定:M337x-387x-407x-Series-WIN-SPL-PCL-V3.13.13.00.01-CDV1.38
- 【年度培训】培训需求分析行政人事CLUB.doc
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功