package com.zrb.album.controller;
import com.zrb.album.bean.Album;
import com.zrb.album.bean.Face;
import com.zrb.album.bean.Userinfo;
import com.zrb.album.entity.JsonModel;
import com.zrb.album.service.IPhotoService;
import com.zrb.album.utils.StringConfig;
import com.zrb.album.utils.api.UploadPhotoApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.net.util.IPAddressUtil;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
@RestController
@Slf4j
public class PhotoController {
@Autowired
IPhotoService albumService;
@Autowired
UploadPhotoApi uploadPhotoApi;
private String paths;
// 1: 人物 2:动物 3:风景 4:交通工具 5:建筑 6:未知
Map<Integer, String> int2sort = new HashMap<Integer, String>(){{
put(1, "人物");
put(2, "动植物");
put(3, "风景");
put(4, "交通工具");
put(5, "建筑");
put(6, "截屏");
put(7, "卡通");
put(8, "电子产品");
put(9, "服装");
put(10, "weizhi");
}};
@RequestMapping( value = "/album/face/recommend", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel recommend(HttpSession session) throws IOException {
JsonModel jm = new JsonModel();
Userinfo user = (Userinfo) session.getAttribute("user");
Object recommendURL = uploadPhotoApi.getRecommendURL(user);
jm.setMsg("拍照并推荐成功");
jm.setObj(recommendURL);
jm.setCode(200);
return jm;
}
@RequestMapping( value = "/album/state/set", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel setState(HttpSession session, String md5, Integer state){
JsonModel jm = new JsonModel();
Album album = new Album();
// 此时album 仅包含md5
album.setMd5(md5);
albumService.changeState(album, state);// 此时 包含 md5以及类型. 0 删除 1普通状态 2归档状态 3收藏状态
jm.setCode(200);
jm.setMsg("change state success");
return jm;
}
// @RequestMapping( value = "/album/state/add", method = { RequestMethod.GET, RequestMethod.POST })
// public JsonModel addToGarbage(HttpSession session, String md5){
// JsonModel jm = new JsonModel();
// Album album = new Album();
// // 此时album 仅包含md5
// album.setMd5(md5);
// albumService.changeState(album, 1);// 此时 包含 md5以及类型. 0 删除 1普通状态 2归档状态 3收藏状态
// jm.setCode(200);
// jm.setMsg("delete from garbage success");
// return jm;
// }
@RequestMapping( value = "/face/detect", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel faceDetect(HttpSession session) throws InterruptedException, IOException {
JsonModel jm = new JsonModel();
Userinfo user = (Userinfo) session.getAttribute("user");
albumService.uploadFace(user, this.paths);
this.paths = "";
jm.setCode(200);
jm.setMsg("reset album success");
return jm;
}
@PostMapping("/upload-multi-files")
@ResponseBody
public JsonModel uploadMultiFiles(HttpSession session, List<MultipartFile> files) throws IOException, InterruptedException {
JsonModel jm = new JsonModel();
jm.setCode(200);
log.info("send message");
log.info(files.size() + "");
List<Object> upload_strs = new ArrayList<>();
StringBuilder paths = new StringBuilder();
Userinfo user = (Userinfo) session.getAttribute("user");
Random random = new Random(System.currentTimeMillis());
for (MultipartFile file : files) {
String fileName = file.getOriginalFilename() + "";
fileName = DigestUtils
.md2Hex(fileName).toUpperCase();
log.info("coming");
// File _file = Paths.get(StringConfig.PATH_FILE_STORE, user.getUser_id().toString(), fileName).toFile();
File _file = Paths.get(StringConfig.PATH_FILE_STORE, user.getUser_id().toString(), "cash", fileName).toFile();
file.transferTo(_file.toPath());
paths.append(_file.getPath()).append(',');
log.info("copy file");
Object upload_str = uploadPhotoApi.uploadPhoto(_file, user.getUser_id(), user.getFacesetid());
upload_strs.add(upload_str);
}
// 人脸识别 v1
final String _paths = paths.toString();
albumService.uploadFace(user, _paths);
// 人脸识别v2
// this.paths = paths.toString();
jm.setObj(upload_strs);
jm.setMsg("save success");
return jm;
}
@RequestMapping( value="/getAllPhoto", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel displayMultiPhotoByUserId(HttpSession session){
List<Album> imageString = new ArrayList<>();
Userinfo user = (Userinfo) session.getAttribute("user");
System.out.println(user);
try {
List<Album> allAlbum = albumService.findAllAlbum(user.getUser_id());
for (Album album : allAlbum) {
imageString.add(album);
log.info("返回前端"+album.getMd5());
}
} catch (Exception e) {
e.printStackTrace();
}
JsonModel jm = new JsonModel();
jm.setCode(200);
log.info("send message");
jm.setObj(imageString);
return jm;
}
@RequestMapping( value="/photo/sort", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel displayMultiPhotoBySort(HttpSession session, Integer sort){
String _sort = int2sort.get(sort);
List<Album> imageString = new ArrayList<>();
Userinfo user = (Userinfo) session.getAttribute("user");
System.out.println(user);
try {
List<Album> allAlbum = albumService.getAlbumsBySort(user.getUser_id(), _sort);
for (Album album : allAlbum) {
imageString.add(album);
log.info("返回前端"+album.getMd5());
}
} catch (Exception e) {
e.printStackTrace();
}
JsonModel jm = new JsonModel();
jm.setCode(200);
log.info("send message");
jm.setObj(imageString);
return jm;
}
@RequestMapping( value="/photo/search", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel displayMultiPhotoBySort(HttpSession session, String sort){
List<Album> imageString = new ArrayList<>();
Userinfo user = (Userinfo) session.getAttribute("user");
System.out.println(user);
try {
List<Album> allAlbum = albumService.getAlbumsBySort(user.getUser_id(), sort);
for (Album album : allAlbum) {
imageString.add(album);
log.info("返回前端"+album.getMd5());
}
} catch (Exception e) {
e.printStackTrace();
}
JsonModel jm = new JsonModel();
jm.setCode(200);
log.info("send message");
jm.setObj(imageString);
return jm;
}
@RequestMapping( value = "/album/state/reset", method = { RequestMethod.GET, RequestMethod.POST })
public JsonModel resetPhoto(HttpSession session, String md5){
JsonModel jm = new JsonModel();
Album album = new Album();
// 此时album 仅包含md5
album.setMd5(md5);
albumService.changeState(album, 1);// �
没有合适的资源?快使用搜索试试~ 我知道了~
基于移动云平台的智能云相册设计与实现源码
共470个文件
js:256个
jpg:49个
java:40个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 63 浏览量
2024-10-02
15:53:23
上传
评论
收藏 8.9MB ZIP 举报
温馨提示
该项目是一款基于移动云平台的智能云相册设计源码,涵盖469个文件,包括256个JavaScript文件、49个JPG图片文件、40个Java文件、33个PNG图片文件、20个CSS文件、18个HTML文件、14个Python文件、6个TypeScript文件、4个Markdown文件、4个JSON文件。该相册系统利用现代Web技术实现,支持多语言编写,旨在为用户提供便捷的云端相册管理服务。
资源推荐
资源详情
资源评论
收起资源包目录
基于移动云平台的智能云相册设计与实现源码 (470个子文件)
bootstrap.min.css 135KB
style.css 59KB
chosen.css 12KB
chosen.min.css 10KB
ssi-uploader.css 9KB
fakeLoader.css 8KB
buttons.bootstrap.min.css 8KB
buttons.dataTables.min.css 8KB
cs-skin-elastic.css 7KB
theme.css 6KB
ssi-uploader.min.css 6KB
htmleaf-demo.css 5KB
dataTables.bootstrap.min.css 5KB
share.css 4KB
custom.css 3KB
demo.css 2KB
style.css 2KB
stapel.css 2KB
zzsc.css 1KB
jqvmap.min.css 809B
iconfont.eot 5KB
icomoon.eot 5KB
footer.gif 19KB
bg.gif 4KB
.gitignore 324B
index.html 55KB
search.html 44KB
index.html 24KB
share.html 20KB
album.html 19KB
allshow.html 14KB
file.html 14KB
favorite.html 13KB
recycle-bin.html 12KB
splitJoint.html 12KB
utilities.html 9KB
photograph.html 7KB
page-register.html 7KB
page-login.html 7KB
pages-forget.html 4KB
test_share.html 1KB
upload.html 393B
test_url.html 167B
index.html 0B
AIPhotoAlbum.iml 12KB
PhotoController.java 10KB
PhotoDaoImpl.java 6KB
CollectionController.java 5KB
UploadPhotoApi.java 5KB
FaceController.java 5KB
IFaceServiceImpl.java 5KB
CollectionDaoImpl.java 4KB
UserinfoController.java 4KB
UserinfoDaoImpl.java 3KB
DBConfig.java 3KB
IPhotoServiceImpl.java 2KB
FaceApi.java 2KB
FileTest.java 2KB
TestApi.java 2KB
ICollectionServiceImpl.java 2KB
CreateFaceSetApi.java 2KB
IFaceServiceImplTest.java 1KB
FileUtils.java 1KB
Aop.java 1KB
SessionController.java 1KB
TestPhotoController.java 922B
IUserinfoServiceImpl.java 828B
JsonModel.java 827B
TestDao.java 774B
Application.java 759B
TestUserinfoController.java 681B
IFaceService.java 680B
IPhotoService.java 666B
Album.java 550B
ICollectionService.java 509B
ICollectionDao.java 500B
IPhotoDao.java 457B
Face.java 408B
RedisHttpSessionConfig.java 312B
Userinfo.java 311B
StringConfig.java 279B
Collection.java 265B
IUserinfoDao.java 256B
IUserinfoService.java 236B
AppTest.java 25B
face2.jpg 163KB
hz1.jpg 84KB
zc_bg.jpg 58KB
3.jpg 58KB
QQ图片20201220192343.jpg 50KB
img-1.jpg 47KB
img-3.jpg 45KB
img-2.jpg 44KB
3.jpg 36KB
3.jpg 35KB
2.jpg 31KB
ad002.jpg 30KB
1.jpg 30KB
1.jpg 26KB
3.jpg 22KB
共 470 条
- 1
- 2
- 3
- 4
- 5
资源评论
lly202406
- 粉丝: 2593
- 资源: 5440
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功