Initial commit

This commit is contained in:
2025-11-04 14:25:40 +03:00
commit 80b7e8e22f
16 changed files with 364 additions and 0 deletions

View 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);
}
}