|
@@ -4,7 +4,10 @@ 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.yunzhi.demo.common.BaseController;
|
|
7
|
+import com.yunzhi.demo.common.Constants;
|
7
|
8
|
import com.yunzhi.demo.common.ResponseBean;
|
|
9
|
+import com.yunzhi.demo.common.StringUtils;
|
|
10
|
+import com.yunzhi.demo.entity.TaPost;
|
8
|
11
|
import io.swagger.annotations.Api;
|
9
|
12
|
import io.swagger.annotations.ApiOperation;
|
10
|
13
|
import io.swagger.annotations.ApiParam;
|
|
@@ -59,6 +62,26 @@ public class SysBannerController extends BaseController {
|
59
|
62
|
return ResponseBean.success(result);
|
60
|
63
|
}
|
61
|
64
|
|
|
65
|
+ /**
|
|
66
|
+ * 分页查询列表
|
|
67
|
+ * @param pageNum
|
|
68
|
+ * @param pageSize
|
|
69
|
+ * @return
|
|
70
|
+ */
|
|
71
|
+ @RequestMapping(value="/admin/banner",method= RequestMethod.GET)
|
|
72
|
+ @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
|
73
|
+ public ResponseBean bannerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
74
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
75
|
+ @ApiParam("标题") @RequestParam(value = "title", required = false) String title) throws Exception{
|
|
76
|
+
|
|
77
|
+ IPage<SysBanner> pg = new Page<>(pageNum, pageSize);
|
|
78
|
+ QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>().like(!StringUtils.isEmpty(title), "title", title);
|
|
79
|
+ queryWrapper.orderByDesc("create_date");
|
|
80
|
+
|
|
81
|
+ IPage<SysBanner> result = iSysBannerService.page(pg, queryWrapper);
|
|
82
|
+ return ResponseBean.success(result);
|
|
83
|
+ }
|
|
84
|
+
|
62
|
85
|
/**
|
63
|
86
|
* 保存对象
|
64
|
87
|
* @param sysBanner 实体对象
|
|
@@ -75,6 +98,22 @@ public class SysBannerController extends BaseController {
|
75
|
98
|
}
|
76
|
99
|
}
|
77
|
100
|
|
|
101
|
+ /**
|
|
102
|
+ * 保存对象
|
|
103
|
+ * @param sysBanner 实体对象
|
|
104
|
+ * @return
|
|
105
|
+ */
|
|
106
|
+ @RequestMapping(value="/admin/banner",method= RequestMethod.POST)
|
|
107
|
+ @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
108
|
+ public ResponseBean bannerAdd(@ApiParam("保存内容") @RequestBody SysBanner sysBanner) throws Exception{
|
|
109
|
+
|
|
110
|
+ if (iSysBannerService.save(sysBanner)){
|
|
111
|
+ return ResponseBean.success(sysBanner);
|
|
112
|
+ }else {
|
|
113
|
+ return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
114
|
+ }
|
|
115
|
+ }
|
|
116
|
+
|
78
|
117
|
/**
|
79
|
118
|
* 根据id删除对象
|
80
|
119
|
* @param id 实体ID
|
|
@@ -89,6 +128,20 @@ public class SysBannerController extends BaseController {
|
89
|
128
|
}
|
90
|
129
|
}
|
91
|
130
|
|
|
131
|
+ /**
|
|
132
|
+ * 根据id删除对象
|
|
133
|
+ * @param id 实体ID
|
|
134
|
+ */
|
|
135
|
+ @RequestMapping(value="/admin/banner/{id}", method= RequestMethod.DELETE)
|
|
136
|
+ @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
137
|
+ public ResponseBean bannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
138
|
+ if(iSysBannerService.removeById(id)){
|
|
139
|
+ return ResponseBean.success("success");
|
|
140
|
+ }else {
|
|
141
|
+ return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
142
|
+ }
|
|
143
|
+ }
|
|
144
|
+
|
92
|
145
|
/**
|
93
|
146
|
* 修改对象
|
94
|
147
|
* @param id 实体ID
|
|
@@ -107,6 +160,24 @@ public class SysBannerController extends BaseController {
|
107
|
160
|
}
|
108
|
161
|
}
|
109
|
162
|
|
|
163
|
+ /**
|
|
164
|
+ * 修改对象
|
|
165
|
+ * @param id 实体ID
|
|
166
|
+ * @param sysBanner 实体对象
|
|
167
|
+ * @return
|
|
168
|
+ */
|
|
169
|
+ @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.PUT)
|
|
170
|
+ @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
171
|
+ public ResponseBean bannerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
172
|
+ @ApiParam("更新内容") @RequestBody SysBanner sysBanner) throws Exception{
|
|
173
|
+
|
|
174
|
+ if (iSysBannerService.updateById(sysBanner)){
|
|
175
|
+ return ResponseBean.success(iSysBannerService.getById(id));
|
|
176
|
+ }else {
|
|
177
|
+ return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
178
|
+ }
|
|
179
|
+ }
|
|
180
|
+
|
110
|
181
|
/**
|
111
|
182
|
* 根据id查询对象
|
112
|
183
|
* @param id 实体ID
|
|
@@ -116,4 +187,14 @@ public class SysBannerController extends BaseController {
|
116
|
187
|
public ResponseBean sysBannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
117
|
188
|
return ResponseBean.success(iSysBannerService.getById(id));
|
118
|
189
|
}
|
|
190
|
+
|
|
191
|
+ /**
|
|
192
|
+ * 根据id查询对象
|
|
193
|
+ * @param id 实体ID
|
|
194
|
+ */
|
|
195
|
+ @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.GET)
|
|
196
|
+ @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
197
|
+ public ResponseBean bannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
198
|
+ return ResponseBean.success(iSysBannerService.getById(id));
|
|
199
|
+ }
|
119
|
200
|
}
|