forked from Olympic/NTO-2025-Backend-Individual-Task
Initial commit
This commit is contained in:
35
src/main/java/ru/example/nto/controller/CodeController.java
Normal file
35
src/main/java/ru/example/nto/controller/CodeController.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package ru.example.nto.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.example.nto.service.DepartmentService;
|
||||
import ru.nto.security.Encoder;
|
||||
import ru.nto.security.EncoderApi;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("code")
|
||||
public class CodeController {
|
||||
private final DepartmentService departmentService;
|
||||
private final EncoderApi encoderApi = Encoder.create();
|
||||
|
||||
public CodeController(DepartmentService departmentService) {
|
||||
this.departmentService = departmentService;
|
||||
}
|
||||
|
||||
@GetMapping("/task1/{id}")
|
||||
public int getTask1Code(@PathVariable long id) {
|
||||
return encoderApi.encode(null, id);
|
||||
}
|
||||
|
||||
@GetMapping("/task2/{id}")
|
||||
public int getTask2Code(@PathVariable long id) {
|
||||
return encoderApi.encode(departmentService.getAll(), id);
|
||||
}
|
||||
|
||||
@GetMapping("/task3/{id}")
|
||||
public int getTask3Code(@PathVariable long id) {
|
||||
return encoderApi.encode(departmentService.getByName("Департамент аналитики"), id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user