package com.yeshi.buwan.controller.admin.api;
|
|
import java.io.PrintWriter;
|
import java.util.List;
|
|
import net.sf.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.VideoType;
|
import com.yeshi.buwan.domain.recommend.CategoryRecommendCacheVideo;
|
import com.yeshi.buwan.service.imp.CategoryRecommendCacheVideoService;
|
import com.yeshi.buwan.service.imp.VideoInfoService;
|
import com.yeshi.buwan.service.imp.VideoTypeService;
|
import com.yeshi.buwan.util.JsonUtil;
|
import com.yeshi.buwan.web.tag.PageEntity;
|
|
@Controller
|
@RequestMapping("admin/new/api/top")
|
public class CategoryRecommendCacheVideoAdminController {
|
|
@Autowired
|
private CategoryRecommendCacheVideoService topService;
|
|
@Autowired
|
private VideoInfoService videoInfoService;
|
|
@Autowired
|
private VideoTypeService videoTypeService;
|
|
@RequestMapping("getTopList")
|
public void getTopList(long videotype,String key,int page,int pageSize,PrintWriter out){
|
List<CategoryRecommendCacheVideo> list = topService.getList(videotype,key,page,pageSize);
|
int count = topService.getCount(videotype,key);
|
PageEntity pe = new PageEntity();
|
pe.setPageIndex(page);
|
pe.setPageSize(pageSize);
|
pe.setTotalCount(count);
|
JSONObject data = new JSONObject();
|
data.put("list", list);
|
data.put("pe",pe);
|
String json = JsonUtil.loadTrueAdmin(data);
|
out.print(json);
|
}
|
|
@RequestMapping("getTop")
|
public void getTop(long id,PrintWriter out){
|
CategoryRecommendCacheVideo crcv =topService.getTop(id);
|
if(crcv == null){
|
JsonUtil.loadFalseAdmin("不存在该对象");
|
return;
|
}
|
String json = JsonUtil.loadTrueAdmin(crcv);
|
out.print(json);
|
}
|
|
@RequestMapping("editTopOrderBy")
|
public void editTopOrderBy(long id,int orderBy,int rank,PrintWriter out){
|
CategoryRecommendCacheVideo crcv =topService.getTop(id);
|
if(crcv == null){
|
JsonUtil.loadFalseAdmin("不存在该对象");
|
return;
|
}
|
crcv.setOrderby(orderBy);
|
crcv.setRank(rank);
|
topService.update(crcv);
|
String json = JsonUtil.loadTrueAdmin("");
|
out.print(json);
|
}
|
|
@RequestMapping("addTop")
|
public void addTop(long[] vids,long tid,PrintWriter out){
|
for (long vid : vids) {
|
VideoInfo videoInfo = videoInfoService.getVideoInfo(vid+"");
|
if(videoInfo==null){
|
continue;
|
}
|
VideoType videoType = videoTypeService.getVideoType(tid);
|
if(videoType == null){
|
JsonUtil.loadFalseAdmin("不存在该分类");
|
return;
|
}
|
CategoryRecommendCacheVideo find = topService.getTop(vid,tid);
|
if(find != null){
|
continue;
|
}
|
CategoryRecommendCacheVideo crcv = new CategoryRecommendCacheVideo();
|
crcv.setOrderby(0);
|
crcv.setVideoInfo(videoInfo);
|
crcv.setVideoType(videoType);
|
crcv.setCreatetime(System.currentTimeMillis()+"");
|
topService.save(crcv);
|
}
|
out.print(JsonUtil.loadTrueAdmin(""));
|
}
|
|
@RequestMapping("deleteTop")
|
public void deleteTop(long[] ids,PrintWriter out){
|
for (long id : ids) {
|
topService.delete(id);
|
}
|
out.print(JsonUtil.loadTrueAdmin(""));
|
}
|
|
|
}
|