admin
2020-08-22 813d2cae75cbae3f216de5f493af643c5a560c82
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
package com.yeshi.buwan.web.action;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.stereotype.Controller;
 
import com.opensymphony.xwork2.ActionSupport;
import com.yeshi.buwan.domain.AdminInfo;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoIntersection;
import com.yeshi.buwan.domain.VideoIntersectionVideo;
import com.yeshi.buwan.service.imp.IntersectionService;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.web.tag.PageEntity;
@Controller
public class VideoIntersectionAction extends ActionSupport implements ServletRequestAware {
    @Resource
    private IntersectionService intersectionService;
 
    public IntersectionService getIntersectionService() {
        return intersectionService;
    }
 
    public void setIntersectionService(IntersectionService intersectionService) {
        this.intersectionService = intersectionService;
    }
 
    HttpServletRequest request;
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    /**
     * 合辑列表
     * 
     * @return
     */
    public String intersectionList() {
        key = StringUtil.isNullOrEmpty(key) ? "" : key;
        pageIndex = pageIndex <= 0 ? 1 : pageIndex;
        List<VideoIntersection> list = intersectionService.getIntersectionList(key, pageIndex);
        long count = intersectionService.getIntersectionListCount(key);
        PageEntity page = new PageEntity();
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        page.setParams(map);
        page.setPageIndex(pageIndex);
        page.setTotalCount((int) count);
        request.setAttribute("pageEntity", page);
        request.setAttribute("intersectionList", list);
        return SUCCESS;
    }
 
    /**
     * 合集视频列表
     * 
     * @return
     */
    public String intersectionVideoList() {
        String intersectionId = request.getParameter("id");// 合辑ID
        if (StringUtil.isNullOrEmpty(intersectionId))
            intersectionId = (String) request.getAttribute("id");
        key = StringUtil.isNullOrEmpty(key) ? "" : key;
        pageIndex = pageIndex <= 0 ? 1 : pageIndex;
        List<VideoIntersectionVideo> list = intersectionService.getIntersectionVideoListByInersection(intersectionId,
                key, pageIndex);
        long count = intersectionService.getIntersectionVideoListByInersectionCount(intersectionId, key);
 
        PageEntity page = new PageEntity();
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        map.put("id", intersectionId);
        page.setParams(map);
        page.setPageIndex(pageIndex);
        page.setTotalCount((int) count);
        request.setAttribute("pageEntity", page);
        request.setAttribute("videoList", list);
        return SUCCESS;
    }
 
    /**
     * 添加合集视频
     * 
     * @return
     */
    public String addIntersectionVideo() {
        String videoIds = request.getParameter("videoIds");
        String intersectionIds = request.getParameter("intersectionIds");
        List<String> videoList = new ArrayList<String>();
        List<String> intersectionList = new ArrayList<String>();
        String[] videoIdSts = videoIds.split(",");
        String[] intersectionIdSts = intersectionIds.split(",");
        for (String vi : videoIdSts) {
            if (!StringUtil.isNullOrEmpty(vi))
                videoList.add(vi);
        }
 
        for (String ht : intersectionIdSts) {
            if (!StringUtil.isNullOrEmpty(ht))
                intersectionList.add(ht);
        }
 
        AdminInfo admin = (AdminInfo) request.getSession().getAttribute("ADMIN_USER");
 
        for (String intersection : intersectionList)
            for (String video : videoList) {
                VideoIntersectionVideo viv = new VideoIntersectionVideo();
                viv.setCreatetime(System.currentTimeMillis() + "");
                viv.setIntersection(new VideoIntersection(intersection));
                viv.setVideo(new VideoInfo(video));
                intersectionService.addIntersectionVideo(viv);
            }
 
        return SUCCESS;
    }
 
    /**
     * 删除合集视频
     * 
     * @return
     */
    public String deleteIntersectionVideo() {
        String id = request.getParameter("id");
        VideoIntersectionVideo vs = intersectionService.getIntersectionVideoById(id);
        request.setAttribute("id", vs.getIntersection().getId());
        intersectionService.deleteIntersectionVideo(new VideoIntersectionVideo(id));
        return SUCCESS;
    }
 
    /**
     * 批量删除合集视频
     * 
     * @return
     */
    public String deleteListIntersectionVideo() {
        String urls = request.getParameter("url");
        String[] ids = urls.split(",");
        if (ids != null) {
            VideoIntersectionVideo vs = intersectionService.getIntersectionVideoById(ids[0]);
            request.setAttribute("id", vs.getIntersection().getId());
            for (String id : ids) {
                if (!StringUtil.isNullOrEmpty(id)) {
                    intersectionService.deleteIntersectionVideo(new VideoIntersectionVideo(id));
                }
            }
 
        }
        return SUCCESS;
    }
 
    /**
     * 修改视频信息
     * 
     * @return
     */
    public String updateIntersection() {
        VideoIntersection vs = intersectionService.getIntersectionById(id);
        vs.setName(StringUtil.getUTF8String(name, "iso-8859-1"));
        intersectionService.updateIntersection(vs);
        request.setAttribute("intersection", vs);
        return SUCCESS;
    }
 
    /**
     * 获取视频详情
     * 
     * @return
     */
    public String getIntersection() {
        VideoIntersection vs = intersectionService.getIntersectionById(id);
        request.setAttribute("intersection", vs);
        return SUCCESS;
    }
 
    /**
     * 添加视频
     * 
     * @return
     */
    public String addIntersection() {
        VideoIntersection vs = new VideoIntersection();
        vs.setName(StringUtil.getUTF8String(name, "iso-8859-1"));
        vs.setCreatetime(System.currentTimeMillis() + "");
        intersectionService.addIntersection(vs);
        return SUCCESS;
    }
 
    /**
     * 删除视频
     * 
     * @return
     */
    public String deleteIntersection() {
        intersectionService.deleteIntersection(new VideoIntersection(id));
        return SUCCESS;
    }
 
    public String deleteListIntersection() {
        String urls = request.getParameter("url");
        String[] ids = urls.split(",");
        if (ids != null) {
            for (String idSt : ids)
                intersectionService.deleteIntersection(new VideoIntersection(idSt));
 
        }
        return SUCCESS;
    }
 
    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }
 
    /**
     * page信息
     */
    private String key;
    private int pageIndex;
 
    public String getKey() {
        return key;
    }
 
    public void setKey(String key) {
        this.key = key;
    }
 
    public int getPageIndex() {
        return pageIndex;
    }
 
    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }
 
    /**
     * 实体
     */
    private String id;
    private String name;
    private String beizhu;
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getBeizhu() {
        return beizhu;
    }
 
    public void setBeizhu(String beizhu) {
        this.beizhu = beizhu;
    }
 
}