• Javaweb超市订单管理系统SMBMS


    SMBMS:登陆注销、用户管理、订单管理、供应商管理

    系统搭建流程

    1、建表:

    create table smbms.smbms_address
    (
        id           int default 0 not null
            primary key,
        contact      varchar(30)   null,
        addressDesc  varchar(50)   null,
        postCode     varchar(30)   null,
        tel          varchar(20)   null,
        createBy     varchar(50)   null,
        creationDate datetime      null,
        column_8     int           null,
        modifyBy     varchar(50)   null,
        modifyDate   datetime      null,
        userId       varchar(50)   null
    );
    
    create table smbms.smbms_bill
    (
        id           int default 0 not null
            primary key,
        billCode     int           null,
        productName  varchar(100)  null,
        productDesc  varchar(50)   null,
        productUnit  varchar(50)   null,
        productCount int(4)        null,
        totalPrice   double        null,
        isPayment    varchar(50)   null,
        createBy     varchar(50)   null,
        creationDate datetime      null,
        modifyBy     varchar(50)   null,
        modifyDate   datetime      null,
        provideId    int           null
    );
    
    create table smbms.smbms_provider
    (
        id           int default 0 not null
            primary key,
        proCode      varchar(30)   null,
        proName      varchar(50)   null,
        proDesc      varchar(50)   null,
        proContact   varchar(50)   null,
        proPhone     varchar(30)   null,
        prAddress    varchar(50)   null,
        proFax       varchar(50)   null,
        createBy     varchar(50)   null,
        creationDate datetime      null,
        modifyBy     varchar(50)   null,
        modifyDate   datetime      null
    );
    
    create table smbms.smbms_role
    (
        id           int default 0 not null
            primary key,
        roleCode     varchar(50)   null,
        roleName     varchar(50)   null,
        createdBy    varchar(50)   null,
        creationDate datetime      null,
        modifyBy     varchar(50)   null,
        modifyDate   datetime      null
    );
    
    create table smbms.smbms_user
    (
        id           int default 0 not null
            primary key,
        userCode     varchar(50)   null,
        userName     varchar(50)   null,
        userPassword varchar(50)   null,
        gender       int    null,
        birthday     datetime      null,
        phone        varchar(30)   null,
        address      varchar(40)   null,
        userRole     int 		   null,
        createdBy    int		   null,
        creationDate datetime      null,
        modifyBy     int 		   null,
        modifyDate   datetime      null
    );
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80

    2、建一个maven web项目
    3、配置tomcat
    3、测试项目能否正常启动
    4、导入项目用到的依赖包(servlet、mysql、)
    5、编写实体类(项目结构搭建好):ORM映射:表-类映射

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class Bill {
        private int id;
        private String billCode;
        private String productname;
        private String productDesc;
        private String productUnit;
        private int productCount;
        private double totalPrice;
        private String isPayment;
        private String createBy;
        private Date creationDate;
        private String modifyBy;
        private Date modifyDate;
        private Providerprovideid;
    }
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class Provider {
        private int id;
        private String proCode;
        private String proName;
        private String proDesc;
        private String proContact;
        private String phone;
        private String adress;
        private String proFax;
        private String createBy;
        private Date creationDate;
        private String modifyBy;
        private Date modifydate;
    }
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class Role {
        private int id;
        private String roleCode;
        private String roleName;
        private String createdBy;
        private Date creationDate;
        private String modifyBy;
        private Date modifyDate;
    }
    
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public class User implements Serializable {
       private int id;
    
        private String userCode;
    
        private String userName;
    
        private String userPassword;
    
        private int gender;
    
        private Date birthday;
    
        private String phone;
    
        private String address;
    
        private int userRole;
    
        private int createdBy;
    
        private Date creationDate;
    
        private int modifyBy;
    
        private Date modifyDate;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79

    6、配置db.properties文件

    driver=com.mysql.jdbc.Driver
    url=jdbc:mysql://localhost:3306?useUnicode=true&characterEncoding=utf-8
    username=root
    password=root
    
    • 1
    • 2
    • 3
    • 4

    7、编写数据库的公共类

    public class BaseDao {
    
        private static String driver;
        private static String url;
        private static String username;
        private static String password;
    
    //    静态代码块,类加载的时候就初始化
        static{
    //        通过类加载器读取对应的资源
        InputStream asStream = BaseDao.class.getClassLoader().getResourceAsStream("db.properties");
        Properties properties = new Properties();
        try {
            properties.load(asStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        driver = properties.getProperty("driver");
        url = properties.getProperty("url");
        username = properties.getProperty("username");
        password = properties.getProperty("password");
    }
    
    //  获取数据库的连接
        public static Connection getConnection(){
            Connection conn = null;
            try {
                Class.forName(driver);
                conn = DriverManager.getConnection(url,username,password);
            } catch (ClassNotFoundException | SQLException e) {
                e.printStackTrace();
            }
            return conn;
        }
    //      编写查询公共类
        public static ResultSet execute(Connection conn,String sql,Object[]params,ResultSet resultSet,PreparedStatement preparedStatement){
            try {
                preparedStatement = conn.prepareStatement(sql);
                for (int i = 0; i < params.length; i++) {
                    preparedStatement.setObject(i+1,params[i]);
                }
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            try {
                resultSet = preparedStatement.executeQuery(sql);
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
            return resultSet;
        }
    //    编写增删改公共方法
    public static int execute(Connection conn,String sql,Object[]params,PreparedStatement preparedStatement){
        try {
            preparedStatement = conn.prepareStatement(sql);
            for (int i = 0; i < params.length; i++) {
                preparedStatement.setObject(i+1,params[i]);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        int updateRows = 0;
        try {
            updateRows = preparedStatement.executeUpdate(sql);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return updateRows;
    }
    //释放资源
        public static boolean releaseResource(Connection conn,PreparedStatement preparedStatement,ResultSet resultSet){
            Boolean flag = true;
            if (resultSet!=null){
                try {
                    resultSet.close();
    //                GC回收
                    resultSet = null;
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                    flag = false;
                }
            }
            if (preparedStatement!=null){
                try {
                    preparedStatement.close();
                    preparedStatement = null;
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                    flag = false;
                }
            }
            if (conn!=null){
                try {
                    conn.close();
                    conn=null;
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                    flag = false;
                }
            }
            return flag;
        }
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 编写字符编码过滤器
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=UTF-8");
    
            filterChain.doFilter(request,response);
    
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
      <!--    字符编码过滤器-->
        <filter>
            <filter-name>CharacterEncodingFilter</filter-name>
            <filter-class>atu.wanaei.filter.CharacterEncodingFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>CharacterEncodingFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    8、导入静态资源
    导入路径上传到了gitee上
    在这里插入图片描述
    准备工作到此完成,之后开始实现登录功能,有兴趣的去代码中看

  • 相关阅读:
    传奇M数据目录
    JVM性能优化 —— 类加载器,手动实现类的热加载
    加密密钥应用范围及特点优势分析
    https
    能不能绕过c去学c++?
    「Verilog学习笔记」含有无关项的序列检测
    mmdetection常见报错以及解决方案汇总
    Linux系统文件属性
    在 Clojure 中,如何实现高效的并发编程以处理大规模数据处理任务?
    [NLP]LLM---大模型指令微调中的“Prompt”
  • 原文地址:https://blog.csdn.net/A_Tu_daddy/article/details/125423912