create new endpoints (employee edit)
This commit is contained in:
parent
b71d3eee7d
commit
11d757ec5b
48
.idea/workspace.xml
generated
48
.idea/workspace.xml
generated
@ -5,8 +5,12 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="067ac1f0-be04-4fe4-85c6-f870334053b8" name="Changes" comment="AUTHORIZATION WORK!">
|
<list default="true" id="067ac1f0-be04-4fe4-85c6-f870334053b8" name="Changes" comment="AUTHORIZATION WORK!">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AdminController.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/repository/EmployeeRepository.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/repository/EmployeeRepository.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/service/EmployeeService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/service/EmployeeService.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/service/EmployeeService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/service/EmployeeService.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/service/impl/EmployeeServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/service/impl/EmployeeServiceImpl.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/main/java/com/example/nto/service/impl/EmployeeServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/example/nto/service/impl/EmployeeServiceImpl.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@ -36,13 +40,13 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Application.App.executor": "Run",
|
"Application.App.executor": "Debug",
|
||||||
"Maven.NTO-2024 [org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean].executor": "Run",
|
"Maven.NTO-2024 [org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean].executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Users/User/Desktop/NTO-2024-Backend",
|
"last_opened_file_path": "C:/Users/User/Desktop/Ntoback/NTO-2024-Backend",
|
||||||
"project.structure.last.edited": "Modules",
|
"project.structure.last.edited": "Modules",
|
||||||
"project.structure.proportion": "0.0",
|
"project.structure.proportion": "0.0",
|
||||||
"project.structure.side.proportion": "0.0",
|
"project.structure.side.proportion": "0.0",
|
||||||
@ -168,53 +172,33 @@
|
|||||||
<breakpoints>
|
<breakpoints>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java</url>
|
||||||
<line>34</line>
|
<line>36</line>
|
||||||
<option name="timeStamp" value="6" />
|
<option name="timeStamp" value="6" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/EmployeeController.java</url>
|
||||||
<line>15</line>
|
<line>17</line>
|
||||||
<option name="timeStamp" value="7" />
|
<option name="timeStamp" value="7" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
||||||
<line>51</line>
|
<line>58</line>
|
||||||
<option name="timeStamp" value="25" />
|
<option name="timeStamp" value="25" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
||||||
<line>59</line>
|
<line>70</line>
|
||||||
<option name="timeStamp" value="26" />
|
<option name="timeStamp" value="26" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/websecurity/WebSecurityConfig.java</url>
|
||||||
<line>52</line>
|
<line>49</line>
|
||||||
<option name="timeStamp" value="30" />
|
<option name="timeStamp" value="40" />
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
<line-breakpoint enabled="true" type="java-line">
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AdminController.java</url>
|
||||||
<line>54</line>
|
<line>79</line>
|
||||||
<option name="timeStamp" value="31" />
|
<option name="timeStamp" value="41" />
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
|
||||||
<line>55</line>
|
|
||||||
<option name="timeStamp" value="34" />
|
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
|
||||||
<line>56</line>
|
|
||||||
<option name="timeStamp" value="35" />
|
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
|
||||||
<line>57</line>
|
|
||||||
<option name="timeStamp" value="36" />
|
|
||||||
</line-breakpoint>
|
|
||||||
<line-breakpoint enabled="true" type="java-line">
|
|
||||||
<url>file://$PROJECT_DIR$/src/main/java/com/example/nto/controller/AuthController.java</url>
|
|
||||||
<line>58</line>
|
|
||||||
<option name="timeStamp" value="37" />
|
|
||||||
</line-breakpoint>
|
</line-breakpoint>
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
# Minipigs-Back
|
# Minipigs-Back
|
||||||
|
|
||||||
минипиги solution
|
минипиги solution
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{"login": "pivanov", "password": "admin"} - админ
|
||||||
|
{"login": "ipetrov", "password": "user"} - user
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.example.nto.controller;
|
||||||
|
|
||||||
|
import com.example.nto.entity.Employee;
|
||||||
|
import com.example.nto.service.EmployeeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequestMapping("/api/admin/")
|
||||||
|
public class AdminController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmployeeService employeeService;
|
||||||
|
|
||||||
|
|
||||||
|
public static class DeleteEmployeeRequest {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UpdateEmployeeRequest {
|
||||||
|
private Long id;
|
||||||
|
private String field;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(String field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Такой же метод, как и getEmployeeInfo, только для админов по логину
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PreAuthorize("hasAnyRole('ADMIN')")
|
||||||
|
@GetMapping("/{value}/info")
|
||||||
|
public Employee getEmployeeInfoAdmin(@PathVariable String value) {
|
||||||
|
return employeeService.getEmployeeInfoById(Long.parseLong(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAnyRole('ADMIN')")
|
||||||
|
@DeleteMapping("/employee/delete/")
|
||||||
|
public ResponseEntity<String> deleteEmployee(@RequestBody DeleteEmployeeRequest deleteEmployeeRequest) {
|
||||||
|
employeeService.deleteEmployee(deleteEmployeeRequest.id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasRole('DOLBOEB')")
|
||||||
|
@PutMapping("/employee/update/login/")
|
||||||
|
public ResponseEntity<String> updateEmployeeLogin(@RequestBody UpdateEmployeeRequest updateEmployeeRequest) {
|
||||||
|
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
employeeService.updateEmployeeLogin(updateEmployeeRequest.id, updateEmployeeRequest.field);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAnyRole('ADMIN')")
|
||||||
|
@PutMapping("/employee/update/avatar/")
|
||||||
|
public ResponseEntity<String> updateEmployeeAvatar(@RequestBody UpdateEmployeeRequest updateEmployeeRequest) {
|
||||||
|
employeeService.updateEmployeeAvatar(updateEmployeeRequest.id, updateEmployeeRequest.field);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAnyRole('ADMIN')")
|
||||||
|
@PutMapping("/employee/update/position/")
|
||||||
|
public ResponseEntity<String> updatePosition(@RequestBody UpdateEmployeeRequest updateEmployeeRequest) {
|
||||||
|
employeeService.updateEmployeePosition(updateEmployeeRequest.id, updateEmployeeRequest.field);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
|
}
|
||||||
|
}
|
@ -1,24 +1,31 @@
|
|||||||
package com.example.nto.controller;
|
package com.example.nto.controller;
|
||||||
|
|
||||||
|
import com.example.nto.entity.Employee;
|
||||||
|
import com.example.nto.repository.EmployeeRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class AuthController {
|
public class AuthController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private static class LoginBody {
|
private static class LoginBody {
|
||||||
private String login;
|
private String login;
|
||||||
@ -50,8 +57,12 @@ public class AuthController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/api/login/")
|
@PostMapping("/api/login/")
|
||||||
private ResponseEntity<String> login(HttpServletRequest request, @RequestBody LoginBody loginBody) { //, @RequestParam String login, @RequestParam String password) {
|
private ResponseEntity<String> login(HttpServletRequest request, @RequestBody LoginBody loginBody) { //, @RequestParam String login, @RequestParam String password) {
|
||||||
|
|
||||||
|
Employee employee = employeeRepository.getByLogin(loginBody.login).get();
|
||||||
|
List<GrantedAuthority> authorities = new ArrayList<>();
|
||||||
|
authorities.add(new SimpleGrantedAuthority(employee.getRole()));
|
||||||
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
|
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(
|
||||||
loginBody.getLogin(), loginBody.getPassword());
|
loginBody.getLogin(), loginBody.getPassword(), authorities);
|
||||||
Authentication authentication = authenticationManager.authenticate(authRequest);
|
Authentication authentication = authenticationManager.authenticate(authRequest);
|
||||||
SecurityContext securityContext = SecurityContextHolder.getContext();
|
SecurityContext securityContext = SecurityContextHolder.getContext();
|
||||||
securityContext.setAuthentication(authentication);
|
securityContext.setAuthentication(authentication);
|
||||||
|
@ -3,9 +3,11 @@ package com.example.nto.controller;
|
|||||||
import com.example.nto.entity.Employee;
|
import com.example.nto.entity.Employee;
|
||||||
import com.example.nto.repository.CodeRepository;
|
import com.example.nto.repository.CodeRepository;
|
||||||
import com.example.nto.service.EmployeeService;
|
import com.example.nto.service.EmployeeService;
|
||||||
|
import org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapProperties;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.annotation.Secured;
|
import org.springframework.security.access.annotation.Secured;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@ -45,15 +47,6 @@ public class EmployeeController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Такой же метод, как и getEmployeeInfo, только для админов по логину
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Secured("ADMIN")
|
|
||||||
@GetMapping("/api/admin/{value}/info")
|
|
||||||
public Employee getEmployeeInfoAdmin(@PathVariable String value) {
|
|
||||||
return employeeService.getEmployeeInfoById(Long.parseLong(value));
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Получить информацию по емплоеееее
|
* Получить информацию по емплоеееее
|
||||||
*
|
*
|
||||||
|
@ -10,4 +10,5 @@ public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
|||||||
boolean existsByLogin(String login);
|
boolean existsByLogin(String login);
|
||||||
Optional<Employee> getByLogin(String login);
|
Optional<Employee> getByLogin(String login);
|
||||||
Optional<Employee> findByLogin(String login);
|
Optional<Employee> findByLogin(String login);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,8 @@ public interface EmployeeService {
|
|||||||
boolean doorIsOpen(String login, long code);
|
boolean doorIsOpen(String login, long code);
|
||||||
void updateLastVisit(String login);
|
void updateLastVisit(String login);
|
||||||
Employee getEmployeeInfoById(Long id);
|
Employee getEmployeeInfoById(Long id);
|
||||||
|
void deleteEmployee(Long id);
|
||||||
|
Employee updateEmployeeLogin(Long id, String newLogin);
|
||||||
|
Employee updateEmployeeAvatar(Long id, String newAvatar);
|
||||||
|
Employee updateEmployeePosition(Long id, String newPosition);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.example.nto.entity.Employee;
|
|||||||
import com.example.nto.repository.CodeRepository;
|
import com.example.nto.repository.CodeRepository;
|
||||||
import com.example.nto.repository.EmployeeRepository;
|
import com.example.nto.repository.EmployeeRepository;
|
||||||
import com.example.nto.service.EmployeeService;
|
import com.example.nto.service.EmployeeService;
|
||||||
|
import org.hibernate.sql.Update;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -74,4 +75,32 @@ public class EmployeeServiceImpl implements EmployeeService {
|
|||||||
public Employee getEmployeeInfoById(Long id) {
|
public Employee getEmployeeInfoById(Long id) {
|
||||||
return employeeRepository.findById(id).get();
|
return employeeRepository.findById(id).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEmployee(Long id) {
|
||||||
|
employeeRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Employee updateEmployeeLogin(Long id, String newLogin) {
|
||||||
|
Employee employee = employeeRepository.getById(id);
|
||||||
|
employee.setLogin(newLogin);
|
||||||
|
employeeRepository.save(employee);
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Employee updateEmployeeAvatar(Long id, String newAvatar) {
|
||||||
|
Employee employee = employeeRepository.getById(id);
|
||||||
|
employee.setPhoto(newAvatar);
|
||||||
|
employeeRepository.save(employee);
|
||||||
|
return employee;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Employee updateEmployeePosition(Long id, String newPosition) {
|
||||||
|
Employee employee = employeeRepository.getById(id);
|
||||||
|
employee.setPosition(newPosition);
|
||||||
|
employeeRepository.save(employee);
|
||||||
|
return employee; }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user