作者主页:Java毕设网
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
一、项目介绍
实现了用户登录与注册,查看首页,查看我的相册,添加相册,提交评论,修改密码等功能
二、环境需要
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
五、运行截图
六、相关代码
相册管理控制器
/**
* 相册
*
* @author admin
*/
@RestController
@RequestMapping("album")
public class AlbumController extends AbstractController {
@Autowired
private AlbumService albumService;
/**
* 列表
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
//查询列表数据
Query query = new Query(params);
List<AlbumEntity> albumList = albumService.queryList(query);
int total = albumService.queryTotal(query);
PageUtils pageUtil = new PageUtils(albumList, total, query.getLimit(), query.getPage());
return R.ok().put("page", pageUtil);
}
/**
* 列表
*/
@RequestMapping("/list2")
public R list2(@RequestParam Map<String, Object> params) {
params.put("user", super.getUserId());
Query query = new Query(params);
List<AlbumEntity> albumList = albumService.queryList(query);
return R.ok().put("list", albumList);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id) {
AlbumEntity album = albumService.queryObject(id);
return R.ok().put("album", album);
}
@Autowired
PicService picService;
@RequestMapping("/share/{id}")
public R share(@PathVariable("id") Long id) {
Map<String, Object> para = new HashMap<>();
para.put("album", id);
for (PicEntity pic : this.picService.queryList(para)) {
pic.setShare("1");
this.picService.update(pic);
}
return R.ok();
}
@RequestMapping("/noshare/{id}")
public R noshare(@PathVariable("id") Long id) {
Map<String, Object> para = new HashMap<>();
para.put("album", id);
for (PicEntity pic : this.picService.queryList(para)) {
pic.setShare("0");
this.picService.update(pic);
}
return R.ok();
}
/**
* 保存
*/
@RequestMapping("/save")
public R save(@RequestBody AlbumEntity album) {
album.setUser(super.getUserId());
albumService.save(album);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
public R update(@RequestBody AlbumEntity album) {
albumService.update(album);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Long[] ids) {
albumService.deleteBatch(ids);
for (Long id : ids) {
Map<String, Object> para = new HashMap<>();
para.put("album", id);
for (PicEntity pic : this.picService.queryList(para)) {
this.picService.delete(pic.getId());
}
}
return R.ok();
}
}