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;
|
}
|
|
|
}
|