Home > Java > javaTutorial > body text

Share an example tutorial of the Yimai.com project

零下一度
Release: 2017-06-25 13:30:59
Original
18392 people have browsed it

                                                                                                                                                                                                                             

0.Development process:

1.Project agreement:

6 groups:

Group project name: EasyBuy_flc or (EasyBuy_01)

Team database name: EasyBuy_flc

Version control tool: svn, no longer used

In the future, you can upload your own group's projects to git

Development process control:

Team leader: Change all html pages to jsp suffix, and then establish the database and data table

ATeam members: Design database, write Chinese field names of data tables

BTeam members: Design entity classes

##Project development steps

1.

Database design

easybuy_user (user table)

Table1

EU_USER_ID

varchar Username

EU_USER_NAME

varchar Real name

EU_PASSWORD

varchar Password

EU_SEX

varchar        Gender (T, F)

EU_BIRTHDAY date      Date of birth

EU_IDENTITY_CODE

varchar ID card

EU_EMAIL

varchar             E-mail

====================== ======================================

easybuy_product_category (

Product Category Table) Table2

EPC_ID                 

Category Number

EPC_NAME                                                                                                                            ================================

easybuy_product(Product list)

Table

3

EP_ID

Product number

EP_NAME Product name

EP_DESCRIPTION

Product description

EP_PRICE Product price

EP_STOCK Product inventory

EPC_ID The parent category number of the category to which the current product belongs

EPC_CHILD_ID Category to which the current product belongs

EP_FILE_NAME Product image name

##========== ==================================================

easybuy_order

(Order form) Table4

EO_ID                  

Order number

# EO_USER_ID Order's user

## EO_USER_NAME

所 (real name)

EO_USER_ADDRESS

Order shipping address

EO_CREATE_TIME

Order formation time

EO_COST                    

Amount of this order

EO_STATUS                                                                                                                                    

EO_TYPE                      Order type

(This project is not enabled)

##================== ====================================

easybuy_order_detail

(Order details table) Table

5

EOD_ID Order details number

EO_ID             

Order Number

EP_ID                                                              #Quantity of goods

EOD_COST                                                                                                                   =============================================

easybuy_news

(News table)

EN_TITLE

News Title

EN_CONTENT News content

EN_CREATE_TIME News release time

======= ============================================

easybuy_comment (comment form) Table 7

EC_ID               Comment number

EC_CONTENT Comment content

EC_CREATE_TIME Comment creation time

EC_REPLY Comment reply

EC_REPLY_TIME Comment reply time

EC_NICK_NAME Commenter

================================================ ===============

2.Building the project structure

2.1Start from the entity layer

EntityThe layer code is as follows:

User userClass:

Product_category Product category:

##Product product information table:

Order order table:

Order_detail order details table:

News information table:

User_address Address Class:

Count Class:

Get started Item: 1:

My login:

The functions are: verification, verification code, successful login page jump.

Start layering:

Tool BaseDao:

package cn.com.dao;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import javax.naming.Context;import javax.naming.InitialContext;import javax.sql.DataSource;public class BaseDAO {public static final String driver = "com.mysql.jdbc.Driver";public static final String url = "jdbc:mysql://localhost:3306/easybuy?useUnicode=true&charaterEncoding=UTF-8";public static final String username = "root";public static final String pwd = "1234";public Connection con=null;public PreparedStatement ps=null;public ResultSet rs=null;    //获取连接getConnectionpublic Connection getConnection() throws Exception {//加载驱动        Class.forName(driver);if (con == null || con.isClosed()) {
            con = DriverManager.getConnection(url, username, pwd);
        }return con;
    }//查询 executeQuerypublic ResultSet executeQuery(String sql, Object...objects) throws Exception {
        con = getConnection();
        ps = con.prepareStatement(sql);for (int i = 0; i < objects.length; i++) {
            ps.setObject(i + 1, objects[i]);
        }
        rs = ps.executeQuery();return rs;
    }//增、删、改public int executeUpudate(String sql, Object... objects) throws Exception {
        con = getConnection();
        ps = con.prepareStatement(sql);for (int i = 0; i < objects.length; i++) {
            ps.setObject(i + 1, objects[i]);
        }int num = ps.executeUpdate();        return num;
    }public void closeAll() throws Exception {if (rs != null || !rs.isClosed()) {
            rs.close();
        }if (ps != null || !ps.isClosed()) {
            ps.close();
        }if (con != null || !con.isClosed()) {
            con.close();
        }
    }
}
Copy after login
dao layer:

   select(String name,String pwd)  Exception;

}
Copy after login
dao's Implementation layer:

  UserDaoImpl  BaseDAO   select(String name,String pwd) ="select count(1) from easybuy_user where loginname=? and loginname=?"=(rs!==rs.getInt("id"
Copy after login
services layer:

   select(String name,String pwd)
Copy after login
services implementation layer:

aab741e2726b40359edf6b2d10e3c6c8

我的重难点:

难点1: 在浏览中cookie的存取。 问题描述: 当用户浏览商品时将该用或浏览的当前商品id放入cookie中在”最近浏览“中显示用户浏览过的商品信息 难点:cookie中存放有SessionId如何区分SessionId和商品id? 解决方案: 在将商品id放入cookie中是将cookie的key值和value值设置为相同的值也就是商品的id(cookie中存放Sessionid的cookie的key值和value值不一样),然后在遍历cookie时对比其key值和value值是否相等(相等即商品id不相等则不是商品)

难点2: 百度富文本编辑器中图片上传的配置 问题描述: 使用百度的文本富文本编辑器是传图片后不能在页面上显示 解决方案: 在ueditor的jsp文件夹下的config.json文件中配置正确的上传路径和访问访问路径。 imagePathFormat:图片上传后保存的路径相对于网站的根目录 imageUrlPrefix:图片的访问路径前缀相对于当前页面路径,其访问路径为imagerurlPrefix+imagePathFormat

难点3: 商品分类信息的层级显示: 问题描述: 商品分类中存在父级分类和子分类。如何显示 解决方案: 分别查询出父级分类和子级分类类在遍历父级分类时遍历子级分类找出该父级分类的子分类进行显示 复制代码如下:

商品分类

       
           
            //遍历父级分类            
${pitem.EPC_NAME }
//显示父分类             //遍历子级分类                                    
${citem.EPC_NAME }
           
           
        
                                           
       

难点4:

使用过滤器实现权限控制 问题描述: 如何区分哪些页面需要验证权限 解决方案: 将需要验证权限的页面设置统一格式的路径在Filter中使用正则表达式筛选出取药进行权限验证的页面进行权限验证,

 

自在人与人

 

The above is the detailed content of Share an example tutorial of the Yimai.com project. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template