IndexEndpoint.java 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.maxkey.web.endpoint;
  17. import java.io.IOException;
  18. import javax.servlet.ServletException;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpServletResponse;
  21. import org.maxkey.configuration.ApplicationConfig;
  22. import org.maxkey.web.WebContext;
  23. import org.slf4j.Logger;
  24. import org.slf4j.LoggerFactory;
  25. import org.springframework.beans.factory.annotation.Autowired;
  26. import org.springframework.beans.factory.annotation.Qualifier;
  27. import org.springframework.stereotype.Controller;
  28. import org.springframework.web.bind.annotation.RequestMapping;
  29. import org.springframework.web.servlet.ModelAndView;
  30. import org.maxkey.persistence.service.NoticesService;
  31. /**
  32. * Index
  33. * @author Crystal.Sea
  34. *
  35. */
  36. @Controller
  37. public class IndexEndpoint {
  38. private static Logger _logger = LoggerFactory.getLogger(IndexEndpoint.class);
  39. @Autowired
  40. NoticesService noticesService;
  41. @Autowired
  42. @Qualifier("applicationConfig")
  43. ApplicationConfig applicationConfig;
  44. @RequestMapping(value={"/forwardindex"})
  45. public ModelAndView forwardindex(HttpServletRequest request,
  46. HttpServletResponse response) throws ServletException, IOException {
  47. _logger.debug("IndexEndpoint /forwardindex.");
  48. String defaultUri = applicationConfig.getLoginConfig().getDefaultUri();
  49. if (defaultUri != null && !defaultUri.equals("")) {
  50. _logger.debug("defaultUri " + defaultUri);
  51. return WebContext.redirect(applicationConfig.getLoginConfig().getDefaultUri());
  52. }
  53. _logger.debug("Uri /appList");
  54. return new ModelAndView("/appList");
  55. }
  56. @RequestMapping(value={"/index"})
  57. public ModelAndView home(HttpServletRequest request,
  58. HttpServletResponse response) throws ServletException, IOException {
  59. _logger.debug("home /index.");
  60. return new ModelAndView("index");
  61. }
  62. @RequestMapping(value={"/"})
  63. public ModelAndView index() {
  64. _logger.debug("IndexEndpoint /.");
  65. return new ModelAndView("index");
  66. }
  67. @RequestMapping(value={"/lastedNotices"})
  68. public ModelAndView lastedNotices() {
  69. _logger.debug("notices /notices.");
  70. ModelAndView modelAndView = new ModelAndView("notices");
  71. modelAndView.addObject("notice", noticesService.queryLastedNotices());
  72. return modelAndView;
  73. }
  74. }