release/2025-02-20-12-42

This commit is contained in:
geniy 2025-02-20 12:42:11 +03:00
parent 75e925419a
commit 5ec569f3c9
4 changed files with 23 additions and 3 deletions

View File

@ -25,10 +25,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http http
.csrf().disable() .csrf().disable()
.authorizeRequests() .authorizeRequests()
/*.antMatchers("/api/employee/**").hasAnyAuthority("ROLE_EMPLOYEE", "ROLE_ADMIN")*/
.antMatchers("/api/admin/**").hasAuthority("ROLE_ADMIN") .antMatchers("/api/admin/**").hasAuthority("ROLE_ADMIN")
/*.antMatchers("url").permitAll()
.antMatchers("url").hasAuthority("ROLE_ADMIN")*/
.anyRequest().authenticated() .anyRequest().authenticated()
.and() .and()
.httpBasic() .httpBasic()

View File

@ -42,4 +42,11 @@ public class AdminController {
String login = authentication.getName(); String login = authentication.getName();
return adminService.getEmployeeEntryList(employeeLogin, login); return adminService.getEmployeeEntryList(employeeLogin, login);
} }
@PostMapping("/panel/is-employee-blocked")
private boolean isEmployeeBlocked(@RequestParam("employee-login") String employeeLogin,
Authentication authentication) {
String login = authentication.getName();
return adminService.isEmployeeBlocked(employeeLogin, login);
}
} }

View File

@ -9,4 +9,5 @@ public interface AdminService {
EmployeeDataDto getEmployeeInfo(String employeeLogin, String selfLogin); EmployeeDataDto getEmployeeInfo(String employeeLogin, String selfLogin);
void setBlockCondition(String employeeLogin, boolean blockCondition, String selfLogin); void setBlockCondition(String employeeLogin, boolean blockCondition, String selfLogin);
List<EntryDto> getEmployeeEntryList(String employeeLogin, String selfLogin); List<EntryDto> getEmployeeEntryList(String employeeLogin, String selfLogin);
boolean isEmployeeBlocked(String employeeLogin, String selfLogin);
} }

View File

@ -4,6 +4,7 @@ import com.infinity.nto.dto.EmployeeDataDto;
import com.infinity.nto.dto.EntryDto; import com.infinity.nto.dto.EntryDto;
import com.infinity.nto.dto.mapper.EmployeeDataMapper; import com.infinity.nto.dto.mapper.EmployeeDataMapper;
import com.infinity.nto.dto.mapper.EntryMapper; import com.infinity.nto.dto.mapper.EntryMapper;
import com.infinity.nto.entity.Employee;
import com.infinity.nto.entity.EmployeeData; import com.infinity.nto.entity.EmployeeData;
import com.infinity.nto.exception.EmployeeDataNotFoundException; import com.infinity.nto.exception.EmployeeDataNotFoundException;
import com.infinity.nto.exception.EmployeeNotFoundException; import com.infinity.nto.exception.EmployeeNotFoundException;
@ -76,4 +77,18 @@ public class AdminServiceImpl implements AdminService {
.map(EntryMapper::toEntryDto) .map(EntryMapper::toEntryDto)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public boolean isEmployeeBlocked(String employeeLogin, String selfLogin) {
if (employeeLogin.equals(selfLogin)) {
throw new SelfChangeException("Self View");
}
Optional<Employee> employee = employeeRepository.findByLogin(employeeLogin);
if (employee.isEmpty()) {
throw new EmployeeNotFoundException("Employee Not Found");
}
return employee.get().isBlock();
}
} }