`

JavaWeb之网上书城案例

 
阅读更多

 

功能分析

 



  

 

总体架构

 



 

 

MVC 设计模式:

Model:POJO(Plain Old Java Object) 

Controller:Servlet

View:JSP + EL + JSTL

 

技术选型

 

数据库:MySQL

数据源:C3P0 

JDBC 工具:DBUtils

事务解决方案:Filter + ThreadLocal

Ajax 解决方案:jQuery + JavaScript + JSON + google-gson

层之间解耦方案:工厂设计模式

 

难点分析

 

通用的分页解决方案

带查询条件的分页

使用 Filter + ThreadLocal 解决事务

 

实体类设计

 



  

 

数据表设计

 

drop database db_bookstore;
create database db_bookstore;
use db_bookstore;

drop table if exists t_account;
create table t_account
(
    id int(11) auto_increment,
    balance float default 0 not null,
    primary key (id)
);

drop table if exists t_user;
create table t_user
(
    id int(11) primary key auto_increment,
    username varchar(50) not null,
    password varchar(200) not null,
    accountid int(11) not null,
    constraint account_id_fk foreign key (accountid) references t_account(id)
);

drop table if exists t_book;
create table t_book
(
    id int(11) primary key auto_increment,
    title varchar(200) not null,
    author varchar(100) not null,
    price float not null,
    publisher varchar(100),
    publishdate date not null,
    salesamount int(11) not null,
    storeamount int(11) not null,
    description text
);

drop table if exists t_trade;
create table t_trade
(
    id int(11) primary key auto_increment,
    userid int(11) references t_user(id),
    tradetime datetime not null
);

drop table if exists t_tradeitem;
create table t_tradeitem
(
    id int(11) auto_increment,
    bookid int(11) not null,
    quantity int(11) not null,
    tradeid int(11) not null,
    primary key(id),
    key book_id_fk (bookid),
    key trade_id_fk(tradeid),
    constraint book_id_fk foreign key (bookid) references t_book(id),
    constraint trade_id_fk foreign key (tradeid) references t_trade(id)
);

 

 

 

 

 

 



 

 

 

 

 

 

 

 

 

 

 

 

  • 大小: 18.3 KB
  • 大小: 5.3 KB
  • 大小: 5.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics