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) {
/
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!! 别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!! 别再对比了,资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,能够满足使用、学习需求,如果有需要的话可以放心下载使用。有任何问题也可以直接私信博主,博主会第一时间给您解答!!!
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 733 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/1ad39e95093044228d03f0d7ce161a82_zy_dreamer.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
白话机器学习
- 粉丝: 1w+
- 资源: 7693
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)