forked from Olympic/NTO-2025-Backend-Individual-Task
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
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);
|
|
}
|
|
}
|