|
@@ -1,23 +1,31 @@
|
1
|
1
|
package com.yunzhi.marketing.xlk.controller;
|
2
|
2
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
3
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
5
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
6
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
7
|
import com.yunzhi.marketing.base.BaseController;
|
7
|
8
|
import com.yunzhi.marketing.base.ResponseBean;
|
|
9
|
+import com.yunzhi.marketing.common.StringUtils;
|
|
10
|
+import com.yunzhi.marketing.xlk.entity.Brand;
|
8
|
11
|
import com.yunzhi.marketing.xlk.entity.Video;
|
9
|
12
|
import com.yunzhi.marketing.xlk.service.IVideoService;
|
|
13
|
+import io.swagger.annotations.Api;
|
|
14
|
+import io.swagger.annotations.ApiOperation;
|
10
|
15
|
import org.slf4j.Logger;
|
11
|
16
|
import org.slf4j.LoggerFactory;
|
12
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
18
|
import org.springframework.web.bind.annotation.PathVariable;
|
14
|
19
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
20
|
+import org.springframework.web.bind.annotation.RequestHeader;
|
15
|
21
|
import org.springframework.web.bind.annotation.RequestMapping;
|
16
|
22
|
import org.springframework.web.bind.annotation.RequestMethod;
|
17
|
23
|
import org.springframework.web.bind.annotation.RequestParam;
|
18
|
24
|
import org.springframework.web.bind.annotation.ResponseBody;
|
19
|
25
|
import org.springframework.web.bind.annotation.RestController;
|
20
|
26
|
|
|
27
|
+import javax.servlet.http.HttpServletRequest;
|
|
28
|
+
|
21
|
29
|
/**
|
22
|
30
|
* <p>
|
23
|
31
|
* 视频表 前端控制器
|
|
@@ -28,6 +36,7 @@ import org.springframework.web.bind.annotation.RestController;
|
28
|
36
|
*/
|
29
|
37
|
@RestController
|
30
|
38
|
@RequestMapping("/api")
|
|
39
|
+@Api(value = "视频表", tags = "xlk-视频表")
|
31
|
40
|
public class VideoController extends BaseController {
|
32
|
41
|
|
33
|
42
|
private final Logger logger = LoggerFactory.getLogger(VideoController.class);
|
|
@@ -42,15 +51,20 @@ public class VideoController extends BaseController {
|
42
|
51
|
* @param pageSize
|
43
|
52
|
* @return
|
44
|
53
|
*/
|
45
|
|
- @RequestMapping(value="/video",method= RequestMethod.GET)
|
|
54
|
+ @ApiOperation(value = "视频列表", notes = "视频列表")
|
|
55
|
+ @RequestMapping(value="/admin/video",method= RequestMethod.GET)
|
46
|
56
|
public ResponseBean videoList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
47
|
|
- @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
57
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
58
|
+ @RequestParam(value ="name") String name,
|
|
59
|
+ @RequestHeader("authorization") String token, HttpServletRequest request){
|
48
|
60
|
ResponseBean responseBean = new ResponseBean();
|
49
|
61
|
try {
|
50
|
62
|
//使用分页插件
|
51
|
63
|
IPage<Video> pg = new Page<>(pageNum, pageSize);
|
52
|
|
- QueryWrapper<Video> queryWrapper = new QueryWrapper<>();
|
53
|
|
- queryWrapper.orderByDesc("create_date");
|
|
64
|
+ LambdaQueryWrapper<Video> queryWrapper = new LambdaQueryWrapper<>();
|
|
65
|
+ queryWrapper.eq(!StringUtils.isEmpty(name),Video::getName,name);
|
|
66
|
+ queryWrapper.eq(Video::getOrgId,getOrgId(request));
|
|
67
|
+ queryWrapper.orderByDesc(Video::getCreatedTime);
|
54
|
68
|
|
55
|
69
|
IPage<Video> result = iVideoService.page(pg, queryWrapper);
|
56
|
70
|
responseBean.addSuccess(result);
|
|
@@ -67,10 +81,12 @@ public class VideoController extends BaseController {
|
67
|
81
|
* @param video 实体对象
|
68
|
82
|
* @return
|
69
|
83
|
*/
|
|
84
|
+ @ApiOperation(value = "添加视频", notes = "添加视频")
|
70
|
85
|
@RequestMapping(value="/video",method= RequestMethod.POST)
|
71
|
|
- public ResponseBean videoAdd(@RequestBody Video video){
|
|
86
|
+ public ResponseBean videoAdd(@RequestBody Video video,@RequestHeader("authorization") String token, HttpServletRequest request){
|
72
|
87
|
ResponseBean responseBean = new ResponseBean();
|
73
|
88
|
try {
|
|
89
|
+ video.setOrgId(getOrgId(request));
|
74
|
90
|
if (iVideoService.save(video)){
|
75
|
91
|
responseBean.addSuccess(video);
|
76
|
92
|
}else {
|
|
@@ -88,6 +104,7 @@ public class VideoController extends BaseController {
|
88
|
104
|
* 根据id删除对象
|
89
|
105
|
* @param id 实体ID
|
90
|
106
|
*/
|
|
107
|
+ @ApiOperation(value = "根据id删除视频", notes = "根据id删除视频")
|
91
|
108
|
@ResponseBody
|
92
|
109
|
@RequestMapping(value="/video/{id}", method= RequestMethod.DELETE)
|
93
|
110
|
public ResponseBean videoDelete(@PathVariable Integer id){
|
|
@@ -112,6 +129,7 @@ public class VideoController extends BaseController {
|
112
|
129
|
* @param video 实体对象
|
113
|
130
|
* @return
|
114
|
131
|
*/
|
|
132
|
+ @ApiOperation(value = "根据id修改视频", notes = "根据id修改视频")
|
115
|
133
|
@RequestMapping(value="/video/{id}",method= RequestMethod.PUT)
|
116
|
134
|
public ResponseBean videoUpdate(@PathVariable Integer id,
|
117
|
135
|
@RequestBody Video video){
|
|
@@ -134,6 +152,7 @@ public class VideoController extends BaseController {
|
134
|
152
|
* 根据id查询对象
|
135
|
153
|
* @param id 实体ID
|
136
|
154
|
*/
|
|
155
|
+ @ApiOperation(value = "根据id查询详情", notes = "根据id查询详情")
|
137
|
156
|
@RequestMapping(value="/video/{id}",method= RequestMethod.GET)
|
138
|
157
|
public ResponseBean videoGet(@PathVariable Integer id){
|
139
|
158
|
ResponseBean responseBean = new ResponseBean();
|