HomeController.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2019 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. * >>
  17. *
  18. */
  19. package edp.davinci.controller;
  20. import edp.core.annotation.AuthIgnore;
  21. import edp.davinci.core.common.Constants;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.core.env.Environment;
  24. import org.springframework.stereotype.Controller;
  25. import org.springframework.web.bind.annotation.RequestMapping;
  26. import org.springframework.web.bind.annotation.ResponseBody;
  27. import springfox.documentation.annotations.ApiIgnore;
  28. import java.util.HashMap;
  29. import java.util.Map;
  30. @ApiIgnore
  31. @Controller
  32. public class HomeController {
  33. @Autowired
  34. private Environment environment;
  35. @RequestMapping("swagger")
  36. public String swagger() {
  37. return "redirect:swagger-ui.html";
  38. }
  39. @RequestMapping(value = {"", "/"})
  40. public String index() {
  41. return "index";
  42. }
  43. @RequestMapping("share/")
  44. public String shareIndex() {
  45. return "share";
  46. }
  47. @RequestMapping(Constants.BASE_API_PATH + "/configurations")
  48. @AuthIgnore
  49. @ResponseBody
  50. public Map<String, Object> configurations() {
  51. Map<String, Object> configs = new HashMap<>();
  52. configs.put("version", environment.getProperty("davinci.version"));
  53. configs.put("jwtToken", new HashMap<String, Object>() {{
  54. put("timeout", environment.getProperty("jwtToken.timeout"));
  55. }});
  56. configs.put("security", new HashMap<String, Object>() {{
  57. put("oauth2", new HashMap<String, Object>() {{
  58. put("enable", Boolean.valueOf(environment.getProperty("spring.security.oauth2.enable")));
  59. }});
  60. }});
  61. return new HashMap<String, Object>() {{
  62. put("payload", configs);
  63. }};
  64. }
  65. }