基于javaweb的SpringBoot智能相册管理系统图片相册(java+springboot+maven+vue+mysql+redis)

运行环境

Java≥8、MySQL≥5.7、Node.js≥14

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可

❗没学过node.js的不要搞前后端分离项目

适用

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

功能说明

182323210309

192323210309

212323210309

222323210309

232323210309

242323210309

252323210309

基于javaweb的SpringBoot智能相册管理系统图片相册(java+springboot+maven+vue+mysql+redis)

前端启动命令:npm run serve
后端启动类:StartApplication

登录:
user1 123456

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
    jsonObject.put("data",res);
jsonObject.put("status","success");
return jsonObject;
}

//恢复照片
@RequestMapping("/recoverImage")
public JSONObject recoverImage(HttpServletRequest req,String token,@RequestParam("imageId")List<Integer> imageId){
JSONObject jsonObject = new JSONObject();
User user = tokenUtil.jwtParser(token);
Integer userId;
if(user!=null) {
userId = user.getUserId();
}
else{
jsonObject.put("status","fail");
return jsonObject;
}
System.out.println(imageId);
recycleService.recoverImage(userId,imageId);
jsonObject.put("status","success");
recordService.addRecord(req,Operation.recoverImage.getName(), imageId.size(),userId);
return jsonObject;
}

//删除照片
@RequestMapping("/deleteImage")
public JSONObject deleteImage(HttpServletRequest req, String token, @RequestParam("imageId")List<Integer> imageId){
JSONObject jsonObject = new JSONObject();
User user = tokenUtil.jwtParser(token);
Integer userId;
if(user!=null) {
userId = user.getUserId();
}
else{
jsonObject.put("status","fail");
return jsonObject;
}
recycleService.deleteImage(userId,imageId);
jsonObject.put("status","success");

recordService.addRecord(req, Operation.deleteImage.getName(), imageId.size(),userId);
return jsonObject;
}
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
                SerializerFeature.WriteNullNumberAsZero,
// 将 List 类型的 null 转成 []
SerializerFeature.WriteNullListAsEmpty,
// 将 Boolean 类型的 null 转成 false
SerializerFeature.WriteNullBooleanAsFalse,
// 避免循环引用
SerializerFeature.DisableCircularReferenceDetect);

converter.setFastJsonConfig(config);
converter.setDefaultCharset(Charset.forName("UTF-8"));
List<MediaType> mediaTypeList = new ArrayList<>();
// 解决中文乱码问题,相当于在 Controller 上的 @RequestMapping 中加了个属性 produces = "application/json"
mediaTypeList.add(MediaType.APPLICATION_JSON);
converter.setSupportedMediaTypes(mediaTypeList);
converters.add(converter);

}
}



@Service
public class RecordServiceImpl implements RecordService {

@Resource
RecordMapper recordMapper;
@Resource
IpUtil ipUtil;
@Resource
DateUtil dateUtil;

/**
* 添加记录
* @param operation
* @param
* @param number
* @param userId
* @return
*/
@Override
public boolean addRecord(HttpServletRequest req,String operation, Integer number, Integer userId) {
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


@Service
public class ImageServiceImpl implements ImageService {

@Resource
private ImageMapper imageMapper;
@Resource
private UserMapper userMapper;
@Resource
private AlbumMapper albumMapper;
@Resource
private RecycleMapper recycleMapper;
@Resource
private FileServeUtil fileServeUtil;
@Resource
private RecordService recordService;
// 当前系统时间
private SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


/**
* 普通上传
* @param imageList
* @param userId
* @param albumId
* @param albumName
* @param imgType
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)//事务控制
public boolean uploadImage(HttpServletRequest req,List<Image> imageList, Integer userId, Integer albumId, String albumName, String imgType) throws Exception {
//添加图片
imageMapper.addImages(imageList);
//返回图片id集合
List<Integer> imageIds = new ArrayList<>();
for (Image i : imageList) {
imageIds.add(i.getImageId());
}
//添加中间用户图片表
userMapper.addUserImage(userId,imageIds);
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
            ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Forwarded-For");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}

return "0:0:0:0:0:0:0:1".equals(ip) ? LOCAL_IP : ip;
}

}



@Service
public interface RecordService {
/**
* 添加记录
* @param operation
* @param
* @param number
* @param userId
* @return
*/
boolean addRecord( HttpServletRequest req,String operation, Integer number, Integer userId);


/**
* 查询所有记录
* @param userId
* @return
*/
List<Record> selectAllRecord(Integer userId) throws ParseException;

/**
* 删除所有记录
* @param userId
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

@Service
public interface RecordService {
/**
* 添加记录
* @param operation
* @param
* @param number
* @param userId
* @return
*/
boolean addRecord( HttpServletRequest req,String operation, Integer number, Integer userId);


/**
* 查询所有记录
* @param userId
* @return
*/
List<Record> selectAllRecord(Integer userId) throws ParseException;

/**
* 删除所有记录
* @param userId
*/
void deleteAllRecord(Integer userId);

/**
* 删除部分记录
* @param userId
* @param Ids
*/
void deleteRecordByIds(Integer userId,List<Integer> Ids);


}


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