Commit 1fa33380510874bfacd1590895d3c7a9f4ccea9c

Authored by jiangjiazhi
1 parent 9996932aa5

add jws

Showing 1 changed file with 31 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/EnumsController.java View file @ 1fa3338
1 1 package com.lyms.platform.operate.web.controller;
2 2  
3 3 import com.lyms.platform.common.enums.*;
  4 +import com.lyms.platform.common.utils.ExceptionUtils;
  5 +import com.lyms.platform.common.utils.JsonUtil;
  6 +import com.lyms.platform.common.utils.SystemConfig;
  7 +import com.lyms.platform.operate.web.facade.BasicConfigFacade;
  8 +import com.lyms.platform.operate.web.result.BasicConfigResult;
4 9 import com.lyms.platform.permission.model.Organization;
  10 +import org.springframework.beans.factory.annotation.Autowired;
5 11 import org.springframework.stereotype.Controller;
6 12 import org.springframework.web.bind.annotation.PathVariable;
7 13 import org.springframework.web.bind.annotation.RequestMapping;
8 14 import org.springframework.web.bind.annotation.RequestMethod;
9 15 import org.springframework.web.bind.annotation.ResponseBody;
10 16  
  17 +import javax.servlet.http.HttpServletResponse;
  18 +import java.io.IOException;
  19 +import java.io.PrintWriter;
11 20 import java.util.ArrayList;
12 21 import java.util.HashMap;
13 22 import java.util.List;
... ... @@ -354,5 +363,27 @@
354 363 return list;
355 364 }
356 365  
  366 + @RequestMapping(value = "/getjws", method = RequestMethod.GET)
  367 + public void geJws(HttpServletResponse response) {
  368 + int cacheTime =30000;
  369 + String json = JsonUtil.array2JsonString(basicConfigFacade.getBaseicConfigByParentId(SystemConfig.JIWANGSHI_ID));
  370 + writeJsonWithCache(response,json,cacheTime);
  371 + }
  372 +
  373 + public void writeJsonWithCache(HttpServletResponse response, String json,int cacheTime) {
  374 + response.setContentType("application/json;charset=UTF-8");
  375 + response.setCharacterEncoding("UTF-8");
  376 + response.setHeader("Cache-Control", "max-age=" + cacheTime);
  377 + try {
  378 + PrintWriter out = response.getWriter();
  379 + out.print(json);
  380 + } catch (IOException e) {
  381 + ExceptionUtils.catchException(e,"writeJsonWithCache Error.");
  382 + }
  383 + }
  384 +
  385 +
  386 + @Autowired
  387 + private BasicConfigFacade basicConfigFacade;
357 388 }