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