基于javaweb的SpringBoot线上网络文件管理系统(java+springboot+html+ssm+maven+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

170123062402

180123062402

190123062402

200123062402

220123062402

230123062402

基于javaweb的SpringBoot线上网络文件管理系统(java+springboot+html+ssm+maven+mysql)

项目介绍

本项目分为前后台,有管理员与用户两种角色;

管理员角色包含以下功能:

管理员登录,管理员主页,权限管理,分类管理,用户管理,文档管理,下载记录,上传记录等功能。 用户角色包含以下功能:

注册账号,登录,系统首页,我的资源查看,编辑资源,我的资料修改,文件上传,密码重置,邮箱信息,密码重置成功等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 8.0/5.7版本;

技术栈

HTML+CSS+JavaScript+mysql+Spring+SpringMVC+mybatis+Spring boot

使用说明
运行项目,输入http://localhost:8091 登录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
    return fileDAO.getLocalUrlByVisitUrl(Checker.checkNull(visitUrl));
}

@Override
public List<FileRecord> listAll(int userId, int offset, int categoryId, String orderBy, String search) {
return fileDAO.listAll(userId, offset, categoryId, orderBy, search);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
Exception.class)
public boolean upload(int categoryId, String tag, String description, String prefix, MultipartFile multipartFile,
User user) {
if (user.getIsUploadable() == 1) {
String name = multipartFile.getOriginalFilename();
String suffix = FileExecutor.getFileSuffix(name);
String localUrl = SettingConfig.getUploadStoragePath() + ValueConsts.SEPARATOR + name;
Category category = categoryService.getById(categoryId);
long maxSize = Formatter.sizeToLong(StartApplication.settings.getStringUseEval(ConfigConsts
.FILE_MAX_SIZE_OF_SETTING));
long size = multipartFile.getSize();
boolean fileExists = localUrlExists(localUrl);
//检测标签是否合法
if (StartApplication.settings.getBooleanUseEval(ConfigConsts.TAG_REQUIRE_OF_SETTING)) {
String[] tags = Checker.checkNull(tag).split(ValueConsts.SPACE);
if (tags.length <= StartApplication.settings.getIntegerUseEval(ConfigConsts.TAG_SIZE_OF_SETTING)) {
int maxLength = StartApplication.settings.getIntegerUseEval(ConfigConsts.TAG_LENGTH_OF_SETTING);
for (String t : tags) {
if (t.length() > maxLength) {
return false;
}
}
} else {
return false;
}
}
//是否可以上传
boolean canUpload = !multipartFile.isEmpty() && size <= maxSize && Pattern.compile(StartApplication
.settings.getStringUseEval(ConfigConsts.FILE_SUFFIX_MATCH_OF_SETTING)).matcher(suffix).matches()
&& (Checker.isNotExists(localUrl) || !fileExists || StartApplication.settings.getBooleanUseEval
(ConfigConsts.FILE_COVER_OF_SETTING));
logger.info("is empty [" + multipartFile.isEmpty() + "], file size [" + size + "], max file size [" +
maxSize + "]");
if (canUpload) {
String visitUrl = getRegularVisitUrl(Checker.isNotEmpty(prefix) && user.getPermission() > 1 ? prefix
: StartApplication.settings.getStringUseEval(ConfigConsts.CUSTOM_LINK_RULE_OF_SETTING), user,
name, suffix, category);
if (fileExists) {
removeByLocalUrl(localUrl);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


/**
*/
@Controller
@Api(description = "视图页面映射")
public class ViewController {

private final HttpServletRequest request;

@Autowired
public ViewController(IUserService userService, HttpServletRequest request) {
this.request = request;
}

@ApiOperation(value = "远程文件管理页面")
@AuthInterceptor(InterceptorLevel.SYSTEM)
@RequestMapping(value = "/filemanager", method = RequestMethod.GET)
public String fileManager() {
return "/filemanager";
}

@ApiOperation(value = "上传页面")
@AuthInterceptor
@RequestMapping(value = "/upload", method = RequestMethod.GET)
public String upload() {
return "/upload";
}

@ApiOperation(value = "首页")
@AuthInterceptor(InterceptorLevel.NONE)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48


/**
*/
@Service
public class UserServiceImpl implements IUserService {

private final UserDAO userDAO;

private Logger logger = Logger.getLogger(UserServiceImpl.class);

@Autowired
public UserServiceImpl(UserDAO userDAO) {this.userDAO = userDAO;}

@Override
public boolean updatePermission(int id, int permission) {
return userDAO.updatePermission(id, permission > 2 ? 2 : permission);
}

@Override
public boolean resetPassword(int id, String password) {
boolean result = Checker.isNotEmpty(password) && userDAO.updatePasswordById(id, password);
if (result) {
TokenConfig.removeTokenByValue(id);
try {
MailSender.sendMail(getUserById(id).getEmail(), "密码重置通知", "您的密码已被管理员重置为:" + password);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
return result;
}

@Override
public boolean updateFileAuth(int id, String auths) {
int[] auth = BeanUtils.getAuth(auths);
return userDAO.updateAuthById(id, auth[0], auth[1], auth[2], auth[3], auth[4]);
}

@Override
public List<User> listUser(int permission, String condition, int offset) {
return userDAO.listUserBy(permission, condition, offset);
}

@Override
public User login(String loginName, String password, String token, HttpServletResponse response) {
boolean allowLogin = settings.getBooleanUseEval(ConfigConsts.ALLOW_LOGIN_OF_SETTINGS);
User user = null;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 *
* @param id 文件编号
*
* @return {@link BaseAuthRecord}
*/
BaseAuthRecord getAuth(long id);

/**
* 批量删除文件
*
* @param ids 所有文件编号
*
* @return 是否删除成功
*/
boolean deleteFiles(String ids);

/**
* 更新文件路径
*
* @param id 文件编号
* @param oldLocalUrl 原本地路径
* @param localUrl 本地路径
* @param visitUrl 访问路径
*
* @return 是否更新成功
*/
boolean[] updateUrl(int id, String oldLocalUrl, String localUrl, String visitUrl);

/**
* 更新文件信息
*
* @param id 文件编号
* @param user 用户对象
* @param name 文件名
* @param category 文件分类
* @param tag 标签
* @param description 文件描述
*
* @return 是否更新成功
*/
boolean updateFileInfo(long id, User user, String name, String category, String tag, String description);

/**
* 删除文件,验证权限
*
* @param user 用户对象
* @param fileId 文件编号
*
* @return {@link Boolean}
*/
boolean removeFile(User user, long fileId);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@Override
public List<FileRecord> listUserDownloaded(int userId, int offset, String search) {
return fileDAO.listUserDownloaded(userId, offset, search);
}

@Override
public List<FileRecord> listUserUploaded(int userId, int offset, String search) {
return fileDAO.listUserUploaded(userId, offset, search);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
Exception.class)
public boolean removeById(long id) {
downloadDAO.removeByFileId(id);
authService.removeByFileId(id);
return fileDAO.removeById(id);
}

@Override
public boolean removeByVisitUrl(String visitUrl) {
long fileId = fileDAO.getIdByVisitUrl(visitUrl);
return removeById(fileId);
}

@Override
public boolean removeByLocalUrl(String localUrl) {
long fileId = fileDAO.getIdByLocalUrl(localUrl);
return removeById(fileId);
}

@Override
public String getResource(String visitUrl, HttpServletRequest request) {
logger.info("visit url: " + visitUrl);
boolean downloadable = StartApplication.settings.getBooleanUseEval(ConfigConsts
.ANONYMOUS_DOWNLOADABLE_OF_SETTING);
User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING);
File file = fileDAO.getFileByVisitUrl(visitUrl);
AuthRecord authRecord = null;
if (Checker.isNotNull(file)) {
authRecord = authService.getByFileIdAndUserId(file.getId(), Checker.isNull(user) ? 0 : user.getId());
}
boolean canDownload = Checker.isNotNull(file) && file.getIsDownloadable() == 1 && (downloadable || (Checker
.isNull(authRecord) ? (Checker.isNotNull(user) && user.getIsDownloadable() == 1) : authRecord
.getIsDownloadable() == 1));
if (canDownload) {
fileDAO.updateDownloadTimesById(file.getId());
if (Checker.isNotNull(user)) {
downloadDAO.insertDownload(user.getId(), file.getId());
}
return file.getLocalUrl();
}


项目链接:
https://javayms.github.io?id=211222062008200wt
https://javayms.pages.dev?id=211222062008200wt