package com.yanhui.controller;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import com.yanhui.base.BaseController;
import com.yanhui.entity.Video;
import com.yanhui.log.YanHuiLog;
import com.yanhui.result.PageBean;
import com.yanhui.util.ResponseUtil;
import com.yanhui.util._uploadUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* InnoDB free: 660480 kB
*
* @author colorbin
* @email 490647751@qq.com
* @date 2017-01-23 09:54:19
*/
@Controller
@RequestMapping("video")
public class VideoController extends BaseController<Video>{
YanHuiLog yhLog = new YanHuiLog(VideoController.class.getName());
/**
* 点播列表
* @param request
* @return
*/
@RequestMapping("muivod")
public String muivod(HttpServletRequest request) {
List<Video> videoList = videoService.findAllList();
request.setAttribute("videoList", videoList);
return "yh-video/index";
}
/**
* 点播详情页面
* @param request
* @return
*/
@RequestMapping("muivodetail")
public String muivodetail(Integer id,HttpServletRequest request) {
Video video = videoService.findById(id);
request.setAttribute("video", video);
return "yh-video/detail";
}
/**
* 列表
* @param page
* @param rows
* @param pwdUrl
* @param request
* @param response
*/
@RequestMapping("getAllVideo")
public void getAllVideo(String page,String rows,Video video,HttpServletRequest request,HttpServletResponse response) {
try {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
PageBean pageBean = new PageBean(Integer.parseInt(page),Integer.parseInt(rows));
List<Video> list = videoService.selectByList(pageBean,video);
int count = videoService.selectByCount(video);
JSONArray array = JSONArray.fromObject(list);
JSONObject jsonObject = new JSONObject();
jsonObject.put("total", count);
jsonObject.put("rows", array);
PrintWriter out = response.getWriter();
out.print(jsonObject.toString());
out.close();
out.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 添加或更新
* @param movie
* @param response
* @param flag
* @return
* @throws Exception
*/
@RequestMapping("save")
public String save(@RequestParam("video") MultipartFile videoPath,
@RequestParam("pic") MultipartFile pic,
Video video,HttpServletResponse response,Integer flag)throws Exception{
int resultTotal=0;
String picurl = _uploadUtil.uploadFile(pic,"videoImg");
String videourl = _uploadUtil.uploadFile(videoPath,"video");
if(flag==1){
video.setPicurl(picurl);
video.setVideourl(videourl);
resultTotal = videoService.add(video);
resultTotal = 1;
}
JSONObject result=new JSONObject();
if(resultTotal>0){
result.put("success", true);
}else{
result.put("success", false);
}
ResponseUtil.write(response, result);
return null;
}
/**
* 删除
* @param ids
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/delete")
public String delete(String ids,HttpServletResponse response)throws Exception{
String []idsStr = ids.split(",");
for(int i = 0; i < idsStr.length; i++){
videoService.delete(Integer.parseInt(idsStr[i]));
}
JSONObject result=new JSONObject();
result.put("success", true);
ResponseUtil.write(response, result);
return null;
}
}
最近下载更多
2639895440 LV1
2022年9月21日
mamahaha LV3
2022年7月6日
zd1990 LV2
2022年4月13日
amour1 LV11
2022年1月24日
MyPary LV6
2021年11月14日
了大河家违法和 LV3
2021年2月16日
user_mingen LV1
2020年3月24日
huzh035 LV3
2020年3月17日
kevens10 LV1
2020年3月13日
那一年你在哪 LV13
2019年11月27日
最近浏览更多
微信网友_7525238679375872 LV1
5月25日
xianyu091012 LV5
2024年12月26日
wmxhahah LV7
2024年4月8日
帅涵123456 LV2
2023年11月6日
流连瓦盖法 LV7
2023年9月20日
baozhenghua LV2
2023年8月29日
2506793979 LV12
2023年7月2日
陆程江 LV2
2023年5月28日
纯爱战士 LV2
2023年5月28日
奶油栀子 LV1
2023年5月6日

