Skip to content

Commit

Permalink
User management (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
haiphucnguyen authored Dec 16, 2024
1 parent dbbeb33 commit bd87d54
Show file tree
Hide file tree
Showing 32 changed files with 243 additions and 155 deletions.
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public void sendEmail(
String to, String subject, String content, boolean isMultipart, boolean isHtml) {
javaMailSender.ifPresentOrElse(
sender -> sendEmailSync(sender, to, subject, content, isMultipart, isHtml),
() -> LOG.warn("Mail sending is disabled. Skipping email to '{}'", to));
() ->
LOG.warn(
"Mail sending is disabled. Skipping email to '{}' with content {}",
to,
content));
}

private void sendEmailSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

@Entity
@Table(name = "fw_organization")
@Data
@Getter
@Setter
@Builder
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor
@AllArgsConstructor
public class Organization {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

@Entity
@Table(name = "fw_team")
@Data
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
@EqualsAndHashCode(callSuper = false)
@Entity
@Table(name = "fw_team_request")
@Data
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "fw_team_role")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TeamRole implements Serializable {

@Id
@EqualsAndHashCode.Include
@Column(name = "name", nullable = false, length = 50)
private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "fw_team_workflow_selection")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor
@AllArgsConstructor
public class TeamWorkflowSelection {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@EqualsAndHashCode(callSuper = false)
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Entity
@Table(name = "fw_workflow")
@Data
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Workflow extends AbstractAuditingEntity<Long> {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "fw_workflow_actions")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkflowAction {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "fw_workflow_state")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkflowState {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Data
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Entity
@Table(name = "fw_workflow_transition")
public class WorkflowTransition {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@
import java.time.ZonedDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Entity
@Table(name = "fw_workflow_transition_history")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WorkflowTransitionHistory {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Objects;
import java.util.Set;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.Formula;

/** A Authority. */
@Entity
@Table(name = "fw_authority")
@JsonIgnoreProperties(value = {"new", "id"})
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Authority implements Serializable {

private static final long serialVersionUID = 1L;

@EqualsAndHashCode.Include
@NotNull @Size(max = 50)
@Id
@Column(name = "name", length = 50, nullable = false)
Expand All @@ -56,26 +58,4 @@ public class Authority implements Serializable {

@Formula("(SELECT COUNT(ua.user_id) FROM fw_user_authority ua WHERE ua.authority_name = name)")
private Long usersCount;

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Authority)) {
return false;
}
return getName() != null && getName().equals(((Authority) o).getName());
}

@Override
public int hashCode() {
return Objects.hashCode(getName());
}

// prettier-ignore
@Override
public String toString() {
return "Authority{" + "name=" + getName() + "}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
import jakarta.persistence.*;
import lombok.*;

@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "fw_authority_resource_permission")
@IdClass(AuthorityResourcePermissionId.class) // Composite key class
public class AuthorityResourcePermission {
@EqualsAndHashCode.Include
@Id
@Column(name = "authority_name")
private String authorityName;

@EqualsAndHashCode.Include
@Id
@Column(name = "resource_name")
private String resourceName;
Expand All @@ -23,12 +27,10 @@ public class AuthorityResourcePermission {
@Column(name = "permission", nullable = false)
private Permission permission;

@EqualsAndHashCode.Exclude
@ManyToOne
@JoinColumn(name = "authority_name", insertable = false, updatable = false)
private Authority authority;

@EqualsAndHashCode.Exclude
@ManyToOne
@JoinColumn(name = "resource_name", insertable = false, updatable = false)
private Resource resource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@

@Entity
@Table(name = "fw_resource")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Resource {

@EqualsAndHashCode.Include
@Id
@Column(name = "name", nullable = false, unique = true, length = 50)
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@

@Entity
@Table(name = "fw_tenant", schema = MASTER_SCHEMA)
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Tenant extends AbstractAuditingEntity<Long> implements Serializable {

@EqualsAndHashCode.Include
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
/** A user. */
@Entity
@Table(name = "fw_user")
@Data
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
Expand Down
Loading

0 comments on commit bd87d54

Please sign in to comment.