-- 先创建库
-- 再使用库
USE oa;
CREATE TABLE claim_voucher
(
id INT NOT NULL AUTO_INCREMENT,
cause VARCHAR(100),
create_sn CHAR(5),
create_time DATETIME,
next_deal_sn CHAR(5),
total_amount DOUBLE,
STATUS VARCHAR(20),
PRIMARY KEY (id)
);
/*==============================================================*/
/* Table: claim_voucher_item */
/*==============================================================*/
CREATE TABLE claim_voucher_item
(
id INT NOT NULL AUTO_INCREMENT,
claim_voucher_id INT,
item VARCHAR(20),
amount DOUBLE,
COMMENT VARCHAR(100),
PRIMARY KEY (id)
);
/*==============================================================*/
/* Table: deal_record */
/*==============================================================*/
CREATE TABLE deal_record
(
id INT NOT NULL AUTO_INCREMENT,
claim_voucher_id INT,
deal_sn CHAR(5),
deal_time DATETIME,
deal_way VARCHAR(20),
deal_result VARCHAR(20),
COMMENT VARCHAR(100),
PRIMARY KEY (id)
);
/*==============================================================*/
/* Table: department */
/*==============================================================*/
CREATE TABLE department
(
sn CHAR(5) NOT NULL,
NAME VARCHAR(20),
address VARCHAR(100),
PRIMARY KEY (sn)
);
/*==============================================================*/
/* Table: employee */
/*==============================================================*/
CREATE TABLE employee
(
sn CHAR(5) NOT NULL,
PASSWORD VARCHAR(20),
NAME VARCHAR(20),
department_sn CHAR(5),
post VARCHAR(20),
PRIMARY KEY (sn)
);
ALTER TABLE claim_voucher ADD CONSTRAINT FK_Reference_2 FOREIGN KEY (next_deal_sn)
REFERENCES employee (sn) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE claim_voucher ADD CONSTRAINT FK_Reference_3 FOREIGN KEY (create_sn)
REFERENCES employee (sn) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE claim_voucher_item ADD CONSTRAINT FK_Reference_4 FOREIGN KEY (claim_voucher_id)
REFERENCES claim_voucher (id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE deal_record ADD CONSTRAINT FK_Reference_5 FOREIGN KEY (claim_voucher_id)
REFERENCES claim_voucher (id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE deal_record ADD CONSTRAINT FK_Reference_6 FOREIGN KEY (deal_sn)
REFERENCES employee (sn) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE employee ADD CONSTRAINT FK_Reference_1 FOREIGN KEY (department_sn)
REFERENCES department (sn) ON DELETE RESTRICT ON UPDATE RESTRICT;
INSERT INTO department VALUES('10001','总经理办公室','A座0201');
INSERT INTO department VALUES('10002','财务部','A座0202');
INSERT INTO department VALUES('10003','事业部','A座0203');
INSERT INTO employee VALUES('10001','000000','张三','10001','总经理');
INSERT INTO employee VALUES('10002','000000','李四','10002','财务');
INSERT INTO employee VALUES('10003','000000','王五','10003','部门经理');
INSERT INTO employee VALUES('10004','000000','赵六','10003','员工');
USE `oa`;
SELECT * FROM `claim_voucher`; -- 报销单表
SELECT * FROM `claim_voucher_item`; -- 报销单明细表
SELECT * FROM `deal_record`; -- 报销单处理记录表
SELECT * FROM `department`; -- 部门表
SELECT * FROM `employee`; -- 员工表
-- 部门表
-- 查
SELECT * FROM `department`; -- 部门表
-- 根据部门sn查询
SELECT * FROM `department` WHERE sn='10001';
-- 添加部门
INSERT INTO `department` (sn,NAME,address) VALUES ('10004','后勤部','A座0204');
-- 修改部门
UPDATE `department` SET sn='10005',NAME='总经理安保部',address='A座0205' WHERE sn = '10004';
-- 删除部门
DELETE FROM `department` WHERE sn = '10005';
-- 员工表
-- 查
SELECT * FROM `employee`; -- 员工表
-- 根据员工sn查询
SELECT * FROM `employee` WHERE sn='10001';
-- 添加员工
INSERT INTO `employee` (sn,PASSWORD,NAME,department_sn,post) VALUES ('10005','123123','刁七','10003','员工');
-- 修改员工
UPDATE `employee` SET sn='10005',PASSWORD='123123',NAME='孙红雷',department_sn='10003',post='员工' WHERE sn = '10005';
-- 删除员工
DELETE FROM `employee` WHERE sn = '10005';
-- 报销单表
-- 查
SELECT * FROM `claim_voucher`; -- 报销表
-- 根据报销单id查询
SELECT * FROM `claim_voucher` WHERE id=1;
-- 添加报销单
INSERT INTO `claim_voucher` (id,cause,create_sn,create_time,next_deal_sn,total_amount,STATUS) VALUES (2,'出差','10005','2020-03-23','10003','189.50','未审批');
-- 修改报销单
UPDATE `claim_voucher` SET id=1,cause='误餐',create_sn='10005',create_time='2020-03-23',next_deal_sn='10003',total_amount='89.50',STATUS='未审批' WHERE id = 1;
-- 删除员工
DELETE FROM `claim_voucher` WHERE id = 1;
-- 报销单明细表
-- 查
SELECT * FROM `claim_voucher_item`; -- 报销明细表
-- 根据报销单明细id查询
SELECT * FROM `claim_voucher_item` WHERE id=1;
-- 添加报销明细单
INSERT INTO `claim_voucher_item` (id,claim_voucher_id,item,amount,COMMENT) VALUES (1,1,'误餐','89.50','出差导致误餐');
-- 修改报销单明细
UPDATE `claim_voucher_item` SET id=1,claim_voucher_id=1,item='误餐',amount=89.5,COMMENT='生病导致误餐' WHERE id = 1;
-- 删除报销单明细
DELETE FROM `claim_voucher_item` WHERE id = 1;
-- 报销单处理记录表
-- 查
SELECT * FROM `deal_record`; -- 报销处理记录表
-- 根据报销单处理记录id查询
SELECT * FROM `deal_record` WHERE id=1;
-- 添加报销明细单
INSERT INTO `deal_record` (id,claim_voucher_id,deal_sn,deal_time,deal_way,deal_result,COMMENT) VALUES (1,1,'10003','2020-03-23','误餐','已审批','出差导致误餐');
-- 修改报销单处理记录
UPDATE `deal_record` SET id=1,claim_voucher_id=1,deal_sn="10003",deal_time='2020-03-23',deal_way='误餐',deal_result='已审批',COMMENT='生病导致误餐' WHERE id = 2;
-- 删除报销单处理记录
DELETE FROM `deal_record` WHERE id = 1;
——————————————————————————————
创建项目
<dependencies>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-beansartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-coreartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-contextartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-expressionartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-testartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatis-springartifactId>
<version>2.0.3version>
dependency>
<dependency>
<groupId>org.mybatisgroupId>
<artifactId>mybatisartifactId>
<version>3.5.4version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-jdbcartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>commons-logginggroupId>
<artifactId>commons-loggingartifactId>
<version>1.2version>
dependency>
<dependency>
<groupId>log4jgroupId>
<artifactId>log4jartifactId>
<version>1.2.17version>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<version>8.0.19version>
dependency>
<dependency>
<groupId>commons-dbcpgroupId>
<artifactId>commons-dbcpartifactId>
<version>1.4version>
dependency>
<dependency>
<groupId>commons-poolgroupId>
<artifactId>commons-poolartifactId>
<version>1.6version>
dependency>
<dependency>
<groupId>com.github.jsqlparsergroupId>
<artifactId>jsqlparserartifactId>
<version>2.0version>
dependency>
<dependency>
<groupId>com.github.pagehelpergroupId>
<artifactId>pagehelperartifactId>
<version>5.1.11version>
dependency>
dependencies>
<dependencies>
<dependency>
<groupId>org.examplegroupId>
<artifactId>oa_daoartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aopartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-aspectsartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>aopalliancegroupId>
<artifactId>aopallianceartifactId>
<version>1.0version>
dependency>
<dependency>
<groupId>org.aspectjgroupId>
<artifactId>aspectjweaverartifactId>
<version>1.9.5version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-txartifactId>
<version>5.2.3.RELEASEversion>
dependency>
dependencies>
pom.xml 配置web依赖的jar包
<dependencies>
<dependency>
<groupId>org.examplegroupId>
<artifactId>oa_bizartifactId>
<version>1.0-SNAPSHOTversion>
dependency>
<dependency>
<groupId>junitgroupId>
<artifactId>junitartifactId>
<version>4.12version>
<scope>testscope>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>servlet-apiartifactId>
<version>2.5version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>javax.servletgroupId>
<artifactId>jstlartifactId>
<version>1.2version>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webartifactId>
<version>5.2.3.RELEASEversion>
dependency>
<dependency>
<groupId>com.fasterxml.jackson.coregroupId>
<artifactId>jackson-databindartifactId>
<version>2.10.2version>
dependency>
<dependency>
<groupId>com.fasterxml.jackson.coregroupId>
<artifactId>jackson-coreartifactId>
<version>2.10.2version>
dependency>
<dependency>
<groupId>com.fasterxml.jackson.coregroupId>
<artifactId>jackson-annotationsartifactId>
<version>2.10.2version>
dependency>
dependencies>
<resources>
<resource>
<directory>${basedir}/src/main/javadirectory>
<includes>
<include>**/*.xmlinclude>
includes>
resource>
resources>