VideosController.java
5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.cnlive.shenhe.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cnlive.shenhe.bean.ErrorEnum;
import com.cnlive.shenhe.bean.ResponseBean;
import com.cnlive.shenhe.bean.SessionUser;
import com.cnlive.shenhe.entity.ShyUsers;
import com.cnlive.shenhe.entity.ShyVideos;
import com.cnlive.shenhe.serviceImpl.UsersServiceImpl;
import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
import com.cnlive.shenhe.utils.AuditPass;
import com.cnlive.shenhe.utils.CommonConst;
import com.cnlive.shenhe.utils.CommonUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping("/videos")
public class VideosController {
@Autowired
AuditPass Pass;
@Autowired
VideosServiceImpl videosService;
@Autowired
UsersServiceImpl usersService;
@RequestMapping("/index")
public String index(HttpSession session, Model model) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
ShyUsers shyUsers = new ShyUsers();
shyUsers.setUser_id(sessionUser.getUserId());
shyUsers = usersService.select(shyUsers);
JSONObject user = new JSONObject();
user.put("name", shyUsers.getUsername());
user.put("company", shyUsers.getCompany_brief());
user.put("spid", shyUsers.getSp_id());
model.addAttribute("user", user);
return "page/video.html";
}
/**
* 审核信息返回接口
*
* @param activity_id 视频id
* @param state 状态码
* @param attr_tags 标签
* @param msg 备注信息
* @return
*/
@PostMapping("/shenheVideo")
@ResponseBody
public ResponseBean shenheInfo(Integer id, String activity_id, Integer state, String attr_tags, String msg, String callback, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
String userId = sessionUser.getUserId();
JSONObject result = null;
try {
result = Pass.auditPass(activity_id, state, attr_tags, msg, callback);
} catch (Exception e) {
e.printStackTrace();
System.out.println("视频审核失败");
return new ResponseBean(ErrorEnum.ERROR);
}
if (result == null) {
System.out.println("视频审核失败且接口错误没有返回信息");
return new ResponseBean(ErrorEnum.ERROR);
}
Integer code = result.getInteger("code");
if (code != 0) {
System.out.println("审核失败,code==" + code);
return new ResponseBean(code, result.getString("msg"));
}
state = state == 4 ? 2 : 1;
int i = videosService.updateVideo(id, userId, state, msg);
if (i == 0) {
return new ResponseBean(ErrorEnum.ERROR);
}
return new ResponseBean(ErrorEnum.SUCCESS);
}
/**
* 内容分页列表接口
*
* @param video_title
* @param start_date
* @param end_date
* @param state
* @param page
* @param pageSize
* @param orderByClause
* @return
*/
@GetMapping("/page")
public Object getListVideos(Model model, String video_title, String start_date, String end_date, Integer state, Integer page, Integer pageSize, String video_priority, String orderByClause, HttpSession session) {
SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
Integer spid = sessionUser.getSpid();
if (CommonUtils.isNull(page)) page = 1;
if (CommonUtils.isNull(pageSize)) pageSize = 10;
if (CommonUtils.isNotNull(spid) && spid == 0) {
spid = 82;
}
PageInfo<ShyVideos> videoPage = videosService.getListContent(video_title, start_date, end_date, state, page, pageSize, video_priority, orderByClause, spid);
List<ShyVideos> list = videoPage.getList();
if (!list.isEmpty()) {
for (ShyVideos videos : list) {
if (videos.getState() != CommonConst.AUDIT_INTT) {
String auditor = "白名单";
String auditor_id = videos.getAuditor_id();
if (CommonUtils.isNotEmpty(auditor_id)) {
ShyUsers user = new ShyUsers();
user.setUser_id(auditor_id);
user = usersService.select(user);
if (CommonUtils.isNotNull(user)) auditor = user.getUsername() + user.getEmail();
}
videos.setAuditor(auditor);
}
}
}
model.addAttribute("videoPage", videoPage);
return "page/video.html";
}
/**
* 内容详情页接口(查看)
*
* @param id
* @return
*/
@GetMapping("/details")
public Object getDetailsVideo(Model model, Integer id) {
ShyVideos detailsContent = videosService.getDetailsContent(id);
Object images = JSON.parse(detailsContent.getVideo_imgs());
model.addAttribute("images", images);
model.addAttribute("video", detailsContent);
return "page/videoDetail.html";
}
}