admin
2021-04-08 d7a3014c38dbb1061cba70e7dbb49d58831e6399
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
package com.yeshi.buwan.controller.api;
 
import java.io.IOException;
import java.io.PrintWriter;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
 
import com.yeshi.buwan.controller.parser.web.WebFindParser;
import com.yeshi.buwan.controller.parser.web.WebHomeParser;
import com.yeshi.buwan.controller.parser.web.WebUserParser;
import com.yeshi.buwan.controller.parser.web.WebVideosParser;
import com.yeshi.buwan.util.VerifyCodeUtil;
 
@Controller
@RequestMapping("/web/api/v1")
public class WebApiControllerV1 {
 
    @Resource
    private WebHomeParser webHomeParser;
    @Resource
    private WebVideosParser webVideoParser;
    @Resource
    private WebFindParser webFindParser;
 
    @Resource
    private WebUserParser webUserParser;
 
    // 获取网页首页信息
    @RequestMapping(value = "/home", method = RequestMethod.POST)
    public void home(HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        String uid = request.getParameter("Uid");
        if ("getHomePage".equalsIgnoreCase(method)) {
            webHomeParser.getHomePage(uid, request, out);
        } else if ("getClass".equalsIgnoreCase(method)) {
            webHomeParser.getClass(uid, request, out);
        } else if ("getCategoryRecommend".equalsIgnoreCase(method)) {
            webHomeParser.getCategoryRecommend(uid, request, out);
        } else if ("getTopHotStars".equalsIgnoreCase(method)) {
            webHomeParser.getTopHotStars(uid, request, out);
        } else if ("getTopTypePlayVideos".equalsIgnoreCase(method)) {
            webHomeParser.getTopTypePlayVideos(uid, request, out);
        } else if ("getHotStarList".equalsIgnoreCase(method)) {
            webHomeParser.getHotStarList(uid, request, out);
        } else if ("getSpecialList".equalsIgnoreCase(method)) {
            webHomeParser.getSpecialList(uid, request, out);
        }
 
        out.close();
    }
 
    // 获取网页首页信息
    @RequestMapping(value = "/videos", method = RequestMethod.POST)
    public void videos(HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        String uid = request.getParameter("Uid");
        if ("getVideoList".equalsIgnoreCase(method)) {
            webVideoParser.getVideoList(uid, request, out);
        } else if ("getVideoDetail".equalsIgnoreCase(method)) {
            webVideoParser.getVideoDetail(uid, request, out);
        } else if ("getRecommendVideos".equalsIgnoreCase(method)) {
            webVideoParser.getRecommendVideos(uid, request, out);
        } else if ("getPlayUrl".equalsIgnoreCase(method)) {
            webVideoParser.getPlayUrl(uid, request, out);
        }
        out.close();
    }
 
    @RequestMapping(value = "/find", method = RequestMethod.POST)
    public void find(HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        String uid = request.getParameter("Uid");
        if ("getSpecialDetail".equalsIgnoreCase(method)) {
            webFindParser.getSpecialDetail(uid, request, out);
        } else if ("getStarDetail".equalsIgnoreCase(method)) {
            webFindParser.getStarDetail(uid, request, out);
        }
        out.close();
    }
 
    @RequestMapping(value = "/user", method = RequestMethod.POST)
    public void user(HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        String uid = request.getParameter("Uid");
        if ("suggestSearch".equalsIgnoreCase(method)) {
            webUserParser.suggestSearch(uid, request, out);
        } else if ("search".equalsIgnoreCase(method)) {
            webUserParser.search(uid, request, out);
        } else if ("thirdlogin".equalsIgnoreCase(method)) {
            webUserParser.thirdlogin(uid, request, out);
        } else if ("login".equalsIgnoreCase(method)) {
            webUserParser.login(uid, request, out);
        }else if ("sendVerifyCode".equalsIgnoreCase(method)) {
            webUserParser.sendVerifyCode(uid, request, out);
        } else if ("register".equalsIgnoreCase(method)) {
            webUserParser.register(uid, request, out);
        } else if ("setPwd".equalsIgnoreCase(method)) {
            webUserParser.setPwd(uid, request, out);
        } else if ("getUserInfo".equalsIgnoreCase(method)) {
            webUserParser.getUserInfo(uid, request, out);
        } else if ("updateUserInfo".equalsIgnoreCase(method)) {
            webUserParser.updateUserInfo(uid, request, out);
        } else if ("getAttentionList".equalsIgnoreCase(method)) {
            webUserParser.getAttentionList(uid, request, out);
        } else if ("addAttention".equalsIgnoreCase(method)) {
            webUserParser.addAttention(uid, request, out);
        } else if ("cancelAttention".equalsIgnoreCase(method)) {
            webUserParser.cancelAttention(uid, request, out);
        } else if ("getVideoCommentList".equalsIgnoreCase(method)) {
            webUserParser.getVideoCommentList(uid, request, out);
        } else if ("comment".equalsIgnoreCase(method)) {
            webUserParser.comment(uid, request, out);
        } else if ("getMyCommentReply".equalsIgnoreCase(method)) {
            webUserParser.getMyCommentReply(uid, request, out);
        } else if ("replayComment".equalsIgnoreCase(method)) {
            webUserParser.replayComment(uid, request, out);
        }
        out.close();
    }
 
    // 生成图片验证码
    @RequestMapping(value = "/imgcode", method = RequestMethod.GET)
    public void imgCode(HttpServletRequest request, HttpServletResponse response) {
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setContentType("image/jpeg");
 
        String code = request.getParameter("Code");
        String width = request.getParameter("Width");
        String height = request.getParameter("Height");
        // 生成图片
        int w = Integer.parseInt(width), h = Integer.parseInt(height);
        try {
            VerifyCodeUtil.outputImage(w, h, response.getOutputStream(), code);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
}