package com.bootdo.nsmp.domain;
import java.io.Serializable;
public class Material implements Serializable{
private static final long serialVersionUID = 1L;
//主键Id
private Long id;
//系统拓扑结构说明
private Integer structure;
//对应的文件
private String struFile;
//对应的文件路径
private String struFileUrl;
//系统安全组织架构
private Integer safe;
//对应的文件
private String safeFile;
//对应的文件路径
private String safeFileUrl;
//系统安全保护设施设计实施方案
private Integer protect;
//对应的文件
private String proFile;
//对应的文件路径
private String proFileUrl;
//系统使用的安全产品清单
private Integer list;
//对应的文件
private String listFile;
//对应的文件路径
private String listFileUrl;
//系统等级测试报告
private Integer clazz;
//对应的文件
private String clazzFile;
//对应的文件路径
private String clazzFileUrl;
//专家评审情况
private Integer judge;
//对用的文件
private String judgeFile;
//对用的文件路径
private String judgeFileUrl;
//上级主管部门评审意见
private Integer gover;
//对应的文件
private String goverFile;
//对应的文件
private String goverFileUrl;
}
原理:在Java中,数据库使用的是MySQL数据库,在存储的时候,分别存储的是文件的名称和路径,所以我们在创建实体类的时候,实际上创建的是文件名和路径,在创建数据库的时候,将文件名和路径对应的字段分别创建,在存储的时候,分别存储文件名和路径。实际上文件名和文件的路径是存储在数据库中的,但是真正的文件时存储在服务器上的。
文件具体怎么调用,等到我做到哪一步了会再写出来。(这里只是实体类的写法)
以下是mapper.xml的文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bootdo.nsmp.dao.MaterialDao">
<select id="list" resultType="com.bootdo.nsmp.domain.Material">
select * from material
<if test="offset != null and limit != null">
limit ${offset}, ${limit}
</if>
</select>
<select id="count" resultType="int">
select count(*) from material
</select>
<insert id="save" parameterType="com.bootdo.nsmp.domain.Material"
useGeneratedKeys="true" keyProperty="id">
insert into material
(
`structure`,
`struFile`,
`struFileUrl`,
`safe`,
`safeFile`,
`safeFileUrl`,
`protect`,
`proFile`,
`proFileUrl`,
`list`,
`listFile`,
`listFileUrl`,
`clazz`,
`clazzFile`,
`clazzFileUrl`,
`judge`,
`judgeFile`,
`judgeFileUrl`,
`gover`,
`goverFile`,
`goverFileUrl`
)
values
(
#{structure},
#{struFile},
#{struFileUrl},
#{safe},
#{safeFile},
#{safeFileUrl},
#{protect},
#{proFile},
#{proFileUrl},
#{list},
#{listFile},
#{listFileUrl},
#{clazz},
#{clazzFile},
#{clazzFileUrl},
#{judge},
#{judgeFile},
#{judgeFileUrl},
#{gover},
#{goverFile},
#{goverFileUrl}
)
</insert>
</mapper>
创建数据库:
select * from material;
CREATE TABLE material
(
id BIGINT(11) not null PRIMARY KEY,
structure int(30),
struFile VARCHAR(50),
struFileUrl VARCHAR(50),
safe int(30),
safeFile VARCHAR(50),
safeFileUrl VARCHAR(50),
protect int(30),
proFile VARCHAR(50),
proFileUrl VARCHAR(50),
list int(30),
listFile VARCHAR(50),
listFileUrl VARCHAR(50),
clazz int(30),
clazzFile VARCHAR(50),
clazzFileUrl VARCHAR(50),
judge int(30),
judgeFile VARCHAR(50),
judgeFileUrl VARCHAR(50),
gover int(30),
goverFile VARCHAR(50),
goverFileUrl VARCHAR(50)
)
前端设置:
<tr>
<th>
<em class="gg-star">*</em>
<span>上级主管部门审批意见</span>
</th>
<td>
<input type="radio" name="gover" value="有">有
<input type="radio" name="gover" value="无">无
</td>
<td>
<div class="form-group">
<label class="col-sm-3 control-label">附件:</label>
<div class="col-sm-8">
<input id="files7" name="goverFile" class="form-control" type="file">
</div>
</div>
</td>
</tr>