[ADD] 프로젝트 권한 추가

main
bjkim 11 months ago
parent 4dfcf0de93
commit ac641cf0ce

@ -9,6 +9,8 @@ import org.springframework.data.annotation.LastModifiedDate;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@Schema(description = "프로젝트") @Schema(description = "프로젝트")
@Comment("프로젝트") @Comment("프로젝트")
@ -77,4 +79,7 @@ public class ProjectEntity {
@Schema(description = "수정 유저 이름", example = "시스템") @Schema(description = "수정 유저 이름", example = "시스템")
@Comment("수정 유저 이름") @Comment("수정 유저 이름")
private String modUserNm; private String modUserNm;
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL, orphanRemoval = true)
private List<UserProjectMapEntity> userMappings = new ArrayList<>();
} }

@ -0,0 +1,8 @@
package kr.re.etri.autoflow.entity;
public enum ProjectPermission {
CREATE,
READ,
UPDATE,
DELETE
}

@ -0,0 +1,44 @@
package kr.re.etri.autoflow.entity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import kr.re.etri.autoflow.models.User;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.HashSet;
import java.util.Set;
@Entity
@Table(name = "tb_user_project_map")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "유저-프로젝트 매핑 정보")
public class UserProjectMapEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Schema(description = "매핑 ID", example = "1")
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
@Schema(description = "프로젝트 정보")
private ProjectEntity project;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(nullable = false)
@Schema(description = "사용자 정보")
private User user;
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "tb_user_project_permission", joinColumns = @JoinColumn(name = "user_project_id"))
@Enumerated(EnumType.STRING)
@Column(length = 20)
@Schema(description = "권한 목록", example = "[\"READ\", \"WRITE\"]")
private Set<ProjectPermission> permissions = new HashSet<>();
}
Loading…
Cancel
Save