|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.shigongli.common.BaseController;
|
|
7
|
+import com.shigongli.common.OSSUtils;
|
7
|
8
|
import com.shigongli.common.ResponseBean;
|
8
|
9
|
import io.swagger.annotations.Api;
|
9
|
10
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -19,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
19
|
20
|
import com.shigongli.service.ITaMetaImageService;
|
20
|
21
|
import com.shigongli.entity.TaMetaImage;
|
21
|
22
|
import org.springframework.web.bind.annotation.RestController;
|
|
23
|
+import org.springframework.web.multipart.MultipartFile;
|
|
24
|
+
|
|
25
|
+import java.io.IOException;
|
22
|
26
|
|
23
|
27
|
/**
|
24
|
28
|
* <p>
|
|
@@ -39,81 +43,91 @@ public class TaMetaImageController extends BaseController {
|
39
|
43
|
@Autowired
|
40
|
44
|
public ITaMetaImageService iTaMetaImageService;
|
41
|
45
|
|
|
46
|
+ @Autowired
|
|
47
|
+ OSSUtils ossUtils;
|
42
|
48
|
|
43
|
|
- /**
|
44
|
|
- * 分页查询列表
|
45
|
|
- * @param pageNum
|
46
|
|
- * @param pageSize
|
47
|
|
- * @return
|
48
|
|
- */
|
49
|
|
- @RequestMapping(value="/taMetaImage",method= RequestMethod.GET)
|
50
|
|
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
51
|
|
- public ResponseBean taMetaImageList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
53
|
|
-
|
54
|
|
- IPage<TaMetaImage> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- QueryWrapper<TaMetaImage> queryWrapper = new QueryWrapper<>();
|
56
|
|
- queryWrapper.orderByDesc("create_date");
|
57
|
|
-
|
58
|
|
- IPage<TaMetaImage> result = iTaMetaImageService.page(pg, queryWrapper);
|
59
|
|
- return ResponseBean.success(result);
|
60
|
|
- }
|
61
|
49
|
|
|
50
|
+// /**
|
|
51
|
+// * 分页查询列表
|
|
52
|
+// * @param pageNum
|
|
53
|
+// * @param pageSize
|
|
54
|
+// * @return
|
|
55
|
+// */
|
|
56
|
+// @RequestMapping(value="/taMetaImage",method= RequestMethod.GET)
|
|
57
|
+// @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
|
58
|
+// public ResponseBean taMetaImageList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
59
|
+// @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
|
60
|
+//
|
|
61
|
+// IPage<TaMetaImage> pg = new Page<>(pageNum, pageSize);
|
|
62
|
+// QueryWrapper<TaMetaImage> queryWrapper = new QueryWrapper<>();
|
|
63
|
+// queryWrapper.orderByDesc("create_date");
|
|
64
|
+//
|
|
65
|
+// IPage<TaMetaImage> result = iTaMetaImageService.page(pg, queryWrapper);
|
|
66
|
+// return ResponseBean.success(result);
|
|
67
|
+// }
|
|
68
|
+//
|
62
|
69
|
/**
|
63
|
70
|
* 保存对象
|
64
|
71
|
* @param taMetaImage 实体对象
|
65
|
72
|
* @return
|
66
|
73
|
*/
|
67
|
|
- @RequestMapping(value="/taMetaImage",method= RequestMethod.POST)
|
|
74
|
+ @RequestMapping(value="/mp/taMetaImage",method= RequestMethod.POST)
|
68
|
75
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
69
|
|
- public ResponseBean taMetaImageAdd(@ApiParam("保存内容") @RequestBody TaMetaImage taMetaImage) throws Exception{
|
70
|
|
-
|
71
|
|
- if (iTaMetaImageService.save(taMetaImage)){
|
72
|
|
- return ResponseBean.success(taMetaImage);
|
73
|
|
- }else {
|
74
|
|
- return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
75
|
|
- }
|
76
|
|
- }
|
|
76
|
+ public ResponseBean taMetaImageAdd(@RequestParam("file") MultipartFile multipartFile) throws Exception{
|
77
|
77
|
|
78
|
|
- /**
|
79
|
|
- * 根据id删除对象
|
80
|
|
- * @param id 实体ID
|
81
|
|
- */
|
82
|
|
- @RequestMapping(value="/taMetaImage/{id}", method= RequestMethod.DELETE)
|
83
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
84
|
|
- public ResponseBean taMetaImageDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
85
|
|
- if(iTaMetaImageService.removeById(id)){
|
86
|
|
- return ResponseBean.success("success");
|
87
|
|
- }else {
|
88
|
|
- return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
89
|
|
- }
|
90
|
|
- }
|
|
78
|
+ try {
|
|
79
|
+ String image = ossUtils.putObject(multipartFile, "/shigongli/images/");
|
91
|
80
|
|
92
|
|
- /**
|
93
|
|
- * 修改对象
|
94
|
|
- * @param id 实体ID
|
95
|
|
- * @param taMetaImage 实体对象
|
96
|
|
- * @return
|
97
|
|
- */
|
98
|
|
- @RequestMapping(value="/taMetaImage/{id}",method= RequestMethod.PUT)
|
99
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
100
|
|
- public ResponseBean taMetaImageUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
101
|
|
- @ApiParam("更新内容") @RequestBody TaMetaImage taMetaImage) throws Exception{
|
|
81
|
+ TaMetaImage taMetaImage = new TaMetaImage();
|
|
82
|
+ taMetaImage.setImage(image);
|
102
|
83
|
|
103
|
|
- if (iTaMetaImageService.updateById(taMetaImage)){
|
104
|
|
- return ResponseBean.success(iTaMetaImageService.getById(id));
|
105
|
|
- }else {
|
106
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
84
|
+ iTaMetaImageService.save(taMetaImage);
|
|
85
|
+ return ResponseBean.success(taMetaImage);
|
|
86
|
+ } catch (IOException e) {
|
|
87
|
+ return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
|
107
|
88
|
}
|
108
|
|
- }
|
109
|
89
|
|
110
|
|
- /**
|
111
|
|
- * 根据id查询对象
|
112
|
|
- * @param id 实体ID
|
113
|
|
- */
|
114
|
|
- @RequestMapping(value="/taMetaImage/{id}",method= RequestMethod.GET)
|
115
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
116
|
|
- public ResponseBean taMetaImageGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
117
|
|
- return ResponseBean.success(iTaMetaImageService.getById(id));
|
118
|
90
|
}
|
|
91
|
+//
|
|
92
|
+// /**
|
|
93
|
+// * 根据id删除对象
|
|
94
|
+// * @param id 实体ID
|
|
95
|
+// */
|
|
96
|
+// @RequestMapping(value="/taMetaImage/{id}", method= RequestMethod.DELETE)
|
|
97
|
+// @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
98
|
+// public ResponseBean taMetaImageDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
99
|
+// if(iTaMetaImageService.removeById(id)){
|
|
100
|
+// return ResponseBean.success("success");
|
|
101
|
+// }else {
|
|
102
|
+// return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
103
|
+// }
|
|
104
|
+// }
|
|
105
|
+//
|
|
106
|
+// /**
|
|
107
|
+// * 修改对象
|
|
108
|
+// * @param id 实体ID
|
|
109
|
+// * @param taMetaImage 实体对象
|
|
110
|
+// * @return
|
|
111
|
+// */
|
|
112
|
+// @RequestMapping(value="/taMetaImage/{id}",method= RequestMethod.PUT)
|
|
113
|
+// @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
114
|
+// public ResponseBean taMetaImageUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
115
|
+// @ApiParam("更新内容") @RequestBody TaMetaImage taMetaImage) throws Exception{
|
|
116
|
+//
|
|
117
|
+// if (iTaMetaImageService.updateById(taMetaImage)){
|
|
118
|
+// return ResponseBean.success(iTaMetaImageService.getById(id));
|
|
119
|
+// }else {
|
|
120
|
+// return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
121
|
+// }
|
|
122
|
+// }
|
|
123
|
+//
|
|
124
|
+// /**
|
|
125
|
+// * 根据id查询对象
|
|
126
|
+// * @param id 实体ID
|
|
127
|
+// */
|
|
128
|
+// @RequestMapping(value="/taMetaImage/{id}",method= RequestMethod.GET)
|
|
129
|
+// @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
130
|
+// public ResponseBean taMetaImageGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
131
|
+// return ResponseBean.success(iTaMetaImageService.getById(id));
|
|
132
|
+// }
|
119
|
133
|
}
|