基于javaweb的SSM+Maven校园相册管理系统(java+ssm+html+bootstrap+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

430023492402

440023492402

450023492402

460023492402

470023492402

480023492402

490023492402

基于javaweb的SSM+Maven校园相册管理系统(java+ssm+html+bootstrap+layui+mysql)

项目介绍

实现了用户登录与注册,查看首页,查看我的相册,添加相册,提交评论,修改密码等功能

环境需要

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

技术栈

  1. 后端:Spring+SpringMVC+Mybatis 2. 前端:html+CSS+JavaScript+bootstrap+layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,在浏览器中输入 http://localhost:8080/ssm_xcselect

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
	@RequestMapping("/update")
public R update(@RequestBody CommentEntity comment){
commentService.update(comment);

return R.ok();
}

/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids){
commentService.deleteBatch(ids);

return R.ok();
}

}
package com.learn.controller;



/**
* 系统配置信息
*
* @email 123456@qq.com
*/
@RestController
@RequestMapping("/sys/config")
public class SysConfigController extends AbstractController {
@Autowired
private SysConfigService sysConfigService;

/**
* 所有配置列表
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
            // 返回“图像”选项卡并显示图片
out.println("<script type=\"text/javascript\">");
out.println("window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ",'" + path + "','')");
out.println("</script>");

} catch (RuntimeException e) {
out.println("<script type=\"text/javascript\">");
out.println("window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ",'','" + e.getMessage() + "');");
out.println("</script>");
}
}


}
package com.learn.controller;



/**
* 角色管理
*
* @email 123456@qq.com
*/
@RestController
@RequestMapping("/sys/role")
public class SysRoleController extends AbstractController {
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysRoleMenuService sysRoleMenuService;

/**
* 角色列表
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
//            rootPath = classPath.substring(1, classPath.indexOf("/WEB-INF/classes"));
rootPath = classPath;
rootPath = rootPath.replace("/", "\\");
}
//linux下
if ("/".equals(File.separator)) {
rootPath = classPath.substring(0, classPath.indexOf("/WEB-INF/classes"));
rootPath = rootPath.replace("\\", "/");
}
return rootPath;
}

/**
* 判断文件是否未空,或者没有数据
*
* @param file 文件
* @return 结果
*/
public static boolean isEmpty(MultipartFile file) {
return file == null || file.getSize() == 0 || "".equals(file.getOriginalFilename().trim());
}


/**
* 上传文件
*
* @param prefix 存放文件的跟路径
* @param file 文件
* @return 返回相对路径
*/
public static String uploadFile(String prefix, MultipartFile file, HttpServletRequest request) {
prefix = "/cdn/" + prefix;
//取得当前上传文件的文件名称
String myFileName = file.getOriginalFilename();
String suffix = myFileName.substring(myFileName.lastIndexOf(".") + 1);
//重命名上传后的文件名
String fileName = UUID.randomUUID().toString() + "." + suffix.toLowerCase();

//文件夹路径
String filePath = getRootPath(request) + prefix + "/";
File f = new File(filePath);
// 目录已存在创建文件夹
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
		
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));

//用户名
String username = ShiroUtils.getUserEntity().getUsername();
sysLog.setUsername(username);

sysLog.setCreateDate(new Date());
//保存系统日志
sysLogService.save(sysLog);
}

}
package com.learn.utils;



/**
* IP地址
*
* @email 123456@qq.com
*/
public class IPUtils {
private static Logger logger = LoggerFactory.getLogger(IPUtils.class);

/**
* 获取IP地址
*
* 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
* 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
*/
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
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
			
sysMenuService.update(menu);

return R.ok();
}

/**
* 删除
*/
@SysLog("删除菜单")
@RequestMapping("/delete")
@RequiresPermissions("sys:menu:delete")
public R delete(@RequestBody Long[] menuIds){
for(Long menuId : menuIds){
if(menuId.longValue() <= 30){
return R.error("系统菜单,不能删除");
}
}
sysMenuService.deleteBatch(menuIds);

return R.ok();
}

/**
* 用户菜单列表
*/
@RequestMapping("/user")
public R user(){
List<SysMenuEntity> menuList = sysMenuService.getUserMenuList(getUserId());

return R.ok().put("menuList", menuList);
}

/**
* 验证参数是否正确
*/
private void verifyForm(SysMenuEntity menu){
if(StringUtils.isBlank(menu.getName())){
throw new RRException("菜单名称不能为空");
}

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
	}

/**
* 验证参数是否正确
*/
private void verifyForm(SysMenuEntity menu){
if(StringUtils.isBlank(menu.getName())){
throw new RRException("菜单名称不能为空");
}

if(menu.getParentId() == null){
throw new RRException("上级菜单不能为空");
}

//菜单
if(menu.getType() == Constant.MenuType.MENU.getValue()){
if(StringUtils.isBlank(menu.getUrl())){
throw new RRException("菜单URL不能为空");
}
}

//上级菜单类型
int parentType = Constant.MenuType.CATALOG.getValue();
if(menu.getParentId() != 0){
SysMenuEntity parentMenu = sysMenuService.queryObject(menu.getParentId());
parentType = parentMenu.getType();
}

//目录、菜单
if(menu.getType() == Constant.MenuType.CATALOG.getValue() ||
menu.getType() == Constant.MenuType.MENU.getValue()){
if(parentType != Constant.MenuType.CATALOG.getValue()){
throw new RRException("上级菜单只能为目录类型");
}
return ;
}

//按钮
if(menu.getType() == Constant.MenuType.BUTTON.getValue()){
if(parentType != Constant.MenuType.MENU.getValue()){
throw new RRException("上级菜单只能为菜单类型");
}
return ;
}
}
}
package com.learn.controller;


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