feat: position field + menu role permissions management
This commit is contained in:
@@ -289,6 +289,7 @@ public class EmployeeController {
|
||||
if (row.containsKey("생년월일")) emp.setBirthDate(java.time.LocalDate.parse(row.get("생년월일")));
|
||||
if (row.containsKey("학력")) emp.setEducation(row.get("학력"));
|
||||
if (row.containsKey("학교명")) emp.setSchoolName(row.get("학교명"));
|
||||
if (row.containsKey("직급")) emp.setPosition(row.get("직급"));
|
||||
if (row.containsKey("학과")) emp.setMajor(row.get("학과"));
|
||||
if (row.containsKey("입사일")) emp.setJoinedDate(java.time.LocalDate.parse(row.get("입사일")));
|
||||
return emp;
|
||||
@@ -328,7 +329,7 @@ public class EmployeeController {
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@GetMapping("/batch/template")
|
||||
public ResponseEntity<byte[]> downloadTemplate() throws Exception {
|
||||
String[] headers = {"로그인ID", "이름", "이메일", "전화번호", "권한", "재직상태", "파견상태", "생년월일", "학력", "학교명", "학과", "입사일"};
|
||||
String[] headers = {"로그인ID", "이름", "이메일", "전화번호", "권한", "재직상태", "파견상태", "생년월일", "학력", "학교명", "직급", "학과", "입사일"};
|
||||
Map<Integer, String[]> dropdowns = Map.of(
|
||||
4, new String[]{"ADMIN", "MANAGER", "EMPLOYEE"},
|
||||
5, new String[]{"ACTIVE", "ON_LEAVE", "RESIGNED"},
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.srsystem.controller;
|
||||
|
||||
import com.srsystem.dto.ApiResponse;
|
||||
import com.srsystem.entity.MenuPermission;
|
||||
import com.srsystem.repository.MenuPermissionRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/menu-permissions")
|
||||
@RequiredArgsConstructor
|
||||
public class MenuPermissionController {
|
||||
|
||||
private final MenuPermissionRepository repository;
|
||||
|
||||
@GetMapping
|
||||
@PreAuthorize("hasAnyRole('EMPLOYEE', 'MANAGER', 'ADMIN')")
|
||||
public ApiResponse<List<MenuPermission>> getAll() {
|
||||
return ApiResponse.ok(repository.findAllByOrderBySortOrderAsc());
|
||||
}
|
||||
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
@PutMapping("/{menuKey}")
|
||||
public ApiResponse<MenuPermission> update(@PathVariable String menuKey, @RequestBody Map<String, String> body) {
|
||||
MenuPermission perm = repository.findByMenuKey(menuKey)
|
||||
.orElseThrow(() -> new RuntimeException("Menu not found: " + menuKey));
|
||||
if (body.containsKey("allowedRoles")) {
|
||||
perm.setAllowedRoles(body.get("allowedRoles"));
|
||||
}
|
||||
return ApiResponse.ok(repository.save(perm));
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,6 @@ public record EmployeeSummary(
|
||||
LocalDate graduationDate,
|
||||
String residence,
|
||||
String profileImage,
|
||||
String schoolName
|
||||
String schoolName,
|
||||
String position
|
||||
) {}
|
||||
|
||||
@@ -77,6 +77,9 @@ public class Employee extends BaseEntity {
|
||||
@Column(name = "school_name", length = 200)
|
||||
private String schoolName;
|
||||
|
||||
@Column(name = "position", length = 50)
|
||||
private String position;
|
||||
|
||||
@Column(name = "graduation_date")
|
||||
private LocalDate graduationDate;
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.srsystem.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.SQLRestriction;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tb_menu_permission")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@SQLDelete(sql = "UPDATE tb_menu_permission SET is_deleted = 'Y' WHERE id = ?")
|
||||
@SQLRestriction("is_deleted = 'N'")
|
||||
public class MenuPermission extends BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sq_menu_permissions")
|
||||
@SequenceGenerator(name = "sq_menu_permissions", sequenceName = "sq_menu_permissions", allocationSize = 50)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "menu_key", nullable = false, unique = true, length = 100)
|
||||
private String menuKey;
|
||||
|
||||
@Column(name = "menu_name", nullable = false, length = 200)
|
||||
private String menuName;
|
||||
|
||||
@Column(name = "parent_key", length = 100)
|
||||
private String parentKey;
|
||||
|
||||
@Column(name = "allowed_roles", nullable = false, columnDefinition = "TEXT")
|
||||
private String allowedRoles;
|
||||
|
||||
@Column(name = "sort_order")
|
||||
private Integer sortOrder;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.srsystem.repository;
|
||||
|
||||
import com.srsystem.entity.MenuPermission;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface MenuPermissionRepository extends JpaRepository<MenuPermission, Long> {
|
||||
List<MenuPermission> findAllByOrderBySortOrderAsc();
|
||||
Optional<MenuPermission> findByMenuKey(String menuKey);
|
||||
}
|
||||
@@ -107,6 +107,7 @@ public class EmployeeService {
|
||||
employee.setResidence(updateRequest.getResidence());
|
||||
employee.setProfileImage(updateRequest.getProfileImage());
|
||||
employee.setSchoolName(updateRequest.getSchoolName());
|
||||
employee.setPosition(updateRequest.getPosition());
|
||||
|
||||
return employee;
|
||||
}
|
||||
@@ -173,7 +174,8 @@ public class EmployeeService {
|
||||
employee.getGraduationDate(),
|
||||
employee.getResidence(),
|
||||
employee.getProfileImage(),
|
||||
employee.getSchoolName()
|
||||
employee.getSchoolName(),
|
||||
employee.getPosition()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user