搭建Java共享网盘( 二 )

3.检索重复上传的资源
//这里上传在上面上传资源时候,将保存原始资源名字public List<UserFile> findRetrieveListByOwnerId(int ownerId,int isDelete){List<UserFile> fileList = new ArrayList<UserFile>();Connection conn = db.getConnection();PreparedStatement ps = null;ResultSet rs = null;UserFile userFile = null;String sql="select * from file where oldfilename in ( " +" select a.oldfilename from (select oldfilename,count(id) counts from file GROUP BY oldfilenameHAVING counts>1) a" +" ) andownerid=? and isDelete=?";ps = conn.prepareStatement(sql);ps.setInt(1, ownerId);ps.setInt(2, isDelete);rs = ps.executeQuery();while(rs.next()){userFile = new UserFile();userFile.setId(rs.getInt(1));userFile.setFilename(rs.getString(2));userFile.setPath(rs.getString(3));userFile.setCreateTime(rs.getTimestamp(4));userFile.setIsShared(rs.getInt(5));userFile.setOwnerId(rs.getInt(6));userFile.setFileSize(rs.getString(7));userFile.setCounts(rs.getInt(8));userFile.setSharedReason(rs.getString("SharedReason"));userFile.setSharedTime(rs.getString("SharedTime"));fileList.add(userFile);}return fileList;}4.平台会员充值
//前端jsp代码<body><div id="wrApper"><%@include file="common/nav.jsp" %><div id="page-wrapper"><div class=""><div class="col-md-12"><h1 class="margin-bottom-15">以下是微信付款码,扫码即可支付</h1><div class="form-group"><div class="col-md-12"><div class="control-wrapper"><div class="text-center" id="div1"><input type="submit" value=https://www.isolves.com/it/cxkf/yy/JAVA/2020-12-31/"扫码付款"class="btn btn-success">

${msgSuccess }${msgFail }
搭建Java共享网盘
//js实现,采用定时跳转模拟真实用户支付流程,后续进行改动用户会员状态var test1 = setTimeout(function(){$("#div1").css("display","none");$("#div2").css("display","block");layer.msg('恭喜您,完成扫码支付!', {time: 4000, icon:6},function () {window.location.href="user?action=doTopUp";});clearTimeout(test1);},5000);//后端代码public void doTopUp(User user) {Connection conn = db.getConnection();PreparedStatement ps = null;ResultSet rs = null;try {//members=1为会员状态ps = conn.prepareStatement("update user set members = 1 where id = ?");ps.setInt(1, user.getId());ps.execute();} catch (SQLException e) {e.printStackTrace();} finally {try {if (conn != null)conn.close();if (ps != null)ps.close();if (rs != null)rs.close();} catch (SQLException e) {e.printStackTrace();}}}
来源:https://www.tuicool.com/articles/iQVzY3U

【搭建Java共享网盘】


推荐阅读


上一篇:世界上含金量最高的奖项是什么?

下一篇:白茶是凉性的,什么茶是热性的