07.订单操作
08.用户操作
09.权限控制
10.权限关联与控制
11.AOP日志
07.订单操作
SSM订单操作
表结构分析
productId描述了订单与产品之间的关系。
memberid描述了订单与会员之间的关系。创建表sql
-- 订单 drop table orders; CREATE TABLE orders( id varchar2(32) default SYS_GUID() PRIMARY KEY, orderNum VARCHAR2(20) NOT NULL UNIQUE, orderTime timestamp, peopleCount INT, orderDesc VARCHAR2(500), payType INT, orderStatus INT, productId varchar2(32), memberId varchar2(32), FOREIGN KEY (productId) REFERENCES product(id), FOREIGN KEY (memberId) REFERENCES member(id) ) insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘0E7231DC797C486290E8713CA3C6ECCC‘, ‘12345‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘676C5BD1D35E429A8C2E114939C5685A‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘5DC6A48DD4E94592AE904930EA866AFA‘, ‘54321‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘676C5BD1D35E429A8C2E114939C5685A‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘2FF351C4AC744E2092DCF08CFD314420‘, ‘67890‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘12B7ABF2A4C544568B0A7C69F36BF8B7‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘A0657832D93E4B10AE88A2D4B70B1A28‘, ‘98765‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘12B7ABF2A4C544568B0A7C69F36BF8B7‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘E4DD4C45EED84870ABA83574A801083E‘, ‘11111‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘12B7ABF2A4C544568B0A7C69F36BF8B7‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘96CC8BD43C734CC2ACBFF09501B4DD5D‘, ‘22222‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘12B7ABF2A4C544568B0A7C69F36BF8B7‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘55F9AF582D5A4DB28FB4EC3199385762‘, ‘33333‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘9F71F01CB448476DAFB309AA6DF9497F‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘CA005CF1BE3C4EF68F88ABC7DF30E976‘, ‘44444‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘9F71F01CB448476DAFB309AA6DF9497F‘, ‘E61D65F673D54F68B0861025C69773DB‘); insert into ORDERS (id, ordernum, ordertime, peoplecount, orderdesc, paytype, orderstatus, productid, memberid) values (‘3081770BC3984EF092D9E99760FDABDE‘, ‘55555‘, to_timestamp(‘02-03-2018 12:00:00.000000‘, ‘dd-mm-yyyy hh24:mi:ss.ff‘), 2, ‘没什么‘, 0, 1, ‘9F71F01CB448476DAFB309AA6DF9497F‘, ‘E61D65F673D54F68B0861025C69773DB‘);
创建表sql
-- 会员 drop table member; CREATE TABLE member( id varchar2(32) default SYS_GUID() PRIMARY KEY, NAME VARCHAR2(20), nickname VARCHAR2(20), phoneNum VARCHAR2(20), email VARCHAR2(20) ); insert into MEMBER (id, name, nickname, phonenum, email) values (‘E61D65F673D54F68B0861025C69773DB‘, ‘张三‘, ‘小三‘, ‘18888888888‘, ‘[email protected]‘);
创建表sql
-- 旅客 drop table traveller; CREATE TABLE traveller( id varchar2(32) default SYS_GUID() PRIMARY KEY, NAME VARCHAR2(20), sex VARCHAR2(20), phoneNum VARCHAR2(20), credentialsType INT, credentialsNum VARCHAR2(50), travellerType INT ) insert into TRAVELLER (id, name, sex, phonenum, credentialstype, credentialsnum, travellertype) values (‘3FE27DF2A4E44A6DBC5D0FE4651D3D3E‘, ‘张龙‘, ‘男‘, ‘13333333333‘, 0, ‘123456789009876543‘, 0); insert into TRAVELLER (id, name, sex, phonenum, credentialstype, credentialsnum, travellertype) values (‘EE7A71FB6945483FBF91543DBE851960‘, ‘张小龙‘, ‘男‘, ‘15555555555‘, 0, ‘987654321123456789‘, 1);
旅客与订单之间是多对多关系,所以我们需要一张中间表(order_traveller)来描述。
创建表sql
-- 订单与旅客中间表 drop table order_traveller; CREATE TABLE order_traveller( orderId varchar2(32), travellerId varchar2(32), PRIMARY KEY (orderId,travellerId), FOREIGN KEY (orderId) REFERENCES orders(id), FOREIGN KEY (travellerId) REFERENCES traveller(id) ) insert into ORDER_TRAVELLER (orderid, travellerid) values (‘0E7231DC797C486290E8713CA3C6ECCC‘, ‘3FE27DF2A4E44A6DBC5D0FE4651D3D3E‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘2FF351C4AC744E2092DCF08CFD314420‘, ‘3FE27DF2A4E44A6DBC5D0FE4651D3D3E‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘3081770BC3984EF092D9E99760FDABDE‘, ‘EE7A71FB6945483FBF91543DBE851960‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘55F9AF582D5A4DB28FB4EC3199385762‘, ‘EE7A71FB6945483FBF91543DBE851960‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘5DC6A48DD4E94592AE904930EA866AFA‘, ‘3FE27DF2A4E44A6DBC5D0FE4651D3D3E‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘96CC8BD43C734CC2ACBFF09501B4DD5D‘, ‘EE7A71FB6945483FBF91543DBE851960‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘A0657832D93E4B10AE88A2D4B70B1A28‘, ‘3FE27DF2A4E44A6DBC5D0FE4651D3D3E‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘CA005CF1BE3C4EF68F88ABC7DF30E976‘, ‘EE7A71FB6945483FBF91543DBE851960‘); insert into ORDER_TRAVELLER (orderid, travellerid) values (‘E4DD4C45EED84870ABA83574A801083E‘, ‘EE7A71FB6945483FBF91543DBE851960‘);
1.订单操作-查询所有订单流程分析
2.订单操作-查询所有订单代码实现1
在数据库中创建完所需的TABLE并且insert into 必要的数据后,我们就要写DAO层的实体类。
多与多对应关系的中间表没有实体类。
在子模块heima_ssm_domain下创建以下的3个实体类:
Orders
Member
Traveller
在子模块heima_ssm_web下创建控制类OrdersController
在子模块heima_ssm_service下创建接口和实现类 IOrdersService 和 OrdersServiceImpl
在子模块heima_ssm_dao下创建 IOrdersDao接口类供mybatis框架基于注解写sql语句
3.订单操作-查询所有订单代码实现2
DAO层的接口上在 @Select注解的下一行有必要声明查询的主键。
注解@Results ,使用这个注解来实现属性映射对应关系。
==================
end
原文地址:https://www.cnblogs.com/MarlonKang/p/11565797.html
时间: 2024-10-10 02:15:09