package com.fdkankan.scene.controller; import com.alibaba.fastjson.JSONObject; import com.fdkankan.scene.entity.Scene; import com.fdkankan.scene.service.ISceneService; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import lombok.extern.log4j.Log4j2; import org.joda.time.DateTime; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; /** * Created by Hb_zzZ on 2019/7/4. */ @Log4j2 @RestController /**app公共模块接口(旧的接口)*/ public class CommonController { @Autowired private ISceneService sceneService; @RequestMapping("/scene/getInfo") @ResponseBody public void getInfo(HttpServletRequest request,HttpServletResponse response) { try { log.info("scene/getInfo"); JSONObject result = new JSONObject(); response.setContentType("text/html;charset=UTF-8"); String num = request.getParameter("num"); if(num==null||num.trim().equals("")) { response.getWriter().println(-102); return; } Scene scene = sceneService.findByNum(num); log.info("场景序号:"+num); if(scene == null) { log.info("场景不存在"); response.getWriter().print(-1); return; } String key = scene.getSceneKey(); if(key == null||key.equals("")) { //response.getWriter().print(0); result.put("public", 0); } else { result.put("public", 1); } int screenCapLen = scene.getScreencapLen(); result.put("screenCapLen", screenCapLen); result.put("sceneKey", key); result.put("sceneName", scene.getSceneName()); result.put("sceneDec", scene.getSceneDec()); result.put("sceneType", scene.getSceneType()); result.put("homePic", scene.getThumb()); result.put("thumbImg", scene.getThumbStatus()); result.put("version", scene.getVersion()); result.put("floorLogo", scene.getFloorLogo()); result.put("floorLogoSize", scene.getFloorLogoSize()); result.put("entry", scene.getEntry()); result.put("createTime", (new DateTime(scene.getCreateTime()).toString("yyyy-MM-dd"))); result.put("shootCount", scene.getShootCount()); result.put("status", scene.getStatus()); result.put("sceneIndex", scene.getStyle()); result.put("bgMusic", scene.getBgMusic()); result.put("cameraType", scene.getSceneScheme()); result.put("ecs", scene.getOss()); result.put("floorEditVer", scene.getFloorEditVer()); result.put("floorPublishVer", scene.getFloorPublishVer()); result.put("screencapVoiceType", scene.getScreencapVoiceType()); result.put("playData", scene.getPlayData()); result.put("screencapVoiceSrc", scene.getScreencapVoiceSrc()); result.put("screencapMusic", scene.getScreencapMusic()); result.put("screencapVoiceSound", scene.getScreencapVoiceSound()); result.put("screencapThumb", scene.getScreencapThumb()); result.put("sceneScheme", scene.getSceneScheme()); String hots = scene.getHotsIds(); if(hots==null||hots.trim().equals("")) { result.put("hots", 0); } else { result.put("hots", 1); } response.getWriter().print(result); } catch (Exception e) { StringWriter trace=new StringWriter(); e.printStackTrace(new PrintWriter(trace)); log.error(trace.toString()); try { response.getWriter().print(-101); } catch (IOException e1) { // TODO Auto-generated catch block } } } }