package com.clouddrive.dao.impl;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.clouddrive.dao.BaseDao;
import com.clouddrive.dao.RSProcessor;
import com.clouddrive.dao.ShareDao;
import com.clouddrive.entity.Share;
public class ShareDaoImpl extends BaseDao implements ShareDao {
@Override
public int countShare() {
String sql = "select count(*) as share_count from share";
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
int count = 0;
if (rs != null) {
if (rs.next()) {
count = rs.getInt("share_count");
}
}
return new Integer(count);
}
};
return (Integer) this.executeQuery(getResultProcessor, sql);
}
@Override
public int countShareByKey(String key) {
String sql = "select count(*) as share_count from share where keyword=?";
Object[] params = { key };
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
int count = 0;
if (rs != null) {
if (rs.next()) {
count = rs.getInt("share_count");
}
}
return new Integer(count);
}
};
return (Integer) this.executeQuery(getResultProcessor, sql, params);
}
@Override
public Share findShareByKey(String key) {
String sql = "select * from share where keyword = ?";
Object[] params = { key };
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
Share share = null;
if (rs != null) {
if (rs.next()) {
String user = rs.getString("user");
String uuidName = rs.getString("uuidName");
String url = rs.getString("url");
String shareTime = rs.getString("shareTime");
String key = rs.getString("keyword");
int downloads = rs.getInt("downloads");
long size = rs.getLong("size");
share = new Share(user, uuidName, url, shareTime, key, downloads, size);
}
}
return share;
}
};
return (Share) this.executeQuery(getResultProcessor, sql, params);
}
@Override
public int insert(Share share) {
String sql = "insert share (user, uuidName, url, shareTime, keyword, downloads, size) values(?,?,?,?,?,?,?)";
Object[] params = { share.getUser(), share.getUuidName(), share.getUrl(), share.getShareTime(), share.getKey(),
0, share.getSize() };
return this.executeUpdate(sql, params);
}
@SuppressWarnings("unchecked")
@Override
public Vector<Share> findShareByUser(String name) {
String sql = "select * from share where user = ? order by shareTime desc";
Object[] params = { name };
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
Vector<Share> shares = new Vector<Share>();
while (rs.next()) {
String user = rs.getString("user");
String uuidName = rs.getString("uuidName");
String url = rs.getString("url");
String shareTime = rs.getString("shareTime");
String key = rs.getString("keyword");
int downloads = rs.getInt("downloads");
long size = rs.getLong("size");
Share share = new Share(user, uuidName, url, shareTime, key, downloads, size);
shares.add(share);
}
return shares;
}
};
return (Vector<Share>) this.executeQuery(getResultProcessor, sql, params);
}
@Override
public int updateDownloadByKey(String key) {
String sql = "update share \r\n" + "set downloads = downloads+1\r\n" + "where keyword = ?";
Object[] params = { key };
return this.executeUpdate(sql, params);
}
@Override
public int delShareByKey(String key) {
String sql = "delete from share\r\n" + "where keyword = ?";
Object[] params = { key };
return this.executeUpdate(sql, params);
}
@Override
public int delShareByUuidName(String uuidName) {
String sql = "delete from share\r\n" + "where uuidName = ?";
Object[] params = { uuidName };
return this.executeUpdate(sql, params);
}
@Override
public int countShareByUuidName(String uuidName) {
String sql = "select count(*) as share_count from share where uuidName=?";
Object[] params = { uuidName };
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
int count = 0;
if (rs != null) {
if (rs.next()) {
count = rs.getInt("share_count");
}
}
return new Integer(count);
}
};
return (Integer) this.executeQuery(getResultProcessor, sql, params);
}
@Override
public String findKeyByUuidName(String uuidName) {
String sql = "select keyword from share where uuidName = ?";
Object[] params = { uuidName };
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
String key = null;
if (rs != null) {
if (rs.next()) {
key = rs.getString("keyword");
}
}
return key;
}
};
return (String) this.executeQuery(getResultProcessor, sql, params);
}
@SuppressWarnings("unchecked")
@Override
public Vector<Share> getHotShare() {
String sql = "select * from share order by downloads desc limit 12";
Object[] params = {};
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
Vector<Share> shares = new Vector<Share>();
while (rs.next()) {
String user = rs.getString("user");
String uuidName = rs.getString("uuidName");
String url = rs.getString("url");
String shareTime = rs.getString("shareTime");
String key = rs.getString("keyword");
int downloads = rs.getInt("downloads");
long size = rs.getLong("size");
Share share = new Share(user, uuidName, url, shareTime, key, downloads, size);
shares.add(share);
}
return shares;
}
};
return (Vector<Share>) this.executeQuery(getResultProcessor, sql, params);
}
@Override
public int countDownloads() {
String sql = "select sum(downloads) as sumDowmloads from share";
RSProcessor getResultProcessor = new RSProcessor() {
public Object process(ResultSet rs) throws SQLException {
int count = 0;
if (rs != null) {
if (rs.next()) {
count = rs.getInt("sumDowmloads");
}
}
return new Integer(count);
}
};
return (Integer) this.executeQuery(getResultProcessor, sql);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【资源介绍】 基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip 该项目是个人毕设项目,答辩评审分达到95分,代码都经过调试测试,确保可以运行!欢迎下载使用,可用于小白学习、进阶。 该资源主要针对计算机、通信、人工智能、自动化等相关专业的学生、老师或从业者下载使用,亦可作为期末课程设计、课程大作业、毕业设计等。 项目整体具有较高的学习借鉴价值!基础能力强的可以在此基础上修改调整,以实现不同的功能。 欢迎下载交流,互相学习,共同进步! 基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于javaweb的仿照百度网盘的小型云盘系统源码+sql数据库.zip (205个子文件)
UpLoadServlet.class 7KB
ShareDaoImpl.class 4KB
DownLoadServlet.class 4KB
FileListBizImpl.class 4KB
FileManageBizImpl.class 4KB
BaseDao.class 3KB
LoginServlet.class 3KB
Type.class 3KB
ListFilesServlet.class 3KB
FileDaoImpl.class 3KB
DelFileServlet.class 3KB
LeaveMessageServlet.class 3KB
ShareFileServlet.class 3KB
MkDirServlet.class 3KB
Share.class 3KB
HomeListServlet.class 3KB
RegisterServlet.class 3KB
FileMessage.class 3KB
LoginFilter.class 2KB
ShareListServlet.class 2KB
DelShareServlet.class 2KB
ShareServlet.class 2KB
UserDaoImpl.class 2KB
EcharsDataServlet.class 2KB
ShareManageBizImpl.class 2KB
LogoutServlet.class 2KB
User.class 2KB
FileDaoImpl$1.class 2KB
FileDaoImpl$2.class 2KB
ShareDaoImpl$4.class 2KB
ShareDaoImpl$7.class 2KB
CreateKey.class 2KB
ShareDaoImpl$3.class 2KB
InitServlet.class 2KB
CountDataBizImpl.class 2KB
UserDaoImpl$3.class 1KB
LoginBizImpl.class 1KB
Conversion.class 1KB
UserDaoImpl$2.class 1KB
Message.class 1KB
ShareDaoImpl$6.class 1KB
ShareDaoImpl$8.class 1KB
ShareDaoImpl$5.class 1KB
ShareDaoImpl$1.class 1KB
ShareDaoImpl$2.class 1KB
FileDaoImpl$3.class 1KB
UserDaoImpl$1.class 1KB
UserDaoImpl$4.class 1KB
RegisterBizImpl.class 1KB
MessageDaoImpl.class 977B
MessageBizImpl.class 973B
ShareDao.class 796B
CurrentTime.class 759B
FileListBiz.class 593B
FileDao.class 562B
UserDao.class 475B
ShareManageBiz.class 405B
FileManageBiz.class 268B
CountDataBiz.class 238B
RSProcessor.class 233B
LoginBiz.class 201B
RegisterBiz.class 183B
MessageBiz.class 180B
InboxBiz.class 177B
MessageDao.class 174B
.classpath 714B
org.eclipse.wst.common.component 474B
org.eclipse.wst.jsdt.ui.superType.container 49B
fileinput.css 10KB
theme.min.css 3KB
main.css 3KB
checkbox.css 691B
login.css 127B
loading-sm.gif 3KB
loading.gif 847B
mysql-connector-java-5.1.36-bin.jar 949KB
commons-collections4-4.2.jar 735KB
fastjson-1.2.54.jar 576KB
standard.jar 384KB
commons-lang-2.6.jar 278KB
commons-beanutils-1.9.3.jar 240KB
commons-io-2.5.jar 204KB
taglibs-standard-impl-1.2.5.jar 202KB
taglibs-standard-jstlel-1.2.5.jar 159KB
ezmorph-1.0.6.jar 84KB
commons-fileupload-1.3.2.jar 69KB
commons-logging-1.2.jar 60KB
taglibs-standard-compat-1.2.5.jar 52KB
taglibs-standard-spec-1.2.5.jar 39KB
jstl.jar 20KB
ShareDaoImpl.java 6KB
UpLoadServlet.java 6KB
FileDaoImpl.java 4KB
ListFilesServlet.java 3KB
Type.java 3KB
BaseDao.java 3KB
DownLoadServlet.java 3KB
UserDaoImpl.java 3KB
LoginServlet.java 3KB
FileManageBizImpl.java 2KB
共 205 条
- 1
- 2
- 3
资源评论
onnx
- 粉丝: 9619
- 资源: 5597
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功