package com.example.nto.controller; import com.example.nto.entity.EmployeeData; import com.example.nto.entity.Entry; import com.example.nto.service.AdminService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; @RestController @RequiredArgsConstructor @RequestMapping("/api/admin") public class AdminController { private final AdminService adminService; @PostMapping("/am-i-admin") private void amIAdmin() {} @PostMapping("/panel/get-employee-info") private EmployeeData getEmployeeInfo(@RequestParam("employee-login") String employeeLogin) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String login = authentication.getName(); return adminService.getEmployeeInfo(employeeLogin, login); } @PostMapping("/panel/set-block-condition") private void setBlockCondition(@RequestParam("employee-login") String employeeLogin, @RequestParam("block-condition") boolean blockCondition) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String login = authentication.getName(); adminService.setBlockCondition(employeeLogin, blockCondition, login); } @PostMapping("/panel/get-employee-entry-list") private List getEmployeeEntryList(@RequestParam("employee-login") String employeeLogin) { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String login = authentication.getName(); return adminService.getEmployeeEntryList(employeeLogin, login); } }