123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package com.server.alb.models
- import jakarta.persistence.*
- @Entity
- @Table(name = "users")
- class User() {
- @Id
- @Column(name = "user_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- var id: Long = 0
- var username: String = ""
- var password: String = ""
- var isEnabled = false
- @ManyToMany(cascade = [CascadeType.ALL], fetch = FetchType.EAGER)
- @JoinTable(
- name = "users_roles",
- joinColumns = [JoinColumn(name = "user_id")],
- inverseJoinColumns = [JoinColumn(name = "role_id")]
- )
- var roles: Set<Role> = HashSet()
- @OneToMany(mappedBy = "qcId", cascade = [CascadeType.ALL], orphanRemoval = true)
- var qcId: List<ListBug> = mutableListOf()
- @OneToMany(mappedBy = "proId", cascade = [CascadeType.ALL], orphanRemoval = true)
- var proId: List<ListBug> = mutableListOf()
- @Transient
- var roleName: Role? = null
- @PostLoad
- fun onLoad() {
- for (role in roles) {
- roleName = role
- }
- }
- }
|