|
@@ -101,6 +101,62 @@ public class AudioController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 管理员搜索资源平台的接口
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/resource", method = RequestMethod.POST)
|
|
|
+ public void AdminLoadResource(HttpServletRequest request, HttpServletResponse response){
|
|
|
+ String name = request.getParameter("name");
|
|
|
+ String idResource = request.getParameter("idResource");
|
|
|
+ String idNo = request.getParameter("idNo");
|
|
|
+ String type = request.getParameter("type"); //资源类型, 音频,视频, 直播 取值{0,1,2}, 分别表示{视频,音频,直播}
|
|
|
+ String page = request.getParameter("page");
|
|
|
+ String size = request.getParameter("size");
|
|
|
+
|
|
|
+ JSONArray list = new JSONArray();
|
|
|
+ String res = null;
|
|
|
+ if((idResource!=null && idResource.length()>0)
|
|
|
+ || (idNo!=null && idNo.length()>0)){
|
|
|
+ if(idResource!=null && idResource.length()>0)
|
|
|
+ res = audioHttp.SearchByIdResource(idResource);
|
|
|
+ else
|
|
|
+ res = audioHttp.SearchByIdNo(idNo);
|
|
|
+// System.out.println(res);
|
|
|
+ Map map = JSONObject.parseObject(res);
|
|
|
+ try{
|
|
|
+ if(map.get("code").toString().equalsIgnoreCase("200")){
|
|
|
+ map = JSONObject.parseObject(map.get("data").toString());
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ }
|
|
|
+ }else if(name!=null && name.length()>0){
|
|
|
+ if(type==null || type.length()<1)
|
|
|
+ type = "0";
|
|
|
+ if(page==null || page.length()<1)
|
|
|
+ page = "1";
|
|
|
+ if(size==null || size.length()<1)
|
|
|
+ size = "10";
|
|
|
+ res = audioHttp.SearchByName(name, Integer.valueOf(type), Integer.valueOf(page), Integer.valueOf(size));
|
|
|
+// System.out.println(res);
|
|
|
+ Map map = JSONObject.parseObject(res);
|
|
|
+ try{
|
|
|
+ if(map.get("code").toString().equalsIgnoreCase("200")){
|
|
|
+ map = JSONObject.parseObject(map.get("data").toString());
|
|
|
+ list = JSONArray.parseArray(map.get("list").toString());
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ System.out.println(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ HttpUtil.responseOkData(request, response, list);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 用户搜索接口
|
|
|
* @param request
|
|
|
* @param response
|
|
@@ -155,17 +211,26 @@ public class AudioController {
|
|
|
int r = Math.abs(random.nextInt())%audioList.size();
|
|
|
Audio audio = audioList.get(r);
|
|
|
if(audio.getIdResource()!=null && audio.getIdResource().length()>0){
|
|
|
- String res = audioHttp.GetResource(audio.getIdResource());
|
|
|
+ String res = audioHttp.SearchByIdResource(audio.getIdResource());
|
|
|
// System.out.println(res);
|
|
|
Map map = JSONObject.parseObject(res);
|
|
|
try{
|
|
|
if(map.get("code").toString().equalsIgnoreCase("200")){
|
|
|
map = JSONObject.parseObject(map.get("data").toString());
|
|
|
- JSONArray array = JSONArray.parseArray(map.get("audios").toString());
|
|
|
- map = JSONObject.parseObject(array.get(0).toString());
|
|
|
- String path = map.get("path").toString();
|
|
|
- path = path.replaceAll("\n","");
|
|
|
- audio.setUrl(path);
|
|
|
+ if(map.get("type").toString().equalsIgnoreCase("1")){
|
|
|
+ JSONArray array = JSONArray.parseArray(map.get("audios").toString());
|
|
|
+ map = JSONObject.parseObject(array.get(0).toString());
|
|
|
+ String path = map.get("fullPath").toString();
|
|
|
+ path = path.replaceAll("\n","");
|
|
|
+ audio.setUrl(path);
|
|
|
+ }else if(map.get("type").toString().equalsIgnoreCase("0")){
|
|
|
+ JSONArray array = JSONArray.parseArray(map.get("videos").toString());
|
|
|
+ map = JSONObject.parseObject(array.get(0).toString());
|
|
|
+ String path = map.get("fullPath").toString();
|
|
|
+ path = path.replaceAll("\n","");
|
|
|
+ audio.setUrl(path);
|
|
|
+ }
|
|
|
+
|
|
|
// System.out.println(path);
|
|
|
}
|
|
|
}catch(Exception e){
|