-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisplayController.java
More file actions
172 lines (147 loc) · 5.35 KB
/
DisplayController.java
File metadata and controls
172 lines (147 loc) · 5.35 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.Properties;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import entity.User;
import entity.Video;
import service.IDisplayService;
import service.IUserService;
@Controller
public class DisplayController {
private IUserService userService;
private IDisplayService displayService;
public IUserService getUserService() {
return userService;
}
@Resource
public void setUserService(IUserService userService) {
this.userService = userService;
}
public IDisplayService getDisplayService() {
return displayService;
}
@Resource
public void setIDisplayService(IDisplayService displayService) {
this.displayService = displayService;
}
@RequestMapping(value = "/addPlayOne", method = RequestMethod.POST)
public void addPlayOne(@RequestParam String videoid,HttpServletRequest req,HttpServletResponse resp) throws IOException {
req.setCharacterEncoding("utf-8");
PrintWriter out=resp.getWriter();
out.print(displayService.updateVideoPlay(videoid));
}
@RequestMapping(value = "/typeTop", method = RequestMethod.POST)
public @ResponseBody void typeTop(String typeid,HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.TypeTopLimit(typeid);
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/topFirst", method = RequestMethod.POST)
public @ResponseBody void topFirst(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.TopPlayByType();
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/ranLimit", method = RequestMethod.POST)
public @ResponseBody void ranLimit(String typeid,HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.TypeRanLimit(typeid);
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/searchHot", method = RequestMethod.POST)
public @ResponseBody void hotPlay(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.PlayDescLimit();
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/playTop", method = RequestMethod.POST)
public @ResponseBody void playTop(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.PlayDescLimit();
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/collTop", method = RequestMethod.POST)
public @ResponseBody void collTop(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
List<Video> videos=displayService.CollDescLimit();
JSONArray ja = new JSONArray();
for(Video vi:videos){
JSONObject jo = JSONObject.fromObject(vi);
ja.add(jo);
}
resp.getWriter().print(ja);
}
@RequestMapping(value = "/playVideoAuthor", method = RequestMethod.POST)
public @ResponseBody User playVideoAuthor(String userid,HttpServletRequest req, HttpServletResponse resp)
throws IOException {
User user = userService.getUser(userid);
return user;
}
@RequestMapping(value = "/whereareufrom", method = RequestMethod.POST)
public void whereareufrom(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
Properties props=System.getProperties();
resp.getWriter().print(props.getProperty("os.name"));
}
@RequestMapping(value = "/userinfotop", method = RequestMethod.POST)
public @ResponseBody User userinfotop(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
User user = (User) req.getSession().getAttribute("user");
return user;
}
@RequestMapping(value = "/userlogout", method = RequestMethod.GET)
public String userlogout(HttpServletRequest req, HttpServletResponse resp) {
req.getSession().invalidate();
return "redirect:/index.html";
}
@RequestMapping(value = "/userindex", method = RequestMethod.GET)
public String userindex(HttpServletRequest req, HttpServletResponse resp) {
return "redirect:/index.html";
}
@RequestMapping(value = "/userLoginindex", method = RequestMethod.GET)
public String userLoginindex(HttpServletRequest req, HttpServletResponse resp) {
return "redirect:/user_login.html";
}
}