|
@@ -1,12 +1,15 @@
|
1
|
1
|
package com.yunzhi.liyuanhui.controller;
|
2
|
2
|
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
7
|
import com.yunzhi.liyuanhui.common.BaseController;
|
7
|
8
|
import com.yunzhi.liyuanhui.common.ResponseBean;
|
8
|
9
|
import com.yunzhi.liyuanhui.common.StringUtils;
|
|
10
|
+import com.yunzhi.liyuanhui.entity.TdGalleryType;
|
9
|
11
|
import com.yunzhi.liyuanhui.enums.StatusEnum;
|
|
12
|
+import com.yunzhi.liyuanhui.service.ITdGalleryTypeService;
|
10
|
13
|
import org.slf4j.Logger;
|
11
|
14
|
import org.slf4j.LoggerFactory;
|
12
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -37,6 +40,8 @@ public class TaGalleryController extends BaseController {
|
37
|
40
|
@Autowired
|
38
|
41
|
public ITaGalleryService iTaGalleryService;
|
39
|
42
|
|
|
43
|
+ @Autowired
|
|
44
|
+ private ITdGalleryTypeService iTdGalleryTypeService;
|
40
|
45
|
|
41
|
46
|
/**
|
42
|
47
|
* 分页查询列表
|
|
@@ -69,6 +74,16 @@ public class TaGalleryController extends BaseController {
|
69
|
74
|
public ResponseBean taGalleryAdd(@RequestBody TaGallery taGallery) throws Exception{
|
70
|
75
|
|
71
|
76
|
if (iTaGalleryService.save(taGallery)){
|
|
77
|
+
|
|
78
|
+ // 反更新分类中图片数
|
|
79
|
+ UpdateWrapper<TdGalleryType> updateWrapper = new UpdateWrapper<>();
|
|
80
|
+ updateWrapper.setSql("img_num = img_num + 1");
|
|
81
|
+ updateWrapper.eq("type_id", taGallery.getTypeId());
|
|
82
|
+
|
|
83
|
+ if (!iTdGalleryTypeService.update(updateWrapper)) {
|
|
84
|
+ return ResponseBean.error("保存失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
85
|
+ }
|
|
86
|
+
|
72
|
87
|
return ResponseBean.success(taGallery);
|
73
|
88
|
}else {
|
74
|
89
|
return ResponseBean.error("保存失败", ResponseBean.ERROR_UNAVAILABLE);
|