|
@@ -0,0 +1,104 @@
|
|
1
|
+package com.yunzhi.demo.controller;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
5
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
6
|
+import com.yunzhi.demo.common.BaseController;
|
|
7
|
+import com.yunzhi.demo.common.Constants;
|
|
8
|
+import com.yunzhi.demo.common.ResponseBean;
|
|
9
|
+import com.yunzhi.demo.common.StringUtils;
|
|
10
|
+import io.swagger.annotations.Api;
|
|
11
|
+import io.swagger.annotations.ApiOperation;
|
|
12
|
+import io.swagger.annotations.ApiParam;
|
|
13
|
+import org.slf4j.Logger;
|
|
14
|
+import org.slf4j.LoggerFactory;
|
|
15
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
16
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
17
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
18
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
19
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
20
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
21
|
+import com.yunzhi.demo.service.ITaShareSettingService;
|
|
22
|
+import com.yunzhi.demo.entity.TaShareSetting;
|
|
23
|
+import org.springframework.web.bind.annotation.RestController;
|
|
24
|
+
|
|
25
|
+/**
|
|
26
|
+ * <p>
|
|
27
|
+ * 分享设置 前端控制器
|
|
28
|
+ * </p>
|
|
29
|
+ *
|
|
30
|
+ * @author yansen
|
|
31
|
+ * @since 2021-04-25
|
|
32
|
+ */
|
|
33
|
+
|
|
34
|
+@Api(tags = "分享设置 ")
|
|
35
|
+@RestController
|
|
36
|
+@RequestMapping("/")
|
|
37
|
+public class TaShareSettingController extends BaseController {
|
|
38
|
+
|
|
39
|
+ private final Logger logger = LoggerFactory.getLogger(TaShareSettingController.class);
|
|
40
|
+
|
|
41
|
+ @Autowired
|
|
42
|
+ public ITaShareSettingService iTaShareSettingService;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ /**
|
|
46
|
+ * 保存对象
|
|
47
|
+ * @param taShareSetting 实体对象
|
|
48
|
+ * @return
|
|
49
|
+ */
|
|
50
|
+ @RequestMapping(value="/admin/share-setting",method= RequestMethod.POST)
|
|
51
|
+ @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
52
|
+ public ResponseBean taShareSettingAdd(@ApiParam("保存内容") @RequestBody TaShareSetting taShareSetting) throws Exception {
|
|
53
|
+ if (StringUtils.isEmpty(taShareSetting.getTargetId())) {
|
|
54
|
+ throw new Exception("未设置分享对象");
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ if (StringUtils.isEmpty(taShareSetting.getTargetType())) {
|
|
58
|
+ taShareSetting.setTargetType(Constants.RESOURCE_TYPE_POST);
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ if (iTaShareSettingService.save(taShareSetting)){
|
|
62
|
+ return ResponseBean.success(taShareSetting);
|
|
63
|
+ }else {
|
|
64
|
+ return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ /**
|
|
69
|
+ * 修改对象
|
|
70
|
+ * @param id 实体ID
|
|
71
|
+ * @param taShareSetting 实体对象
|
|
72
|
+ * @return
|
|
73
|
+ */
|
|
74
|
+ @RequestMapping(value="/admin/share-setting/{id}",method= RequestMethod.PUT)
|
|
75
|
+ @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
76
|
+ public ResponseBean taShareSettingUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
77
|
+ @ApiParam("更新内容") @RequestBody TaShareSetting taShareSetting) throws Exception{
|
|
78
|
+ if (StringUtils.isEmpty(taShareSetting.getTargetId())) {
|
|
79
|
+ throw new Exception("未设置分享对象");
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ if (StringUtils.isEmpty(taShareSetting.getTargetType())) {
|
|
83
|
+ taShareSetting.setTargetType(Constants.RESOURCE_TYPE_POST);
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ taShareSetting.setSerialNo(id);
|
|
87
|
+
|
|
88
|
+ if (iTaShareSettingService.updateById(taShareSetting)){
|
|
89
|
+ return ResponseBean.success(iTaShareSettingService.getById(id));
|
|
90
|
+ }else {
|
|
91
|
+ return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
92
|
+ }
|
|
93
|
+ }
|
|
94
|
+
|
|
95
|
+// /**
|
|
96
|
+// * 根据id查询对象
|
|
97
|
+// * @param id 实体ID
|
|
98
|
+// */
|
|
99
|
+// @RequestMapping(value="/admin/share-setting/{id}",method= RequestMethod.GET)
|
|
100
|
+// @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
101
|
+// public ResponseBean taShareSettingGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
102
|
+// return ResponseBean.success(iTaShareSettingService.getById(id));
|
|
103
|
+// }
|
|
104
|
+}
|