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