package com.yeshi.buwan.controller.admin.api; import java.io.PrintWriter; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import com.google.gson.Gson; import com.yeshi.buwan.domain.VideoResource; import com.yeshi.buwan.service.imp.VideoResourceService; import com.yeshi.buwan.util.SystemUtil; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.yeshi.buwan.domain.system.DetailSystem; import com.yeshi.buwan.domain.VideoInfo; import com.yeshi.buwan.service.imp.SystemService; import com.yeshi.buwan.service.imp.VideoService; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @Controller @RequestMapping("admin/new/api/common") public class CommonController { @Resource private VideoService videoService; @Resource private SystemService systemService; @Resource private VideoResourceService videoResourceService; @RequestMapping(value = "/searchvideo", method = RequestMethod.POST) public void searchVideo(String key, PrintWriter out) { List list = videoService.searchVideoUsedByAdmin(key); JSONArray array = new JSONArray(); if (list != null) for (VideoInfo info : list) { JSONObject obj = new JSONObject(); obj.put("id", info.getId()); obj.put("name", info.getName()); obj.put("picture", info.getPicture()); obj.put("show", info.getShow()); array.add(obj); } JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", array); out.print(object); } @RequestMapping(value = "/detailsystemlist", method = RequestMethod.POST) public void detailSystemList(String key, HttpSession session, PrintWriter out) { List list = systemService.getDetailSystemList(SystemUtil.getAdminSelectedSystem(session).getId()); JSONArray array = new JSONArray(); if (list != null) for (DetailSystem system : list) { JSONObject obj = new JSONObject(); obj.put("id", system.getId()); obj.put("name", system.getAppName()); obj.put("platform", system.getPlatform()); array.add(obj); } JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", array); out.print(object); } @RequestMapping(value = "/resourceList", method = RequestMethod.POST) public void resourceList(String key, HttpSession session, PrintWriter out) { List videoResources = videoResourceService.getResourceList(); JSONObject object = new JSONObject(); object.put("code", 0); object.put("data", new Gson().toJson(videoResources)); out.print(object); } }