Pārlūkot izejas kodu

Login Controller adapted. NoticiaController created

Drowsito 2 nedēļas atpakaļ
vecāks
revīzija
784f953364

+ 0 - 54
src/main/java/es/uv/saic/web/LoginController.java

@@ -1,54 +0,0 @@
-package es.uv.saic.web;
-
-import java.io.IOException;
-import java.util.List;
-
-import jakarta.servlet.http.HttpSession;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.core.Authentication;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-
-import es.uv.saic.domain.Noticia;
-import es.uv.saic.service.NoticiaService;
-
-
-@Controller
-public class LoginController {
-	
-	@Autowired
-	private NoticiaService serv;
-	@Autowired
-	private ProceduresController procedures;
-	
-	@GetMapping("/login")
-	public String get(Model model, Authentication auth, HttpSession session, @RequestParam(required = false) String error) throws IOException {
-		if(auth != null) {
-			return procedures.getActiveInstances(model, auth, session, null);
-		}
-		else {
-			if(error != null) {
-		        if(error.equals("expired")) {
-		        	model.addAttribute("expired", true);
-		        }		        
-		        else {
-		        	model.addAttribute("error", true);
-		        }
-			}
-					
-			model.addAttribute("notices", null);
-			List<Noticia> l = this.serv.findVisibles();	
-			if(l != null) {
-				if(!l.isEmpty()) {
-					model.addAttribute("notices", l);
-				}
-			}
-			
-			return "login";
-		}
-		
-	}
-}

+ 22 - 0
src/main/java/es/uv/saic/web/NoticiaController.java

@@ -0,0 +1,22 @@
+package es.uv.saic.web;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RestController;
+
+import es.uv.saic.domain.Noticia;
+import es.uv.saic.service.NoticiaService;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@RestController
+public class NoticiaController {
+    @Autowired
+    private NoticiaService ns;
+    
+    @GetMapping("/noticia/findVisibles")
+    public List<Noticia> findVisibles() {
+        return ns.findVisibles();
+    }
+    
+}