content: package com.wenmrong.community1.community.controller;
  
  import com.wenmrong.community1.community.dto.NotificationDTO;
  import com.wenmrong.community1.community.enums.NotificationTypeEnum;
  import com.wenmrong.community1.community.model.User;
  import com.wenmrong.community1.community.service.NotificationService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.PathVariable;
  
  import javax.servlet.http.HttpServletRequest;
  
  @Controller
  public class NotificationController {
      @Autowired
      private NotificationService notificationService;
  
      @GetMapping("/notification/{id}")
      public String profile(HttpServletRequest request,
                            @PathVariable(name = "id") Long id) {
  
          User user = (User) request.getSession().getAttribute("user");
          if (user == null) {
              return "redirect:/";
          }
          NotificationDTO notificationDTO = notificationService.read(id, user);
          if (NotificationTypeEnum.REPLY_COMMENT.getType() == notificationDTO.getType()
                  || NotificationTypeEnum.REPLY_QUESTION.getType() == notificationDTO.getType()
          || NotificationTypeEnum.THUMB_COMMENT.getType() == notificationDTO.getType()) {
              return "redirect:/question/" + notificationDTO.getOuterid();
  
          } else {
              return "redirect:/";
          }
  
      }
  
  }
  