package com.hd.dao.impl;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hd.dao.CustomerDao;
import com.hd.entity.Customer;
import com.hd.entity.CustomerCondition;
import com.hd.entity.CustomerSource;
import com.hd.entity.CustomerType;
import com.hd.entity.UserInfo;
import com.hd.util.DBUtil;
public class CustomerDaoImpl implements CustomerDao {
@Override
public List<Customer> showAll() {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
List<Customer> customerList = new ArrayList<Customer>();
try {
conn = DBUtil.getConnection();
String sql = "select * from customer_info;";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
int customer_id = rs.getInt("customer_id");
String customer_name = rs.getString("customer_name");
int condition_id = rs.getInt("condition_id");
int source_id = rs.getInt("source_id");
int user_id = rs.getInt("user_id");
int type_id = rs.getInt("type_id");
String customer_sex = rs.getString("customer_sex");
String customer_mobile = rs.getString("customer_mobile");
String customer_qq = rs.getString("customer_qq");
String customer_email = rs.getString("customer_email");
String customer_job = rs.getString("customer_job");
String customer_company = rs.getString("customer_company");
String customer_remark = rs.getString("customer_remark");
// 新增获得生日,我觉得改数据库要
Date birth_day = rs.getDate("birth_day");
Customer customer = new Customer(customer_id, customer_name,
condition_id, source_id, user_id, type_id,
customer_sex, customer_mobile, customer_qq,
customer_email, customer_job, customer_company,
customer_remark, birth_day);
customerList.add(customer);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.closeAll(rs, stmt, conn);
}
return customerList;
}
@Override
public int delete(int customer_id) {
String sql = "delete from customer_info where customer_id = ?";
Object params[] = { customer_id };
return DBUtil.executeUpdate(sql, params);
}
/*
* 获取符合查询条件的所有信息条目
*/
@Override
public int findRequiredCount(String queryType, String customerInput) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
int n = 0;
try {
conn = DBUtil.getConnection();
StringBuffer sql = new StringBuffer(
"select count(1) from customer_info i "
+ " left join user_info u on i.user_id=u.user_id "
+ " left join customer_condition c on i.condition_id=c.condition_id "
+ " left join customer_source s on i.source_id=s.source_id "
+ " left join customer_type t on i.type_id=t.type_id where 1=1");
if (customerInput != null && !"".equals(customerInput)) {
sql.append(" and " + queryType + " like'%" + customerInput
+ "%'");
}
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
rs.next();
n = rs.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.closeAll(rs, stmt, conn);
}
return n;
}
/*
* 获取符合条件的所有员工信息
*/
@Override
public List<Customer> findRequiredCustomer(int start, int size,
String queryType, String customerInput) {
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
List<Customer> customerList = new ArrayList<Customer>();
try {
// (和数据库)建立连接
conn = DBUtil.getConnection();
// (向数据库)发送命令并得到结果
StringBuffer sql = new StringBuffer(
"select * from customer_info i "
+ " left join user_info u on i.user_id=u.user_id "
+ " left join customer_condition c on i.condition_id=c.condition_id "
+ " left join customer_source s on i.source_id=s.source_id "
+ " left join customer_type t on i.type_id=t.type_id where 1=1");
if (customerInput != null && !"".equals(customerInput)) {
sql.append(" and " + queryType + " like'%" + customerInput
+ "%'");
}
sql.append(" limit " + start + "," + size);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql.toString());
// 处理结果
while (rs.next()) {
// 获取各列的数据
int customer_id = rs.getInt("customer_id");
String customer_name = rs.getString("customer_name");
int condition_id = rs.getInt("condition_id");
int source_id = rs.getInt("source_id");
int user_id = rs.getInt("user_id");
int type_id = rs.getInt("type_id");
String customer_sex = rs.getString("customer_sex");
String customer_mobile = rs.getString("customer_mobile");
String customer_qq = rs.getString("customer_qq");
String customer_email = rs.getString("customer_email");
String customer_job = rs.getString("customer_job");
String customer_company = rs.getString("customer_company");
String customer_remark = rs.getString("customer_remark");
Date birth_day = rs.getDate("birth_day");
Date customer_addtime = rs.getDate("customer_addtime");
Date customer_changetime = rs.getDate("customer_changtime");
String customer_address = rs.getString("customer_address");
String customer_blog = rs.getString("customer_blog");
String customer_tel = rs.getString("customer_tel");
String customer_msn = rs.getString("customer_msn");
String customer_addman = rs.getString("customer_addman");
String change_man = rs.getString("change_man");
String is_used = rs.getString("is_used");
// 将各列的数据封装到Employee对象中
/*
* Customer customer = new Customer(customer_id, customer_name,
* condition_id, source_id, user_id, type_id, customer_sex,
* customer_mobile, customer_qq, customer_email, customer_job,
* customer_company, customer_remark, birth_day);
*/
Customer customer = new Customer(customer_id, condition_id,
source_id, user_id, type_id, customer_name,
customer_sex, customer_mobile, customer_qq,
customer_address, customer_email, customer_remark,
customer_job, customer_blog, customer_tel,
customer_msn, birth_day, customer_addtime,
customer_addman, customer_changetime, change_man,
customer_company, is_used);
int condition_id2 = rs.getInt("condition_id");
String condition_name = rs.getString("condition_name");
String condition_explain = rs.getString("condition_explain");
String is_used3 = rs.getString("is_used");
CustomerCondition customerCondition = new CustomerCondition(
condition_id2, condition_name, condition_explain,
is_used);
customer.setCustomerCondition(customerCondition);
int source_id2 = rs.getInt("source_id");
String source_name = rs.getString("source_name");
String is_used2 = rs.getString("is_used");
CustomerSource customerSource = new CustomerSource(source_id2,
source_name, is_used2);
customer.setCustomerSource(customerSource);
int typeId = rs.getInt("type_id");
String typeName = rs.getString("type_name");
String isUsed = rs.getString("is_used");
CustomerType customerType = new CustomerType(typeId, typeName,
isUsed);
customer.setCustomerType(customerType);
int user_id3 = rs.getInt("user_id");
String user_name = rs.getString("user_name");
UserInfo userInfo = new UserInfo(user_id3, user_name);
customer.setUserInfo(userInfo);
customerList.add(customer);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 关闭资源
DBUtil.closeAll(rs, stmt, conn);
}
// 返回数据
return customerList;
}
@Override
public int save(Customer customer) {
String sql = "insert into customer_info values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
// 客户id和user_id为默认值,客户id默认
没有合适的资源?快使用搜索试试~ 我知道了~
房地产管理系统.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共322个文件
class:82个
java:82个
gif:64个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 56 浏览量
2024-03-07
17:11:04
上传
评论
收藏 37.11MB ZIP 举报
温馨提示
本项目是作者自己开发的毕设项目,代码注释清楚,环境部署文档完备
资源推荐
资源详情
资源评论
![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)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.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/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
共 322 条
- 1
- 2
- 3
- 4
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/f62fbb2c17a9404795551a60e3b1502a_weixin_32393347.jpg!1)
小码蚁.
- 粉丝: 2670
- 资源: 4523
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的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)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)