30 lines
984 B
Java
30 lines
984 B
Java
package com.moyi.controlplane.task;
|
|
|
|
import com.moyi.controlplane.auth.AuthController;
|
|
import com.moyi.controlplane.auth.AuthService;
|
|
import java.util.Map;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/tasks")
|
|
public class SessionTaskController {
|
|
private final AsyncTaskService tasks;
|
|
private final AuthService auth;
|
|
|
|
public SessionTaskController(AsyncTaskService tasks, AuthService auth) {
|
|
this.tasks = tasks;
|
|
this.auth = auth;
|
|
}
|
|
|
|
@GetMapping
|
|
public Map<String, Object> list(
|
|
jakarta.servlet.http.HttpServletRequest request,
|
|
@RequestParam(defaultValue = "50") int limit
|
|
) {
|
|
return Map.of("tasks", tasks.listForUser(AuthController.sessionToken(request), auth, limit));
|
|
}
|
|
}
|