admin
2021-06-16 42fa17d6209d10cbe4774388d0ff3fcf3329eb5a
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
package com.yeshi.buwan.controller.admin.api;
 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import net.sf.json.JSONObject;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.buwan.domain.system.DetailSystem;
import com.yeshi.buwan.domain.VideoBanQuan;
import com.yeshi.buwan.domain.VideoBanQuanVideo;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.web.BanquanKeyAdmin;
import com.yeshi.buwan.domain.web.BanquanVideoAdmin;
import com.yeshi.buwan.service.imp.BanQuanService;
import com.yeshi.buwan.service.imp.VideoService;
import com.yeshi.buwan.util.Constant;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.web.tag.PageEntity;
 
@Controller
@RequestMapping("admin/new/api/copyright")
public class CopyRightController {
    
    @Resource
    private BanQuanService banQuanService;
    
    @Resource
    private VideoService videoService;
    
    @RequestMapping("copyRightList")
    public void getCopyRightList(int pageIndex,String key,int detailsystem,PrintWriter out){
        
        List<BanquanVideoAdmin> list = banQuanService.getBanquanVideoAdmin(key, detailsystem, pageIndex);
        long count = banQuanService.getBanquanVideoAdminCount(key, detailsystem);
        PageEntity pe = new PageEntity();
        pe.setPageIndex(pageIndex);
        pe.setPageSize(Constant.pageCount);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        map.put("detailsystem", detailsystem + "");
        pe.setParams(map);
        pe.setTotalCount((int) count);
        JSONObject json =new JSONObject();
        json.put("code", "0");
        json.put("pageEntity", pe);
        Gson gson =new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        json.put("copyRightList",gson.toJson(list));
        out.print(json);
    }
    
    @RequestMapping(value="setCopyRightDetailSystem")
    public void set(String id,String detailSystem,String type,PrintWriter out){
        if("add".equals(type)){
            List<VideoBanQuanVideo> list = new ArrayList<VideoBanQuanVideo>();
            VideoBanQuanVideo video = new VideoBanQuanVideo();
            video.setCreatetime(System.currentTimeMillis() + "");
            video.setDetailSystem(new DetailSystem(detailSystem));
            video.setInfo(new VideoInfo(id));
            video.setName(videoService.getVideoInfo(id).getName());
            video.setShow(true);
            list.add(video);
            banQuanService.addBanQuanVideo(list);
            out.print("yes");
        }else if("delete".equals(type)){
            banQuanService.deleteBanQuanVideoAdmin(id, detailSystem);
            out.print("yes");
        }
    }
    
    @RequestMapping(value="setDetailSystemByCopyRightKey")
    public void setDetailSystemByCopyRightKey(String id,String detailSystem,String type,PrintWriter out){
        System.out.println("id---"+id);
        System.out.println("detailSystem-"+detailSystem);
        if("add".equals(type)){
            List<VideoBanQuan> list = new ArrayList<VideoBanQuan>();
            VideoBanQuan video = new VideoBanQuan();
            video.setCreatetime(System.currentTimeMillis() + "");
            video.setDetailSystem(new DetailSystem(detailSystem));
            video.setName(id);
            video.setShow(true);
            list.add(video);
            banQuanService.addBanQuanKey(list);
            out.print("yes");
            
        }else if("delete".equals(type)){
            banQuanService.deleteBanQuanKeyAdmin(id, detailSystem);
            out.print("yes");
        }
    }
    
    @RequestMapping("addCopyRirhtVideo")
    public void addCopyRirhtVideo(String ids,String detailSystems,PrintWriter out){
        System.out.println("ids-"+ids);
        System.out.println("detailSystems-"+detailSystems);
        if (!StringUtil.isNullOrEmpty(ids)) {
            if (ids.endsWith(","))
                ids = ids.substring(0, ids.length() - 1);
        }
        String[] systemArr = null;
        if (!StringUtil.isNullOrEmpty(detailSystems)) {
            systemArr = detailSystems.split(",");
        }
 
        String[] idArr = ids.split(",");
        List<VideoBanQuanVideo> list = new ArrayList<VideoBanQuanVideo>();
        
        if(ids == null || "".equals(ids.trim())){
            out.print("no");
            return;
        }
        VideoBanQuanVideo video = null;
        if(systemArr != null && systemArr.length>0){
            for (String sys : systemArr){
                for (String id : idArr) {
                    video=new VideoBanQuanVideo();
                    video.setCreatetime(System.currentTimeMillis() + "");
                    video.setDetailSystem(new DetailSystem(sys));
                    video.setInfo(new VideoInfo(id));
                    video.setName(videoService.getVideoInfo(id).getName());
                    video.setShow(true);
                    list.add(video);
                }
            }
        }else{
            out.append("no");
            return;
        }
        banQuanService.addBanQuanVideo(list);
        out.append("yes");
    }
    
    @RequestMapping("addCopyRightKey")
    public void addCopyRightKey(@RequestParam String[] ids,String detailSystems,PrintWriter out){
        String[] systems = null;
        if (!StringUtil.isNullOrEmpty(detailSystems)) {
            systems = detailSystems.split(",");
        }
        if(ids==null || ids.length ==0){
            out.print("no");
            return;
        }
        List<VideoBanQuan> list = null;
        if (systems != null){
            list = new ArrayList<VideoBanQuan>();
            for (String sy : systems)
                for (String st : ids) {
                    VideoBanQuan video = new VideoBanQuan();
                    video.setCreatetime(System.currentTimeMillis() + "");
                    video.setDetailSystem(new DetailSystem(sy));
                    video.setName(st);
                    video.setShow(true);
                    list.add(video);
                }
        }
        if(list != null && list.size() > 0 ){
            banQuanService.addBanQuanKey(list);
            out.print("yes");
        }else{
            out.print("no");
        }
    }
     
    @RequestMapping("deleteCopyRightVideo")
    public void deleteCopyRightVideo(String ids,PrintWriter out){
        if(ids!=null && !"".equals(ids.trim())){
            String[] idArr = ids.split(",");
            for (String id : idArr) {
                banQuanService.deleteBanQuanVideoByVID(id);
            }
            out.print("yes");
        }
    }
    
    @RequestMapping("deleteCopyRightKey")
    public void deleteCopyRightKey(String[] ids,PrintWriter out){
        if(ids == null || ids.length == 0){
            out.print("no");
            return;
        }
        for (String st : ids) {
            banQuanService.deleteBanQuanKeyByKey(st);
        }
        out.print("yes");
    }
    
    /**
     * 搜索屏蔽
     */
    @RequestMapping("copyRightKeyList")
    public void copyRightKeyList(int pageIndex,String key,int detailsystem,PrintWriter out) {
        if (pageIndex == 0){
            pageIndex = 1;
        }
        List<BanquanKeyAdmin> list = banQuanService.getBanquanKeyAdmin(key, detailsystem, pageIndex);
        long count = banQuanService.getBanquanKeyAdminCount(key, detailsystem);
        PageEntity pe = new PageEntity();
        pe.setPageIndex(pageIndex);
        pe.setPageSize(Constant.pageCount);
        Map<String, String> map = new HashMap<String, String>();
        map.put("key", key);
        map.put("detailsystem", detailsystem + "");
        pe.setParams(map);
        pe.setTotalCount((int) count);
        JSONObject json =new JSONObject();
        json.put("code", "0");
        json.put("pageEntity", pe);
        Gson gson =new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        json.put("copyRightKeyAdminList", gson.toJson(list));
        out.print(json);
        return;
    }
    
    
}