基于SpringBoot的Java电子商城源码开源项目介绍

需积分: 32 5 下载量 32 浏览量 更新于2024-11-09 5 收藏 4.3MB ZIP 举报
资源摘要信息: "java版商城源码下载-BookStore:SpringBoot,书店" 知识点详细说明: 1. **项目技术栈分析**: - **SpringBoot**:本项目使用了SpringBoot框架,这是一个流行的Java框架,用于简化新Spring应用的初始搭建以及开发过程。SpringBoot能够快速启动并运行项目,并且简化了项目配置。 - **前后端分离架构**:使用了Vue和layui作为前端框架,提供了用户友好的界面和交互式体验。Vue是当前前端开发的热门框架,它易于上手并且具有良好的扩展性;layui是一个前端UI框架,主要面向后端开发者,使得前端页面开发更加简单高效。 - **MyBatis**:作为持久层框架,MyBatis是一个半ORM(对象关系映射)框架,它提供了对象与数据库之间的映射机制。 2. **系统功能要求**: - **前台用户功能**:系统要求能够实现用户注册、登录、注销功能,同时非注册用户也能够浏览商品和商品分类,支持名称搜索和价格区间搜索功能。注册用户还可以进行购物车操作和订单生成等。 - **后台管理员功能**:后台需要能够对商品类别信息、商品信息、用户信息进行管理,包括查询、插入、更新、删除等操作。 - **界面设计**:系统界面要求简洁美观,操作简单便捷。 3. **系统安装和部署**: - **软件获取**:源码可以在github或者码云上获取,这提供了开源代码的分享和协作平台,方便开发者查看历史版本和进行团队协作。 - **软件安装**:提供了Linux服务器的安装方法,并且提到可以在本地或者云服务器上进行部署,这表明了项目的可移植性和扩展性。 4. **设计报告文档**: - 文档需要详细描述系统需求分析、功能模块设计、数据库设计、系统公用类与接口的设计、核心配置文件以及系统界面截图。这要求开发者在项目初期就要有周密的规划和文档记录,对项目开发具有重要的指导意义。 5. **其他知识点**: - 本项目可能还涉及到服务器配置、网络安全、数据库管理等技术细节。 - 针对项目运行的服务器端口有特别提及,说明需要进行端口配置和管理。 6. **系统开源**: - 标签"系统开源"意味着该项目的源码是开放的,这有利于其他开发者学习和使用代码,同时也可以通过社区贡献代码进行功能完善和优化。 7. **文件名称分析**: - "BookStore-master"可能是该项目的GitHub仓库名称,表明这是一个主分支(master),通常包含着项目当前的稳定版本。 总结以上,"java版商城源码下载-BookStore:SpringBoot,书店"是一个基于SpringBoot构建的Java EE电子商城项目,采用前后端分离的开发模式,强调系统功能的完整性与界面的美观性,并对安装部署和文档编制提出了明确要求。该项目的开源性质进一步鼓励了业界的交流与合作,有利于推动技术的进步和应用的创新。
2011-04-05 上传
package user; import java.sql.*; import java.util.*; import java.util.Date; import java.sql.PreparedStatement; import com.ConnDB; import java.sql.*; import java.util.*; import com.ConnDB; public class UserDB extends ConnDB{ private ArrayList user; public UserDB () throws Exception { } public boolean userExist(String username){ boolean occupied=true; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "select userid from Buser where username=?"); preparedStatement.setString (1, username); ResultSet resultSet = preparedStatement.executeQuery (); if(!resultSet.next()) occupied=false; preparedStatement.close (); ConnDB.terminate(); } catch(SQLException e){ e.printStackTrace(); ConnDB.terminate(); } return occupied; } public boolean isValidUser (String username, String password) { boolean isValid=false; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT username, password FROM Buser WHERE username=? and password=?"); preparedStatement.setString (1, username); preparedStatement.setString (2, password); ResultSet resultSet = preparedStatement.executeQuery (); if (resultSet.next ()) { isValid=true; preparedStatement.close (); ConnDB.terminate(); } else { preparedStatement.close (); ConnDB.terminate(); //return isValid; } } catch (SQLException e) { ConnDB.terminate(); //return isValid; } return isValid; } public boolean find(String key) { boolean gotIt=false; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT username, password FROM Buser WHERE username = ?"); preparedStatement.setString (1, key); ResultSet resultSet = preparedStatement.executeQuery (); if (resultSet.next ()) { gotIt=true; preparedStatement.close (); ConnDB.terminate(); } else { preparedStatement.close (); ConnDB.terminate(); //return isValid; } } catch (SQLException e) { ConnDB.terminate(); //return gotIt; } return gotIt; } public User getUser (int id) { try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT userid, username, rname, password, email, address, postdate, tel " + "FROM Buser WHERE userId = ?"); preparedStatement.setInt (1, id); ResultSet resultSet = preparedStatement.executeQuery (); if (resultSet.next ()) { User users = new User ( resultSet.getInt (1), resultSet.getString (2), resultSet.getString (3), resultSet.getString (4), resultSet.getString (5), resultSet.getString (6), resultSet.getString (7), resultSet.getString (8) ); preparedStatement.close (); ConnDB.terminate(); return users; } else { preparedStatement.close (); ConnDB.terminate(); return null; } } catch (SQLException e) { ConnDB.terminate(); return null; } } public User getUser (String username) { try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT userid, username, rname, password, email, address, postdate, tel " + "FROM Buser WHERE username = ?"); preparedStatement.setString (1, username); ResultSet resultSet = preparedStatement.executeQuery (); if (resultSet.next ()) { User users = new User ( resultSet.getInt (1), resultSet.getString (2), resultSet.getString (3), resultSet.getString (4), resultSet.getString (5), resultSet.getString (6), resultSet.getString (7), resultSet.getString (8) ); preparedStatement.close (); ConnDB.terminate(); return users; } else { preparedStatement.close (); ConnDB.terminate(); return null; } } catch (SQLException e) { ConnDB.terminate(); return null; } } public int addUsers (User users) { System.out.println("**"); int rowsAffected = 0; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "INSERT INTO Buser (username, rname, password, email, address, postdate, tel) " + "VALUES (?, ?, ?, ?, ?, ?, ?)"); preparedStatement.setString (1, users.getUsername ()); preparedStatement.setString (2, users.getRname ()); preparedStatement.setString (3, users.getPassword()); preparedStatement.setString (4, users.getEmail()); preparedStatement.setString (5, users.getAddress()); preparedStatement.setString (6, users.getPostdate()); preparedStatement.setString (7, users.getTel()); //判断是否重复添加 if(find(users.getUsername ())){ rowsAffected =2; System.out.println("exist username"); } else{ rowsAffected = preparedStatement.executeUpdate (); System.out.println(rowsAffected + "add"); } preparedStatement.close (); ConnDB.terminate(); } catch (SQLException e) { ConnDB.terminate(); return 0; } return rowsAffected; } public int deleteUser (int id) { int rowsAffected = 0; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ("DELETE FROM Buser WHERE userid = ?"); preparedStatement.setInt (1, id); rowsAffected = preparedStatement.executeUpdate (); preparedStatement.close (); ConnDB.terminate(); } catch (SQLException e) { ConnDB.terminate(); return 0; } return rowsAffected; } public int modifyUser (User users) { int rowsAffected = 0; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "UPDATE Buser SET username=?, rname=?, password=?, email=?, address=?, postdate=?, tel=? " + "WHERE userid =?"); preparedStatement.setString (1, users.getUsername ()); preparedStatement.setString (2, users.getRname ()); preparedStatement.setString (3, users.getPassword()); preparedStatement.setString (4, users.getEmail()); preparedStatement.setString (5, users.getAddress()); preparedStatement.setString (6, users.getPostdate()); preparedStatement.setString (7, users.getTel()); preparedStatement.setInt (8, users.getId ()); rowsAffected = preparedStatement.executeUpdate (); preparedStatement.close (); ConnDB.terminate(); } catch (SQLException e) { ConnDB.terminate(); return 0; } return rowsAffected; } public Collection getUser () { user = new ArrayList (); try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT userid, username, rname, password, email, address, postdate, tel " + "FROM Buser"); ResultSet resultSet = preparedStatement.executeQuery (); while (resultSet.next ()) { User users = new User ( resultSet.getInt (1), resultSet.getString (2), resultSet.getString (3), resultSet.getString (4), resultSet.getString (5), resultSet.getString (6), resultSet.getString (7), resultSet.getString (8) ); user.add(users); } preparedStatement.close (); } catch (SQLException e) { return null; } ConnDB.terminate(); //Collections.sort(user); return user; } public boolean isModify(String key,int id) { boolean modifyIt=false; try { ConnDB.initialize(); // create database connection PreparedStatement preparedStatement = conn.prepareStatement ( "SELECT userid FROM Buser WHERE username = ? and userd <> ?"); preparedStatement.setString (1, key); preparedStatement.setInt (2, id); ResultSet resultSet = preparedStatement.executeQuery (); if (resultSet.next ()) { modifyIt=true; preparedStatement.close (); ConnDB.terminate(); } else { preparedStatement.close (); ConnDB.terminate(); //return isValid; } } catch (SQLException e) { ConnDB.terminate(); //return gotIt; } return modifyIt; } }