基于Spring+SpringMvc+Hibernate的咔咔发廊管理系统

基于Spring+SpringMvc+Hibernate的咔咔发廊管理系统

基于Spring+SpringMvc+Hibernate的家政服务网-java家政服务网
1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善

代码已经上传github,下载地址 https://github.com/21503882/hair-mag
开发环境:
Eclipse ,MYSQL,JDK1.7,Tomcat 7
涉及技术点:
MVC模式、springMvc、Hibernate、Spring、HTML、JavaScript、CSS、JQUERY、poi、jpa、Ajax等
系统采用Hibernate框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.7. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离;
主要功能:

 

 

系统在两个模块的基础上每一个模块又分为几个模块。
1.前台系统功能模块分为
(1)产品展台模块:通过新品上架,分页显示特价产品,产品销售排行展示网站的所有产品;
(2)产品查询模块:按产品的类别查询产品的相关信息;
(3)购物车模块:用户添加产品至购物车,查看购物车中的产品,从购物车中移除不满意的产品,清空购物车中的产品,修改所要购买的产品的数量;
(4)收银台模块:用户满意购物车中的产品后进行结账并填写订单信息;
(5)用户维护模块:为用户提供了用户注册、用户登录、用户资料修改以及找回密码的功能;
(6)订单查询模块:用户通过查看订单能够了解到自己的当前订单信息及历史订单记录;
(7)公告浏览模块:用户通过浏览公告信息,能够及时了解到网站最新的各种信息。
(8)留言模块:客户可以进行留言给我们提意见,我们在不断地改进中前进。
 

2.后台管理员子系统功能模块分为
(1)产品管理模块:按类别查看产品,对产品的信息进行维护;
(2)用户管理模块:为了保护用户的信息,此模块与前台用户维护的区别是管理员只能查看用户信息和删除操作;
(3)管理员维护模块:这是对管理员的信息进行维护,可以修改管理员的信息。
(4)业务员维护模块:这是对业务员的信息进行维护,管理员可以添加或删除业务员的信息。
(5)订单管理模块:管理员查询订单,查看订单详细信息,删除订单信息,进行订单受理;
(6)公告管理模块:管理员公告浏览,公告信息维护;
(7)留言模块:管理员可以查看客户的留言,对留言进行维护。

package com.yeyunlin.dao;
 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.yeyunlin.info.FoodInfo;
import com.yeyunlin.info.OrderInfo;
import com.yeyunlin.info.ReviewInfo;
import com.yeyunlin.info.UserInfo;
import com.yeyunlin.util.DBUtil;
import com.yeyunlin.util.Tools;
 
public class Dao {
    public static boolean checkPassword(String name, String password) {
        String sql = " select * from managers where name = ? and password = ?";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setString(1, name);
            preparedStatement.setString(2, password);
            ResultSet resultSet = preparedStatement.executeQuery();
            return resultSet.next();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return false;
    }
 
    public static List<UserInfo> getAllUsers() {
        List<UserInfo> userInfos = new ArrayList<UserInfo>();
        String sql;
        sql = " select * from users";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                UserInfo userInfo = new UserInfo();
                userInfo.setName(resultSet.getString(1));
                userInfo.setAccount(resultSet.getString(2));
                userInfo.setPassword(resultSet.getString(3));
                userInfo.setIntegral(resultSet.getInt(4));
                userInfo.setIcon(resultSet.getString(5));
                userInfos.add(userInfo);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return userInfos;
    }
 
    public static List<OrderInfo> getAllOrder(String name) {
        List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
        String sql;
        if (name.equals("")) {
            sql = " select * from foodorder";
        } else {
            sql = " select * from foodorder where user_name = '" + name + "' ";
        }
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                OrderInfo orderInfo = new OrderInfo();
                orderInfo.setOrderId(resultSet.getString(1));
                orderInfo.setUsername(resultSet.getString(2));
                orderInfo.setFoodid(resultSet.getInt(3));
                orderInfo.setDeskid(resultSet.getInt(4));
                orderInfo.setTime(resultSet.getString(5));
                orderInfo.setPaytype(resultSet.getString(6));
                orderInfos.add(orderInfo);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return orderInfos;
    }
 
    public static List<OrderInfo> getUnpayOrder() {
        List<OrderInfo> orderInfos = new ArrayList<OrderInfo>();
        String sql;
        sql = " select * from foodorder where paytype = ? ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setString(1, "0");
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                OrderInfo orderInfo = new OrderInfo();
                orderInfo.setOrderId(resultSet.getString(1));
                orderInfo.setUsername(resultSet.getString(2));
                orderInfo.setFoodid(resultSet.getInt(3));
                orderInfo.setDeskid(resultSet.getInt(4));
                orderInfo.setTime(resultSet.getString(5));
                orderInfo.setPaytype(resultSet.getString(6));
                orderInfos.add(orderInfo);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return orderInfos;
    }
 
    public static String getFoodName(int number) {
        String sql;
        sql = " select name from food where number = ?";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setInt(1, number);
            ResultSet resultSet = preparedStatement.executeQuery();
            if (resultSet.next()) {
                return resultSet.getString(1);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return null;
    }
 
    public static List<FoodInfo> getFoods(String type) {
        List<FoodInfo> foodInfos = new ArrayList<FoodInfo>();
        String sql;
        sql = " select * from food where type = ?";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setString(1, type);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                FoodInfo foodInfo = new FoodInfo();
                foodInfo.setNumber(resultSet.getInt(1));
                foodInfo.setName(resultSet.getString(2));
                foodInfo.setPrice(resultSet.getInt(3));
                foodInfo.setType(resultSet.getString(4));
                foodInfo.setIcon(resultSet.getString(5));
                foodInfo.setDescription(resultSet.getString(6));
                foodInfos.add(foodInfo);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return foodInfos;
    }
 
    public static boolean isFoodHave(int number) {
        String sql;
        sql = " select name from food where number = ?";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setInt(1, number);
            ResultSet resultSet = preparedStatement.executeQuery();
            return resultSet.next();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return false;
    }
 
    public static void insertFood(int number, String name, int price,
            String type, String icon, String description) {
        String sql = " insert into food(number , name , price , type , icon , description )values(?,?,?,?,?,?) ";
        DBUtil util = new DBUtil();
        Connection conn = util.openConn();
        try {
            PreparedStatement preparedStatement = conn.prepareStatement(sql);
 
            preparedStatement.setInt(1, number);
            preparedStatement.setString(2, name);
            preparedStatement.setInt(3, price);
            preparedStatement.setString(4, type);
            preparedStatement.setString(5, icon);
            preparedStatement.setString(6, description);
 
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            util.closeConn(conn);
        }
    }
 
    public static List<ReviewInfo> getReviews() {
        List<ReviewInfo> reviewInfos = new ArrayList<ReviewInfo>();
        String sql;
        sql = " select * from reviews";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                ReviewInfo reviewInfo = new ReviewInfo();
                reviewInfo.setName(resultSet.getString(1));
                reviewInfo.setContent(resultSet.getString(2));
                reviewInfo.setTime(resultSet.getString(3));
                reviewInfos.add(reviewInfo);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return reviewInfos;
    }
 
    public static void addReview(String name, String content, String time) {
        String sql = " insert into reviews(name, content, time)values(?,?,?) ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setString(1, name);
            preparedStatement.setString(2, content);
            preparedStatement.setString(3, time);
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
    }
 
    public static Map getAllFoodId() {
        String sql;
        sql = " select food_id from foodorder";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            ResultSet resultSet = preparedStatement.executeQuery();
            Map foodIdMap = new HashMap();
            while (resultSet.next()) {
                int foodId = resultSet.getInt(1);
                if (foodIdMap.containsKey(foodId)) {
                    int value = (int) foodIdMap.get(foodId);
                    foodIdMap.put(foodId, value + 1);
                } else {
                    foodIdMap.put(foodId, 1);
                }
            }
            return foodIdMap;
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return null;
    }
 
    public static Map getOrderesFoodId(String name) {
        String sql;
        sql = " select food_id from foodorder where user_name = ?";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setString(1, name);
            ResultSet resultSet = preparedStatement.executeQuery();
            Map foodIdMap = new HashMap();
            while (resultSet.next()) {
                int foodId = resultSet.getInt(1);
                if (foodIdMap.containsKey(foodId)) {
                    int value = (int) foodIdMap.get(foodId);
                    foodIdMap.put(foodId, value + 1);
                } else {
                    foodIdMap.put(foodId, 1);
                }
            }
            return foodIdMap;
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return null;
    }
 
    public static void deleteAllInteresting() {
        String sql = " delete from allinteresting ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
    }
    
    public static void insertInteresting(int[] array){
        String sql = " insert into allinteresting(food_id)values(?) ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            connection.setAutoCommit(false);
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            int i = 0;
            while (i < Tools.ALL_INTERESTING_NUMBER) {
                preparedStatement.setInt(1, array[i]);
                preparedStatement.addBatch();
                i++;
            }
            preparedStatement.executeBatch();
            connection.commit();
            preparedStatement.clearBatch();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
    }
    
    public static void insertUserInteresting(String name , int[] array){
        String sql = " insert into userinteresting(user_name, food_id)values(?, ?) ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            connection.setAutoCommit(false);
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            int i = 0;
            while (i < Tools.USER_INTERESTING_NUMBER) {
                preparedStatement.setString(1, name);
                preparedStatement.setInt(2, array[i]);
                preparedStatement.addBatch();
                i++;
            }
            preparedStatement.executeBatch();
            connection.commit();
            preparedStatement.clearBatch();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
    }
    
    public static List<String> getSimilarName(int foodId){
        List<String> userNames = new ArrayList<String>();
        String sql = " select user_name from userinteresting where food_id = ? ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setInt(1, foodId);
            ResultSet resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                String name = resultSet.getString(1);
                userNames.add(name);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
        return userNames;
    }
    
    public static void addRecommemdFood(int id) {
        String sql = " insert into recommemd(food_id)values(?) ";
        DBUtil dbUtil = new DBUtil();
        Connection connection = dbUtil.openConn();
        try {
            PreparedStatement preparedStatement = connection
                    .prepareStatement(sql);
            preparedStatement.setInt(1, id);
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            dbUtil.closeConn(connection);
        }
    }
}
代码已经上传github,下载地址 https://github.com/21503882/hair-mag
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值