admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
package com.newvideo.web.action;
 
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.newvideo.domain.VideoInfo;
import com.newvideo.domain.special.Special;
import com.newvideo.domain.special.SpecialVideo;
import com.newvideo.service.imp.SpecialService;
import com.newvideo.util.Constant;
import com.newvideo.util.LogUtil;
import com.newvideo.util.StringUtil;
import com.newvideo.web.tag.PageEntity;
import com.opensymphony.xwork2.ActionSupport;
@Controller
public class SpecialVideoAction extends ActionSupport implements ServletRequestAware {
    @Resource
    private SpecialService specialService;
 
    public SpecialService getSpecialService() {
        return specialService;
    }
 
    public void setSpecialService(SpecialService specialService) {
        this.specialService = specialService;
    }
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
 
    HttpServletRequest request;
 
    /**
     * �ؼ��������б�
     * 
     * @return
     */
    public String specialVideoList() {
 
        key = StringUtil.isNullOrEmpty(key) ? "" : StringUtil.getUTF8String(key, "iso-8859-1");
        String specialId = request.getParameter("specialId");
        if (StringUtil.isNullOrEmpty(specialId))
            specialId = request.getAttribute("specialId").toString();
 
        List<SpecialVideo> list = specialService.getSpecialVideoList(specialId, key);
        long count = specialService.getSpecialVideoListCount(specialId, key);
        PageEntity pe = new PageEntity();
        pe.setPageSize(Constant.pageCount);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        map.put("specialId", specialId);
        pe.setParams(map);
        pe.setTotalCount((int) count);
        request.setAttribute("pageEntity", pe);
        request.setAttribute("specialVideoList", list);
        request.setAttribute("specialId", specialId);
 
        return SUCCESS;
    }
 
    public String addSpecialVideo() {
 
        String videoIds = request.getParameter("videoIds");
        String specialIds = request.getParameter("specialIds");
        String[] videoIdSts = videoIds.split(",");
        String[] specialIdSt = specialIds.split(",");
        for (String special : specialIdSt)
            for (String videoid : videoIdSts) {
                SpecialVideo sv = new SpecialVideo();
                sv.setCreatetime(System.clearProperty(videoid));
                sv.setSpecial(new Special(special));
                sv.setVideo(new VideoInfo(videoid));
                specialService.addSpecialVideo(sv);
            }
 
        return SUCCESS;
    }
 
    public String deleteSpecialVideo() {
        String id = request.getParameter("id");
        String sepcialId = request.getParameter("sepcialId");
 
        specialService.deleteSpecialVideo(id);
        request.setAttribute("sepcialId", sepcialId);
        return SUCCESS;
    }
 
    public String deleteSpecialVideoList() {
 
        String urls = request.getParameter("urls");
        String[] ids = urls.split(",");
        for (String st : ids) {
            specialService.deleteSpecialVideo(st);
        }
        return SUCCESS;
    }
 
    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }
 
    // ������
 
    @Override
    public void addActionError(String anErrorMessage) {
        super.addActionError(anErrorMessage);
        LogUtil.i(anErrorMessage);
    }
 
    @Override
    public void addFieldError(String fieldName, String errorMessage) {
        super.addFieldError(fieldName, errorMessage);
        LogUtil.i(errorMessage);
    }
 
    @Override
    public void addActionMessage(String aMessage) {
        super.addActionMessage(aMessage);
        LogUtil.i(aMessage);
    }
 
    private String key;
 
    public String getKey() {
        return key;
    }
 
    public void setKey(String key) {
        this.key = key;
    }
 
}