admin
2021-01-23 0a18a8cb0a7a57bf1f82df425251334c57f8c39a
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
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.HomeType;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoResource;
import com.yeshi.buwan.domain.VideoType;
import com.yeshi.buwan.domain.special.Special;
import com.yeshi.buwan.service.imp.ClassService;
import com.yeshi.buwan.service.imp.HomeTypeService;
import com.yeshi.buwan.service.imp.SpecialService;
import com.yeshi.buwan.service.imp.VideoManager;
import com.yeshi.buwan.service.imp.VideoResourceService;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.web.tag.PageEntity;
 
@Controller
public class VideosAction extends ActionSupport implements ServletRequestAware {
    @Resource
    private VideoManager videoManager;
    @Resource
    private ClassService classService;
    @Resource
    private HomeTypeService homeTypeService;
    @Resource
    private SpecialService specialService;
    @Resource
    private VideoResourceService videoResourceService;
 
    public VideoResourceService getVideoResourceService() {
        return videoResourceService;
    }
 
    public void setVideoResourceService(VideoResourceService videoResourceService) {
        this.videoResourceService = videoResourceService;
    }
 
    public VideoManager getVideoManager() {
        return videoManager;
    }
 
    public void setVideoManager(VideoManager videoManager) {
        this.videoManager = videoManager;
    }
 
    public ClassService getClassService() {
        return classService;
    }
 
    public void setClassService(ClassService classService) {
        this.classService = classService;
    }
 
    public HomeTypeService getHomeTypeService() {
        return homeTypeService;
    }
 
    public void setHomeTypeService(HomeTypeService homeTypeService) {
        this.homeTypeService = homeTypeService;
    }
 
    public SpecialService getSpecialService() {
        return specialService;
    }
 
    public void setSpecialService(SpecialService specialService) {
        this.specialService = specialService;
    }
 
    HttpServletRequest request;
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    /**
     * 视频列表
     * 
     * @return
     */
    public String videoList() {
        videoType = StringUtil.isNullOrEmpty(videoType) ? "" : videoType;
        videoType = videoType.equalsIgnoreCase("0") ? "" : videoType;
 
        contenttype = StringUtil.isNullOrEmpty(contenttype) ? "0" : contenttype;
        key = StringUtil.isNullOrEmpty(key) ? "" : key;
        key = StringUtil.getUTF8String(key, "iso-8859-1");
        pageIndex = pageIndex <= 0 ? 1 : pageIndex;
 
        List<VideoInfo> list = classService.getTypeVideoListAdmin(videoType, pageIndex, key,
                Integer.parseInt(contenttype));
        long count = classService.getTypeVideoListAdminCount(videoType, key, Integer.parseInt(contenttype));
        PageEntity page = new PageEntity();
        Map<String, String> map = new HashMap<String, String>();
        map.put("videoType", videoType.equalsIgnoreCase("") ? "0" : videoType);
        map.put("key", key);
        map.put("contenttype", contenttype);
        page.setParams(map);
        page.setPageIndex(pageIndex);
        page.setTotalCount((int) count);
        request.setAttribute("pageEntity", page);
        request.setAttribute("videoList", list);
        // 读取所有的推荐分类
        List<HomeType> homeTypeList = homeTypeService.getHomeType();
        request.setAttribute("homeTypeList", homeTypeList);
 
        List<Special> specialList = specialService.getSpecialList();
        request.setAttribute("specialList", specialList);
 
        return SUCCESS;
    }
 
    /**
     * 修改视频信息
     * 
     * @return
     */
    public String updateVideo() {
        // String videoTypes = request.getParameter("videotypes");
        // videoTypes = StringUtil.isNullOrEmpty(videoTypes) ? "" : videoTypes;
        // String[] typeIds = videoTypes.split(",");
        // List<VideoType> typeList = new ArrayList<VideoType>();
        // for (String st : typeIds) {
        // typeList.add(new VideoType(Long.parseLong(st)));
        // }
 
        VideoInfo info = videoManager.getVideoInfo(id);
        info.setBeizhu(StringUtil.getUTF8String(beizhu, "iso-8859-1"));
        info.setName(StringUtil.getUTF8String(name, "iso-8859-1"));
        info.setDuration(duration);
        info.setIntroduction(StringUtil.getUTF8String(introduction, "iso-8859-1"));
        info.setMainActor(StringUtil.getUTF8String(mainActor, "iso-8859-1"));
        info.setOrderby(orderby);
        info.setYear(year);
        info.setMonth(month);
        info.setDay(day);
        info.setArea(StringUtil.getUTF8String(area, "iso-8859-1"));
        // info.setVideoType(new VideoType(Long.parseLong(videoType)));
        if (!StringUtil.isNullOrEmpty(picture))
            info.setPicture(picture);
        info.setScore(score);
        if (StringUtil.isNullOrEmpty(show)) {
            info.setShow("0");
        } else
            info.setShow("1");
        info.setTag(StringUtil.getUTF8String(tag, "iso-8859-1"));
        videoManager.updateVideoInfo(info);
        // if (typeList != null && typeList.size() > 0)
        // classService.updateVideoTypes(info.getId(), typeList);
        request.setAttribute("videoId", id);
        request.setAttribute("id", id);
 
        return SUCCESS;
    }
 
    /**
     * 获取视频详情
     * 
     * @return
     */
    public String getVideo() {
 
        VideoInfo video = videoManager.getVideoInfo(id);
        video.setTypeList(classService.getVideoTypeList(video.getId()));
        request.setAttribute("videoInfo", video);
        return SUCCESS;
    }
 
    /**
     * 添加视频
     * 
     * @return
     */
    public String addVideo() {
        String videoTypes = request.getParameter("videotypes");
        String[] typeIds = videoTypes.split(",");
        List<VideoType> typeList = new ArrayList<VideoType>();
        for (String st : typeIds) {
            typeList.add(new VideoType(Long.parseLong(st)));
        }
 
        AdminInfo admin = (AdminInfo) request.getSession().getAttribute("ADMIN_USER");
 
        VideoInfo info = new VideoInfo();
        info.setBeizhu(StringUtil.getUTF8String(beizhu, "iso-8859-1"));
        info.setName(StringUtil.getUTF8String(name, "iso-8859-1"));
        info.setDuration(duration);
        info.setIntroduction(StringUtil.getUTF8String(introduction, "iso-8859-1"));
        info.setMainActor(StringUtil.getUTF8String(mainActor, "iso-8859-1"));
        info.setOrderby(orderby);
        info.setPicture(picture);
        info.setScore(score);
        info.setAdmin((AdminInfo) request.getAttribute("ADMIN_USER"));
        info.setCanSave(true);
        info.setCreatetime(System.currentTimeMillis() );
        info.setShare("0");
        info.setAdmin(admin);
        info.setYear(year);
        info.setMonth(month);
        info.setDay(day);
        info.setArea(StringUtil.getUTF8String(area, "iso-8859-1"));
 
        info.setVideoType(new VideoType(Long.parseLong(videoType)));
        if (!StringUtil.isNullOrEmpty(show) && show.contains("on"))
            info.setShow("1");
        else
            info.setShow("0");
        info.setThirdType("0");
        info.setTag(StringUtil.getUTF8String(tag, "iso-8859-1"));
        info.setWatchCount(0 + "");
        VideoInfo vi = videoManager.addVideoInfo(info);
        if (vi != null && !StringUtil.isNullOrEmpty(vi.getId())) {
            classService.updateVideoTypes(vi.getId(), typeList);
        }
        request.setAttribute("videoId", info.getId());
        List<VideoResource> list = videoResourceService.getResourceList();
        request.setAttribute("resourceList", list);
        return SUCCESS;
    }
 
    /**
     * 删除视频
     * 
     * @return
     */
    public String deleteVideo() {
        videoManager.deleteVideo(id);
        return SUCCESS;
    }
 
    public String deleteListVideo() {
        String urls = request.getParameter("url");
        String[] ids = urls.split(",");
        if (ids != null) {
            for (String idSt : ids)
                videoManager.deleteVideo(idSt);
        }
        return SUCCESS;
    }
 
    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }
 
    /**
     * page信息
     */
    private String videoType;
    private String key;
    private int pageIndex;
    private String contenttype;
 
    public String getContenttype() {
        return contenttype;
    }
 
    public void setContenttype(String contenttype) {
        this.contenttype = contenttype;
    }
 
    public String getVideoType() {
        return videoType;
    }
 
    public void setVideoType(String videoType) {
        this.videoType = videoType;
    }
 
    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 area;
    private String picture;
    private String name;
    private String introduction;
    private String duration;
    private String mainActor;
    private String year;
    private String month;
    private String day;
    private String orderby;
    private String beizhu;
    private String score;
    private String show;
    private String tag;
    private String save;// 0-不能缓存 1-能缓存
 
    public String getArea() {
        return area;
    }
 
    public void setArea(String area) {
        this.area = area;
    }
 
    public String getId() {
        return id;
    }
 
    public void setId(String id) {
        this.id = id;
    }
 
    public String getPicture() {
        return picture;
    }
 
    public void setPicture(String picture) {
        this.picture = picture;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getIntroduction() {
        return introduction;
    }
 
    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
 
    public String getDuration() {
        return duration;
    }
 
    public void setDuration(String duration) {
        this.duration = duration;
    }
 
    public String getMainActor() {
        return mainActor;
    }
 
    public void setMainActor(String mainActor) {
        this.mainActor = mainActor;
    }
 
    public String getYear() {
        return year;
    }
 
    public void setYear(String year) {
        this.year = year;
    }
 
    public String getMonth() {
        return month;
    }
 
    public void setMonth(String month) {
        this.month = month;
    }
 
    public String getDay() {
        return day;
    }
 
    public void setDay(String day) {
        this.day = day;
    }
 
    public String getOrderby() {
        return orderby;
    }
 
    public void setOrderby(String orderby) {
        this.orderby = orderby;
    }
 
    public String getBeizhu() {
        return beizhu;
    }
 
    public void setBeizhu(String beizhu) {
        this.beizhu = beizhu;
    }
 
    public String getScore() {
        return score;
    }
 
    public void setScore(String score) {
        this.score = score;
    }
 
    public String getShow() {
        return show;
    }
 
    public void setShow(String show) {
        this.show = show;
    }
 
    public String getTag() {
        return tag;
    }
 
    public void setTag(String tag) {
        this.tag = tag;
    }
 
    public String getSave() {
        return save;
    }
 
    public void setSave(String save) {
        this.save = save;
    }
 
}