Доработка
This commit is contained in:
parent
5004222eba
commit
85606dabbb
@ -6,9 +6,12 @@ import com.example.nto.dto.EnterDTO;
|
||||
import com.example.nto.entity.*;
|
||||
import com.example.nto.service.impl.EmployeeServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.net.http.HttpClient;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@ -39,7 +42,7 @@ public class EmployeeController {
|
||||
}
|
||||
|
||||
@PatchMapping("/admin/authority/change/{login}")
|
||||
public ResponseEntity<EmployeeAuthority> authChange(@PathVariable("login") String username, @RequestBody Authority authority){
|
||||
public ResponseEntity<HttpStatus> authChange(@PathVariable("login") String username, @RequestBody Authority authority){
|
||||
return ResponseEntity.ok(employeeService.changeAuthority(username, authority));
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.example.nto.dto.EmployeeDTO;
|
||||
import com.example.nto.dto.EnterDTO;
|
||||
import com.example.nto.entity.Authority;
|
||||
import com.example.nto.entity.EmployeeAuthority;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -12,5 +13,5 @@ public interface EmployeeService {
|
||||
EmployeeDTO getInfo(String username);
|
||||
EnterDTO addEnter(String username, EnterDTO enterDTO);
|
||||
List<EnterDTO> getAllEmployeeEnters(String username);
|
||||
EmployeeAuthority changeAuthority(String username, Authority auth);
|
||||
HttpStatus changeAuthority(String username, Authority auth);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.example.nto.service.EmployeeService;
|
||||
import com.example.nto.util.EmployeeMapper;
|
||||
import com.example.nto.util.EnterMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -81,7 +82,7 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmployeeAuthority changeAuthority(String username, Authority auth) {
|
||||
public HttpStatus changeAuthority(String username, Authority auth) {
|
||||
Optional<Employee> optionalEmployee = employeeRepository.findByUsername(username);
|
||||
if(optionalEmployee.isEmpty())
|
||||
throw new EmployeeNotFoundException("Employee with username: " + username + " not found");
|
||||
@ -91,8 +92,8 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
|
||||
EmployeeAuthority employeeAuthority = employeeAuthorityRepository.findByEmpId(optionalEmployee.get());
|
||||
employeeAuthority.setAuthId(optionalAuthority.get());
|
||||
|
||||
return employeeAuthorityRepository.save(employeeAuthority);
|
||||
employeeAuthorityRepository.save(employeeAuthority);
|
||||
return HttpStatus.OK;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user