intellij
This commit is contained in:
parent
76654bca02
commit
562c8b3162
|
@ -1,5 +1,15 @@
|
||||||
package com.totopia.server.auth.controller;
|
package com.totopia.server.auth.controller;
|
||||||
|
|
||||||
|
import com.totopia.server.auth.payload.JwtSigninResponse;
|
||||||
|
import com.totopia.server.auth.payload.SigninRequest;
|
||||||
|
import com.totopia.server.auth.payload.SignupRequest;
|
||||||
|
import com.totopia.server.commons.data.payload.ApiResponse;
|
||||||
|
import com.totopia.server.config.jwt.JwtTokenProvider;
|
||||||
|
import com.totopia.server.modules.user.entity.RoleEntity;
|
||||||
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
|
import com.totopia.server.modules.user.repository.RoleRepository;
|
||||||
|
import com.totopia.server.modules.user.repository.UserRepository;
|
||||||
|
import com.totopia.server.modules.user.type.RoleName;
|
||||||
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;
|
||||||
|
@ -15,18 +25,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import com.totopia.server.auth.payload.JwtSigninResponse;
|
|
||||||
import com.totopia.server.auth.payload.SigninRequest;
|
|
||||||
import com.totopia.server.auth.payload.SignupRequest;
|
|
||||||
import com.totopia.server.commons.data.payload.ApiResponse;
|
|
||||||
import com.totopia.server.config.jwt.JwtTokenProvider;
|
|
||||||
import com.totopia.server.modules.user.entity.RoleEntity;
|
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
|
||||||
import com.totopia.server.modules.user.repository.RoleRepository;
|
|
||||||
import com.totopia.server.modules.user.repository.UserRepository;
|
|
||||||
import com.totopia.server.modules.user.type.RoleName;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.totopia.server.auth.payload;
|
package com.totopia.server.auth.payload;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class JwtSigninResponse {
|
public class JwtSigninResponse {
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
private String tokenType = "Bearer";
|
private String tokenType = "Bearer";
|
||||||
|
@ -10,4 +7,53 @@ public class JwtSigninResponse {
|
||||||
public JwtSigninResponse(String accessToken) {
|
public JwtSigninResponse(String accessToken) {
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAccessToken() {
|
||||||
|
return this.accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTokenType() {
|
||||||
|
return this.tokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTokenType(String tokenType) {
|
||||||
|
this.tokenType = tokenType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof JwtSigninResponse)) return false;
|
||||||
|
final JwtSigninResponse other = (JwtSigninResponse) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$accessToken = this.getAccessToken();
|
||||||
|
final Object other$accessToken = other.getAccessToken();
|
||||||
|
if (this$accessToken == null ? other$accessToken != null : !this$accessToken.equals(other$accessToken))
|
||||||
|
return false;
|
||||||
|
final Object this$tokenType = this.getTokenType();
|
||||||
|
final Object other$tokenType = other.getTokenType();
|
||||||
|
if (this$tokenType == null ? other$tokenType != null : !this$tokenType.equals(other$tokenType)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof JwtSigninResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $accessToken = this.getAccessToken();
|
||||||
|
result = result * PRIME + ($accessToken == null ? 43 : $accessToken.hashCode());
|
||||||
|
final Object $tokenType = this.getTokenType();
|
||||||
|
result = result * PRIME + ($tokenType == null ? 43 : $tokenType.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "JwtSigninResponse(accessToken=" + this.getAccessToken() + ", tokenType=" + this.getTokenType() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,6 @@ package com.totopia.server.auth.payload;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class SigninRequest {
|
public class SigninRequest {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String username;
|
private String username;
|
||||||
|
@ -18,4 +9,89 @@ public class SigninRequest {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
public SigninRequest(@NotBlank String username, @NotBlank String password) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SigninRequest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SigninRequestBuilder builder() {
|
||||||
|
return new SigninRequestBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank String getPassword() {
|
||||||
|
return this.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(@NotBlank String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(@NotBlank String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof SigninRequest)) return false;
|
||||||
|
final SigninRequest other = (SigninRequest) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$username = this.getUsername();
|
||||||
|
final Object other$username = other.getUsername();
|
||||||
|
if (this$username == null ? other$username != null : !this$username.equals(other$username)) return false;
|
||||||
|
final Object this$password = this.getPassword();
|
||||||
|
final Object other$password = other.getPassword();
|
||||||
|
if (this$password == null ? other$password != null : !this$password.equals(other$password)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof SigninRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $username = this.getUsername();
|
||||||
|
result = result * PRIME + ($username == null ? 43 : $username.hashCode());
|
||||||
|
final Object $password = this.getPassword();
|
||||||
|
result = result * PRIME + ($password == null ? 43 : $password.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SigninRequest(username=" + this.getUsername() + ", password=" + this.getPassword() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SigninRequestBuilder {
|
||||||
|
private @NotBlank String username;
|
||||||
|
private @NotBlank String password;
|
||||||
|
|
||||||
|
SigninRequestBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SigninRequest.SigninRequestBuilder username(@NotBlank String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SigninRequest.SigninRequestBuilder password(@NotBlank String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SigninRequest build() {
|
||||||
|
return new SigninRequest(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SigninRequest.SigninRequestBuilder(username=" + this.username + ", password=" + this.password + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,6 @@ import javax.validation.constraints.Email;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Size;
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
|
|
||||||
public class SignupRequest {
|
public class SignupRequest {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Size(min = 4, max = 40)
|
@Size(min = 4, max = 40)
|
||||||
|
@ -25,4 +21,81 @@ public class SignupRequest {
|
||||||
@NotBlank
|
@NotBlank
|
||||||
@Size(min = 6, max = 20)
|
@Size(min = 6, max = 20)
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
public SignupRequest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank @Size(min = 4, max = 40) String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank @Size(min = 3, max = 15) String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank @Size(max = 40) @Email String getEmail() {
|
||||||
|
return this.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotBlank @Size(min = 6, max = 20) String getPassword() {
|
||||||
|
return this.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(@NotBlank @Size(min = 4, max = 40) String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(@NotBlank @Size(min = 3, max = 15) String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(@NotBlank @Size(max = 40) @Email String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(@NotBlank @Size(min = 6, max = 20) String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof SignupRequest)) return false;
|
||||||
|
final SignupRequest other = (SignupRequest) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$name = this.getName();
|
||||||
|
final Object other$name = other.getName();
|
||||||
|
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
|
||||||
|
final Object this$username = this.getUsername();
|
||||||
|
final Object other$username = other.getUsername();
|
||||||
|
if (this$username == null ? other$username != null : !this$username.equals(other$username)) return false;
|
||||||
|
final Object this$email = this.getEmail();
|
||||||
|
final Object other$email = other.getEmail();
|
||||||
|
if (this$email == null ? other$email != null : !this$email.equals(other$email)) return false;
|
||||||
|
final Object this$password = this.getPassword();
|
||||||
|
final Object other$password = other.getPassword();
|
||||||
|
if (this$password == null ? other$password != null : !this$password.equals(other$password)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof SignupRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $name = this.getName();
|
||||||
|
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
|
||||||
|
final Object $username = this.getUsername();
|
||||||
|
result = result * PRIME + ($username == null ? 43 : $username.hashCode());
|
||||||
|
final Object $email = this.getEmail();
|
||||||
|
result = result * PRIME + ($email == null ? 43 : $email.hashCode());
|
||||||
|
final Object $password = this.getPassword();
|
||||||
|
result = result * PRIME + ($password == null ? 43 : $password.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SignupRequest(name=" + this.getName() + ", username=" + this.getUsername() + ", email=" + this.getEmail() + ", password=" + this.getPassword() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,22 @@
|
||||||
package com.totopia.server.commons.data.entity;
|
package com.totopia.server.commons.data.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
import org.springframework.data.annotation.CreatedDate;
|
||||||
import org.springframework.data.annotation.LastModifiedDate;
|
import org.springframework.data.annotation.LastModifiedDate;
|
||||||
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import javax.persistence.EntityListeners;
|
import javax.persistence.EntityListeners;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@EntityListeners(AuditingEntityListener.class)
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
@JsonIgnoreProperties(value = { "createdAt", "updatedAt" }, allowGetters = true)
|
@JsonIgnoreProperties(value = { "createdAt", "updatedAt" }, allowGetters = true)
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public abstract class DateAuditEntity implements Serializable {
|
public abstract class DateAuditEntity implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3495202400889041952L;
|
private static final long serialVersionUID = 3495202400889041952L;
|
||||||
|
@ -37,4 +29,59 @@ public abstract class DateAuditEntity implements Serializable {
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Date updatedAt;
|
private Date updatedAt;
|
||||||
|
|
||||||
|
public DateAuditEntity(Date createdAt, Date updatedAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateAuditEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreatedAt() {
|
||||||
|
return this.createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdatedAt() {
|
||||||
|
return this.updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedAt(Date createdAt) {
|
||||||
|
this.createdAt = createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedAt(Date updatedAt) {
|
||||||
|
this.updatedAt = updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof DateAuditEntity)) return false;
|
||||||
|
final DateAuditEntity other = (DateAuditEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$createdAt = this.getCreatedAt();
|
||||||
|
final Object other$createdAt = other.getCreatedAt();
|
||||||
|
if (this$createdAt == null ? other$createdAt != null : !this$createdAt.equals(other$createdAt)) return false;
|
||||||
|
final Object this$updatedAt = this.getUpdatedAt();
|
||||||
|
final Object other$updatedAt = other.getUpdatedAt();
|
||||||
|
if (this$updatedAt == null ? other$updatedAt != null : !this$updatedAt.equals(other$updatedAt)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof DateAuditEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $createdAt = this.getCreatedAt();
|
||||||
|
result = result * PRIME + ($createdAt == null ? 43 : $createdAt.hashCode());
|
||||||
|
final Object $updatedAt = this.getUpdatedAt();
|
||||||
|
result = result * PRIME + ($updatedAt == null ? 43 : $updatedAt.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DateAuditEntity(createdAt=" + this.getCreatedAt() + ", updatedAt=" + this.getUpdatedAt() + ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,10 @@
|
||||||
package com.totopia.server.commons.data.entity;
|
package com.totopia.server.commons.data.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
import org.springframework.data.annotation.LastModifiedBy;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,10 +14,6 @@ import javax.persistence.MappedSuperclass;
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
@JsonIgnoreProperties(value = { "createdBy", "updatedBy" }, allowGetters = true)
|
@JsonIgnoreProperties(value = { "createdBy", "updatedBy" }, allowGetters = true)
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public abstract class UserDateAuditEntity extends DateAuditEntity {
|
public abstract class UserDateAuditEntity extends DateAuditEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 6379346917688414915L;
|
private static final long serialVersionUID = 6379346917688414915L;
|
||||||
|
@ -33,4 +24,59 @@ public abstract class UserDateAuditEntity extends DateAuditEntity {
|
||||||
@LastModifiedBy
|
@LastModifiedBy
|
||||||
private Long updatedBy;
|
private Long updatedBy;
|
||||||
|
|
||||||
|
public UserDateAuditEntity(Long createdBy, Long updatedBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
this.updatedBy = updatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserDateAuditEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getCreatedBy() {
|
||||||
|
return this.createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUpdatedBy() {
|
||||||
|
return this.updatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedBy(Long createdBy) {
|
||||||
|
this.createdBy = createdBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdatedBy(Long updatedBy) {
|
||||||
|
this.updatedBy = updatedBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "UserDateAuditEntity(createdBy=" + this.getCreatedBy() + ", updatedBy=" + this.getUpdatedBy() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof UserDateAuditEntity)) return false;
|
||||||
|
final UserDateAuditEntity other = (UserDateAuditEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$createdBy = this.getCreatedBy();
|
||||||
|
final Object other$createdBy = other.getCreatedBy();
|
||||||
|
if (this$createdBy == null ? other$createdBy != null : !this$createdBy.equals(other$createdBy)) return false;
|
||||||
|
final Object this$updatedBy = this.getUpdatedBy();
|
||||||
|
final Object other$updatedBy = other.getUpdatedBy();
|
||||||
|
if (this$updatedBy == null ? other$updatedBy != null : !this$updatedBy.equals(other$updatedBy)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof UserDateAuditEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $createdBy = this.getCreatedBy();
|
||||||
|
result = result * PRIME + ($createdBy == null ? 43 : $createdBy.hashCode());
|
||||||
|
final Object $updatedBy = this.getUpdatedBy();
|
||||||
|
result = result * PRIME + ($updatedBy == null ? 43 : $updatedBy.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,92 @@
|
||||||
package com.totopia.server.commons.data.payload;
|
package com.totopia.server.commons.data.payload;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class ApiResponse {
|
public class ApiResponse {
|
||||||
private Boolean success;
|
private Boolean success;
|
||||||
private String message;
|
private String message;
|
||||||
|
|
||||||
|
public ApiResponse(Boolean success, String message) {
|
||||||
|
this.success = success;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApiResponseBuilder builder() {
|
||||||
|
return new ApiResponseBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSuccess() {
|
||||||
|
return this.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccess(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof ApiResponse)) return false;
|
||||||
|
final ApiResponse other = (ApiResponse) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$success = this.getSuccess();
|
||||||
|
final Object other$success = other.getSuccess();
|
||||||
|
if (this$success == null ? other$success != null : !this$success.equals(other$success)) return false;
|
||||||
|
final Object this$message = this.getMessage();
|
||||||
|
final Object other$message = other.getMessage();
|
||||||
|
if (this$message == null ? other$message != null : !this$message.equals(other$message)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof ApiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $success = this.getSuccess();
|
||||||
|
result = result * PRIME + ($success == null ? 43 : $success.hashCode());
|
||||||
|
final Object $message = this.getMessage();
|
||||||
|
result = result * PRIME + ($message == null ? 43 : $message.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "ApiResponse(success=" + this.getSuccess() + ", message=" + this.getMessage() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ApiResponseBuilder {
|
||||||
|
private Boolean success;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
ApiResponseBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResponse.ApiResponseBuilder success(Boolean success) {
|
||||||
|
this.success = success;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResponse.ApiResponseBuilder message(String message) {
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApiResponse build() {
|
||||||
|
return new ApiResponse(success, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "ApiResponse.ApiResponseBuilder(success=" + this.success + ", message=" + this.message + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.totopia.server.config;
|
package com.totopia.server.config;
|
||||||
|
|
||||||
|
import com.totopia.server.config.security.SecurityUserDetails;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.domain.AuditorAware;
|
import org.springframework.data.domain.AuditorAware;
|
||||||
|
@ -10,8 +11,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.totopia.server.config.security.SecurityUserDetails;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableJpaAuditing
|
@EnableJpaAuditing
|
||||||
public class AuditingConfig {
|
public class AuditingConfig {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.totopia.server.config;
|
||||||
import com.totopia.server.config.jwt.JwtAuthenticationEntryPoint;
|
import com.totopia.server.config.jwt.JwtAuthenticationEntryPoint;
|
||||||
import com.totopia.server.config.jwt.JwtAuthenticationFilter;
|
import com.totopia.server.config.jwt.JwtAuthenticationFilter;
|
||||||
import com.totopia.server.config.security.SecurityUserDetailsService;
|
import com.totopia.server.config.security.SecurityUserDetailsService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
package com.totopia.server.config.jwt;
|
package com.totopia.server.config.jwt;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
|
||||||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {
|
||||||
|
|
||||||
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(JwtAuthenticationEntryPoint.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
|
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
|
||||||
AuthenticationException e) throws IOException, ServletException {
|
AuthenticationException e) throws IOException, ServletException {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.totopia.server.config.jwt;
|
package com.totopia.server.config.jwt;
|
||||||
|
|
||||||
|
import com.totopia.server.config.security.SecurityUserDetailsService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
@ -8,20 +10,15 @@ import org.springframework.security.web.authentication.WebAuthenticationDetailsS
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.filter.OncePerRequestFilter;
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import javax.servlet.FilterChain;
|
import javax.servlet.FilterChain;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.totopia.server.config.security.SecurityUserDetailsService;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||||
|
|
||||||
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(JwtAuthenticationFilter.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private JwtTokenProvider tokenProvider;
|
private JwtTokenProvider tokenProvider;
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,23 @@
|
||||||
package com.totopia.server.config.jwt;
|
package com.totopia.server.config.jwt;
|
||||||
|
|
||||||
|
import com.totopia.server.config.security.SecurityUserDetails;
|
||||||
|
import io.jsonwebtoken.*;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import io.jsonwebtoken.Claims;
|
|
||||||
import io.jsonwebtoken.ExpiredJwtException;
|
|
||||||
import io.jsonwebtoken.Jwts;
|
|
||||||
import io.jsonwebtoken.MalformedJwtException;
|
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
|
||||||
import io.jsonwebtoken.SignatureException;
|
|
||||||
import io.jsonwebtoken.UnsupportedJwtException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.totopia.server.config.security.SecurityUserDetails;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by rajeevkumarsingh on 19/08/17.
|
* Created by rajeevkumarsingh on 19/08/17.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
|
||||||
public class JwtTokenProvider {
|
public class JwtTokenProvider {
|
||||||
private static final String AUTHORITIES_KEY = "authorities";
|
private static final String AUTHORITIES_KEY = "authorities";
|
||||||
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(JwtTokenProvider.class);
|
||||||
|
|
||||||
@Value("${app.jwt.secret}")
|
@Value("${app.jwt.secret}")
|
||||||
private String jwtSecret;
|
private String jwtSecret;
|
||||||
|
|
|
@ -2,25 +2,15 @@ package com.totopia.server.config.security;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class SecurityUserDetails implements UserDetails {
|
public class SecurityUserDetails implements UserDetails {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -38,6 +28,22 @@ public class SecurityUserDetails implements UserDetails {
|
||||||
|
|
||||||
private Collection<? extends GrantedAuthority> authorities;
|
private Collection<? extends GrantedAuthority> authorities;
|
||||||
|
|
||||||
|
public SecurityUserDetails(Long id, String name, String username, String email, String password, Collection<? extends GrantedAuthority> authorities) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.username = username;
|
||||||
|
this.email = email;
|
||||||
|
this.password = password;
|
||||||
|
this.authorities = authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SecurityUserDetailsBuilder builder() {
|
||||||
|
return new SecurityUserDetailsBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
|
@ -96,4 +102,93 @@ public class SecurityUserDetails implements UserDetails {
|
||||||
.authorities(authorities).build();
|
.authorities(authorities).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return this.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
|
||||||
|
this.authorities = authorities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SecurityUserDetails(id=" + this.getId() + ", name=" + this.getName() + ", username=" + this.getUsername() + ", email=" + this.getEmail() + ", password=" + this.getPassword() + ", authorities=" + this.getAuthorities() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SecurityUserDetailsBuilder {
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String username;
|
||||||
|
private String email;
|
||||||
|
private String password;
|
||||||
|
private Collection<? extends GrantedAuthority> authorities;
|
||||||
|
|
||||||
|
SecurityUserDetailsBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder id(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder name(String name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder username(String username) {
|
||||||
|
this.username = username;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder email(String email) {
|
||||||
|
this.email = email;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder password(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails.SecurityUserDetailsBuilder authorities(Collection<? extends GrantedAuthority> authorities) {
|
||||||
|
this.authorities = authorities;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityUserDetails build() {
|
||||||
|
return new SecurityUserDetails(id, name, username, email, password, authorities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "SecurityUserDetails.SecurityUserDetailsBuilder(id=" + this.id + ", name=" + this.name + ", username=" + this.username + ", email=" + this.email + ", password=" + this.password + ", authorities=" + this.authorities + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.totopia.server.config.security;
|
||||||
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
import com.totopia.server.modules.user.repository.UserRepository;
|
import com.totopia.server.modules.user.repository.UserRepository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
package com.totopia.server.init;
|
package com.totopia.server.init;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
||||||
import com.totopia.server.modules.user.entity.RoleEntity;
|
import com.totopia.server.modules.user.entity.RoleEntity;
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
import com.totopia.server.modules.user.repository.RoleRepository;
|
import com.totopia.server.modules.user.repository.RoleRepository;
|
||||||
import com.totopia.server.modules.user.repository.UserRepository;
|
import com.totopia.server.modules.user.repository.UserRepository;
|
||||||
import com.totopia.server.modules.user.type.RoleName;
|
import com.totopia.server.modules.user.type.RoleName;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ConditionalOnProperty(name = "app.db-init", havingValue = "true")
|
@ConditionalOnProperty(name = "app.db-init", havingValue = "true")
|
||||||
public class DbInitializer implements CommandLineRunner {
|
public class DbInitializer implements CommandLineRunner {
|
||||||
|
@ -46,7 +45,7 @@ public class DbInitializer implements CommandLineRunner {
|
||||||
if (0 == userRepository.count()) {
|
if (0 == userRepository.count()) {
|
||||||
UserEntity user = null;
|
UserEntity user = null;
|
||||||
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
user = UserEntity.builder().username("admin").password(passwordEncoder.encode("admin")).nickname("admin")
|
||||||
.email("admin@example.com").roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 1)).build())
|
.email("admin@example.com").block(false).resetCount(0L).sendEmail(true).roles(Stream.of(RoleEntity.builder().id(Short.valueOf((short) 1)).build())
|
||||||
.collect(Collectors.toCollection(HashSet::new)))
|
.collect(Collectors.toCollection(HashSet::new)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,16 @@
|
||||||
package com.totopia.server.modules.dashboard.controller;
|
package com.totopia.server.modules.dashboard.controller;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
||||||
import com.totopia.server.modules.dashboard.entity.DashboardEntity;
|
import com.totopia.server.modules.dashboard.entity.DashboardEntity;
|
||||||
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
import com.totopia.server.modules.dashboard.repository.DashboardRepository;
|
||||||
|
|
||||||
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.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import javax.transaction.Transactional;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import java.util.List;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class DashboardController {
|
public class DashboardController {
|
||||||
|
|
|
@ -1,29 +1,13 @@
|
||||||
package com.totopia.server.modules.dashboard.entity;
|
package com.totopia.server.modules.dashboard.entity;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
|
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "dashboard")
|
@Table(name = "dashboard")
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class DashboardEntity extends UserDateAuditEntity {
|
public class DashboardEntity extends UserDateAuditEntity {
|
||||||
private static final long serialVersionUID = 8891163223262220481L;
|
private static final long serialVersionUID = 8891163223262220481L;
|
||||||
|
|
||||||
|
@ -47,8 +31,120 @@ public class DashboardEntity extends UserDateAuditEntity {
|
||||||
@Column(name = "sort_order", nullable = false)
|
@Column(name = "sort_order", nullable = false)
|
||||||
private Integer sortOrder;
|
private Integer sortOrder;
|
||||||
|
|
||||||
@Builder.Default
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "display", nullable = false)
|
@Column(name = "display", nullable = false)
|
||||||
private Boolean display = true;
|
private Boolean display = true;
|
||||||
|
|
||||||
|
public DashboardEntity(Integer id, String title, String description, String url, Integer sortOrder, Boolean display) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.description = description;
|
||||||
|
this.url = url;
|
||||||
|
this.sortOrder = sortOrder;
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DashboardEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return this.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSortOrder() {
|
||||||
|
return this.sortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getDisplay() {
|
||||||
|
return this.display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortOrder(Integer sortOrder) {
|
||||||
|
this.sortOrder = sortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplay(Boolean display) {
|
||||||
|
this.display = display;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "DashboardEntity(id=" + this.getId() + ", title=" + this.getTitle() + ", description=" + this.getDescription() + ", url=" + this.getUrl() + ", sortOrder=" + this.getSortOrder() + ", display=" + this.getDisplay() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof DashboardEntity)) return false;
|
||||||
|
final DashboardEntity other = (DashboardEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$id = this.getId();
|
||||||
|
final Object other$id = other.getId();
|
||||||
|
if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
|
||||||
|
final Object this$title = this.getTitle();
|
||||||
|
final Object other$title = other.getTitle();
|
||||||
|
if (this$title == null ? other$title != null : !this$title.equals(other$title)) return false;
|
||||||
|
final Object this$description = this.getDescription();
|
||||||
|
final Object other$description = other.getDescription();
|
||||||
|
if (this$description == null ? other$description != null : !this$description.equals(other$description))
|
||||||
|
return false;
|
||||||
|
final Object this$url = this.getUrl();
|
||||||
|
final Object other$url = other.getUrl();
|
||||||
|
if (this$url == null ? other$url != null : !this$url.equals(other$url)) return false;
|
||||||
|
final Object this$sortOrder = this.getSortOrder();
|
||||||
|
final Object other$sortOrder = other.getSortOrder();
|
||||||
|
if (this$sortOrder == null ? other$sortOrder != null : !this$sortOrder.equals(other$sortOrder)) return false;
|
||||||
|
final Object this$display = this.getDisplay();
|
||||||
|
final Object other$display = other.getDisplay();
|
||||||
|
if (this$display == null ? other$display != null : !this$display.equals(other$display)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof DashboardEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $id = this.getId();
|
||||||
|
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
|
||||||
|
final Object $title = this.getTitle();
|
||||||
|
result = result * PRIME + ($title == null ? 43 : $title.hashCode());
|
||||||
|
final Object $description = this.getDescription();
|
||||||
|
result = result * PRIME + ($description == null ? 43 : $description.hashCode());
|
||||||
|
final Object $url = this.getUrl();
|
||||||
|
result = result * PRIME + ($url == null ? 43 : $url.hashCode());
|
||||||
|
final Object $sortOrder = this.getSortOrder();
|
||||||
|
result = result * PRIME + ($sortOrder == null ? 43 : $sortOrder.hashCode());
|
||||||
|
final Object $display = this.getDisplay();
|
||||||
|
result = result * PRIME + ($display == null ? 43 : $display.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.totopia.server.modules.dashboard.repository;
|
package com.totopia.server.modules.dashboard.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.dashboard.entity.DashboardEntity;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
@ -7,8 +8,6 @@ import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.totopia.server.modules.dashboard.entity.DashboardEntity;
|
|
||||||
|
|
||||||
public interface DashboardRepository extends JpaRepository<DashboardEntity, Integer> {
|
public interface DashboardRepository extends JpaRepository<DashboardEntity, Integer> {
|
||||||
List<DashboardEntity> findByOrderBySortOrder();
|
List<DashboardEntity> findByOrderBySortOrder();
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,14 @@ package com.totopia.server.modules.user.controller;
|
||||||
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
import com.totopia.server.commons.exception.ResourceNotFoundException;
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
import com.totopia.server.modules.user.repository.UserRepository;
|
import com.totopia.server.modules.user.repository.UserRepository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
@ -30,8 +24,14 @@ public class UserController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/users")
|
@GetMapping(value = "/users")
|
||||||
public Page<UserEntity> all(Pageable pageable) {
|
public @ResponseBody Page<UserEntity> all(@PageableDefault(sort = {"username"}, direction = Sort.Direction.DESC, size = 10)Pageable pageable) {
|
||||||
return userRepository.findAll(pageable);
|
Page<UserEntity> users = userRepository.findAll(pageable);
|
||||||
|
// Gson gson = new Gson();
|
||||||
|
//
|
||||||
|
// String json = gson.toJson(users);
|
||||||
|
return users;
|
||||||
|
// public Page<UserEntity> all(Pageable pageable) {
|
||||||
|
// return userRepository.findAll(pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/users/{userId}")
|
@GetMapping(value = "/users/{userId}")
|
||||||
|
|
|
@ -1,26 +1,12 @@
|
||||||
package com.totopia.server.modules.user.entity;
|
package com.totopia.server.modules.user.entity;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.SequenceGenerator;
|
|
||||||
|
|
||||||
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
|
import com.totopia.server.commons.data.entity.UserDateAuditEntity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
@Entity(name = "bank_account")
|
@Entity(name = "bank_account")
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class BankAccountEntity extends UserDateAuditEntity {
|
public class BankAccountEntity extends UserDateAuditEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8628291684559836128L;
|
private static final long serialVersionUID = -8628291684559836128L;
|
||||||
|
@ -46,4 +32,101 @@ public class BankAccountEntity extends UserDateAuditEntity {
|
||||||
@Column(name = "username", nullable = false)
|
@Column(name = "username", nullable = false)
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
|
public BankAccountEntity(Long id, String name, String number, String holder, String username) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.number = number;
|
||||||
|
this.holder = holder;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BankAccountEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumber() {
|
||||||
|
return this.number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHolder() {
|
||||||
|
return this.holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumber(String number) {
|
||||||
|
this.number = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHolder(String holder) {
|
||||||
|
this.holder = holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "BankAccountEntity(id=" + this.getId() + ", name=" + this.getName() + ", number=" + this.getNumber() + ", holder=" + this.getHolder() + ", username=" + this.getUsername() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof BankAccountEntity)) return false;
|
||||||
|
final BankAccountEntity other = (BankAccountEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$id = this.getId();
|
||||||
|
final Object other$id = other.getId();
|
||||||
|
if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
|
||||||
|
final Object this$name = this.getName();
|
||||||
|
final Object other$name = other.getName();
|
||||||
|
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
|
||||||
|
final Object this$number = this.getNumber();
|
||||||
|
final Object other$number = other.getNumber();
|
||||||
|
if (this$number == null ? other$number != null : !this$number.equals(other$number)) return false;
|
||||||
|
final Object this$holder = this.getHolder();
|
||||||
|
final Object other$holder = other.getHolder();
|
||||||
|
if (this$holder == null ? other$holder != null : !this$holder.equals(other$holder)) return false;
|
||||||
|
final Object this$username = this.getUsername();
|
||||||
|
final Object other$username = other.getUsername();
|
||||||
|
if (this$username == null ? other$username != null : !this$username.equals(other$username)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof BankAccountEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $id = this.getId();
|
||||||
|
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
|
||||||
|
final Object $name = this.getName();
|
||||||
|
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
|
||||||
|
final Object $number = this.getNumber();
|
||||||
|
result = result * PRIME + ($number == null ? 43 : $number.hashCode());
|
||||||
|
final Object $holder = this.getHolder();
|
||||||
|
result = result * PRIME + ($holder == null ? 43 : $holder.hashCode());
|
||||||
|
final Object $username = this.getUsername();
|
||||||
|
result = result * PRIME + ($username == null ? 43 : $username.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,11 @@
|
||||||
package com.totopia.server.modules.user.entity;
|
package com.totopia.server.modules.user.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.EnumType;
|
|
||||||
import javax.persistence.Enumerated;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.SequenceGenerator;
|
|
||||||
|
|
||||||
import com.totopia.server.modules.user.type.RoleName;
|
import com.totopia.server.modules.user.type.RoleName;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import javax.persistence.*;
|
||||||
import lombok.Builder;
|
import java.io.Serializable;
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Entity(name = "roles")
|
@Entity(name = "roles")
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class RoleEntity implements Serializable {
|
public class RoleEntity implements Serializable {
|
||||||
private static final long serialVersionUID = 5100719044067326295L;
|
private static final long serialVersionUID = 5100719044067326295L;
|
||||||
|
|
||||||
|
@ -34,4 +18,89 @@ public class RoleEntity implements Serializable {
|
||||||
@Column(name = "name", length = 60)
|
@Column(name = "name", length = 60)
|
||||||
private RoleName name;
|
private RoleName name;
|
||||||
|
|
||||||
|
public RoleEntity(Short id, RoleName name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RoleEntityBuilder builder() {
|
||||||
|
return new RoleEntityBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Short getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleName getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Short id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(RoleName name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof RoleEntity)) return false;
|
||||||
|
final RoleEntity other = (RoleEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$id = this.getId();
|
||||||
|
final Object other$id = other.getId();
|
||||||
|
if (this$id == null ? other$id != null : !this$id.equals(other$id)) return false;
|
||||||
|
final Object this$name = this.getName();
|
||||||
|
final Object other$name = other.getName();
|
||||||
|
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof RoleEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $id = this.getId();
|
||||||
|
result = result * PRIME + ($id == null ? 43 : $id.hashCode());
|
||||||
|
final Object $name = this.getName();
|
||||||
|
result = result * PRIME + ($name == null ? 43 : $name.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "RoleEntity(id=" + this.getId() + ", name=" + this.getName() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RoleEntityBuilder {
|
||||||
|
private Short id;
|
||||||
|
private RoleName name;
|
||||||
|
|
||||||
|
RoleEntityBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleEntity.RoleEntityBuilder id(Short id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleEntity.RoleEntityBuilder name(RoleName name) {
|
||||||
|
this.name = name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoleEntity build() {
|
||||||
|
return new RoleEntity(id, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "RoleEntity.RoleEntityBuilder(id=" + this.id + ", name=" + this.name + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,17 @@
|
||||||
package com.totopia.server.modules.user.entity;
|
package com.totopia.server.modules.user.entity;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.JoinTable;
|
|
||||||
import javax.persistence.ManyToMany;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.persistence.Temporal;
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
import javax.persistence.UniqueConstraint;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.totopia.server.commons.data.entity.DateAuditEntity;
|
import com.totopia.server.commons.data.entity.DateAuditEntity;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.Builder.Default;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "users", uniqueConstraints = { @UniqueConstraint(columnNames = { "username" }),
|
@Table(name = "users", uniqueConstraints = { @UniqueConstraint(columnNames = { "username" }),
|
||||||
@UniqueConstraint(columnNames = { "email" }) })
|
@UniqueConstraint(columnNames = { "email" }) })
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class UserEntity extends DateAuditEntity {
|
public class UserEntity extends DateAuditEntity {
|
||||||
private static final long serialVersionUID = 8891163223262220481L;
|
private static final long serialVersionUID = 8891163223262220481L;
|
||||||
|
|
||||||
|
@ -56,12 +34,10 @@ public class UserEntity extends DateAuditEntity {
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "block", nullable = false)
|
@Column(name = "block", nullable = false)
|
||||||
@Default
|
|
||||||
private Boolean block = false;
|
private Boolean block = false;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "send_email", nullable = false)
|
@Column(name = "send_email", nullable = false)
|
||||||
@Default
|
|
||||||
private Boolean sendEmail = true;
|
private Boolean sendEmail = true;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@ -75,7 +51,6 @@ public class UserEntity extends DateAuditEntity {
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "reset_count", nullable = false)
|
@Column(name = "reset_count", nullable = false)
|
||||||
@Default
|
|
||||||
private Long resetCount = 0L;
|
private Long resetCount = 0L;
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
|
@ -88,12 +63,234 @@ public class UserEntity extends DateAuditEntity {
|
||||||
|
|
||||||
@Basic
|
@Basic
|
||||||
@Column(name = "require_reset", nullable = true)
|
@Column(name = "require_reset", nullable = true)
|
||||||
@Default
|
|
||||||
private Boolean requireReset = false;
|
private Boolean requireReset = false;
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
@JoinTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
|
@JoinTable(name = "user_roles", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "role_id"))
|
||||||
private Set<RoleEntity> roles;
|
private Set<RoleEntity> roles;
|
||||||
|
|
||||||
|
public UserEntity(String username, String password, String nickname, String email, Boolean block, Boolean sendEmail, String activation, Date lastResetTime, Long resetCount, String otpKey, String otep, Boolean requireReset, Set<RoleEntity> roles) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.email = email;
|
||||||
|
this.block = block;
|
||||||
|
this.sendEmail = sendEmail;
|
||||||
|
this.activation = activation;
|
||||||
|
this.lastResetTime = lastResetTime;
|
||||||
|
this.resetCount = resetCount;
|
||||||
|
this.otpKey = otpKey;
|
||||||
|
this.otep = otep;
|
||||||
|
this.requireReset = requireReset;
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return this.password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickname() {
|
||||||
|
return this.nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return this.email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getBlock() {
|
||||||
|
return this.block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getSendEmail() {
|
||||||
|
return this.sendEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivation() {
|
||||||
|
return this.activation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastResetTime() {
|
||||||
|
return this.lastResetTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getResetCount() {
|
||||||
|
return this.resetCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOtpKey() {
|
||||||
|
return this.otpKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOtep() {
|
||||||
|
return this.otep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getRequireReset() {
|
||||||
|
return this.requireReset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<RoleEntity> getRoles() {
|
||||||
|
return this.roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickname(String nickname) {
|
||||||
|
this.nickname = nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(Boolean block) {
|
||||||
|
this.block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSendEmail(Boolean sendEmail) {
|
||||||
|
this.sendEmail = sendEmail;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivation(String activation) {
|
||||||
|
this.activation = activation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastResetTime(Date lastResetTime) {
|
||||||
|
this.lastResetTime = lastResetTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResetCount(Long resetCount) {
|
||||||
|
this.resetCount = resetCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOtpKey(String otpKey) {
|
||||||
|
this.otpKey = otpKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOtep(String otep) {
|
||||||
|
this.otep = otep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequireReset(Boolean requireReset) {
|
||||||
|
this.requireReset = requireReset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoles(Set<RoleEntity> roles) {
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "UserEntity(username=" + this.getUsername() + ", password=" + this.getPassword() + ", nickname=" + this.getNickname() + ", email=" + this.getEmail() + ", block=" + this.getBlock() + ", sendEmail=" + this.getSendEmail() + ", activation=" + this.getActivation() + ", lastResetTime=" + this.getLastResetTime() + ", resetCount=" + this.getResetCount() + ", otpKey=" + this.getOtpKey() + ", otep=" + this.getOtep() + ", requireReset=" + this.getRequireReset() + ", roles=" + this.getRoles() + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object o) {
|
||||||
|
if (o == this) return true;
|
||||||
|
if (!(o instanceof UserEntity)) return false;
|
||||||
|
final UserEntity other = (UserEntity) o;
|
||||||
|
if (!other.canEqual((Object) this)) return false;
|
||||||
|
final Object this$username = this.getUsername();
|
||||||
|
final Object other$username = other.getUsername();
|
||||||
|
if (this$username == null ? other$username != null : !this$username.equals(other$username)) return false;
|
||||||
|
final Object this$password = this.getPassword();
|
||||||
|
final Object other$password = other.getPassword();
|
||||||
|
if (this$password == null ? other$password != null : !this$password.equals(other$password)) return false;
|
||||||
|
final Object this$nickname = this.getNickname();
|
||||||
|
final Object other$nickname = other.getNickname();
|
||||||
|
if (this$nickname == null ? other$nickname != null : !this$nickname.equals(other$nickname)) return false;
|
||||||
|
final Object this$email = this.getEmail();
|
||||||
|
final Object other$email = other.getEmail();
|
||||||
|
if (this$email == null ? other$email != null : !this$email.equals(other$email)) return false;
|
||||||
|
final Object this$block = this.getBlock();
|
||||||
|
final Object other$block = other.getBlock();
|
||||||
|
if (this$block == null ? other$block != null : !this$block.equals(other$block)) return false;
|
||||||
|
final Object this$sendEmail = this.getSendEmail();
|
||||||
|
final Object other$sendEmail = other.getSendEmail();
|
||||||
|
if (this$sendEmail == null ? other$sendEmail != null : !this$sendEmail.equals(other$sendEmail)) return false;
|
||||||
|
final Object this$activation = this.getActivation();
|
||||||
|
final Object other$activation = other.getActivation();
|
||||||
|
if (this$activation == null ? other$activation != null : !this$activation.equals(other$activation))
|
||||||
|
return false;
|
||||||
|
final Object this$lastResetTime = this.getLastResetTime();
|
||||||
|
final Object other$lastResetTime = other.getLastResetTime();
|
||||||
|
if (this$lastResetTime == null ? other$lastResetTime != null : !this$lastResetTime.equals(other$lastResetTime))
|
||||||
|
return false;
|
||||||
|
final Object this$resetCount = this.getResetCount();
|
||||||
|
final Object other$resetCount = other.getResetCount();
|
||||||
|
if (this$resetCount == null ? other$resetCount != null : !this$resetCount.equals(other$resetCount))
|
||||||
|
return false;
|
||||||
|
final Object this$otpKey = this.getOtpKey();
|
||||||
|
final Object other$otpKey = other.getOtpKey();
|
||||||
|
if (this$otpKey == null ? other$otpKey != null : !this$otpKey.equals(other$otpKey)) return false;
|
||||||
|
final Object this$otep = this.getOtep();
|
||||||
|
final Object other$otep = other.getOtep();
|
||||||
|
if (this$otep == null ? other$otep != null : !this$otep.equals(other$otep)) return false;
|
||||||
|
final Object this$requireReset = this.getRequireReset();
|
||||||
|
final Object other$requireReset = other.getRequireReset();
|
||||||
|
if (this$requireReset == null ? other$requireReset != null : !this$requireReset.equals(other$requireReset))
|
||||||
|
return false;
|
||||||
|
final Object this$roles = this.getRoles();
|
||||||
|
final Object other$roles = other.getRoles();
|
||||||
|
if (this$roles == null ? other$roles != null : !this$roles.equals(other$roles)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean canEqual(final Object other) {
|
||||||
|
return other instanceof UserEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
final int PRIME = 59;
|
||||||
|
int result = 1;
|
||||||
|
final Object $username = this.getUsername();
|
||||||
|
result = result * PRIME + ($username == null ? 43 : $username.hashCode());
|
||||||
|
final Object $password = this.getPassword();
|
||||||
|
result = result * PRIME + ($password == null ? 43 : $password.hashCode());
|
||||||
|
final Object $nickname = this.getNickname();
|
||||||
|
result = result * PRIME + ($nickname == null ? 43 : $nickname.hashCode());
|
||||||
|
final Object $email = this.getEmail();
|
||||||
|
result = result * PRIME + ($email == null ? 43 : $email.hashCode());
|
||||||
|
final Object $block = this.getBlock();
|
||||||
|
result = result * PRIME + ($block == null ? 43 : $block.hashCode());
|
||||||
|
final Object $sendEmail = this.getSendEmail();
|
||||||
|
result = result * PRIME + ($sendEmail == null ? 43 : $sendEmail.hashCode());
|
||||||
|
final Object $activation = this.getActivation();
|
||||||
|
result = result * PRIME + ($activation == null ? 43 : $activation.hashCode());
|
||||||
|
final Object $lastResetTime = this.getLastResetTime();
|
||||||
|
result = result * PRIME + ($lastResetTime == null ? 43 : $lastResetTime.hashCode());
|
||||||
|
final Object $resetCount = this.getResetCount();
|
||||||
|
result = result * PRIME + ($resetCount == null ? 43 : $resetCount.hashCode());
|
||||||
|
final Object $otpKey = this.getOtpKey();
|
||||||
|
result = result * PRIME + ($otpKey == null ? 43 : $otpKey.hashCode());
|
||||||
|
final Object $otep = this.getOtep();
|
||||||
|
result = result * PRIME + ($otep == null ? 43 : $otep.hashCode());
|
||||||
|
final Object $requireReset = this.getRequireReset();
|
||||||
|
result = result * PRIME + ($requireReset == null ? 43 : $requireReset.hashCode());
|
||||||
|
final Object $roles = this.getRoles();
|
||||||
|
result = result * PRIME + ($roles == null ? 43 : $roles.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Builder
|
||||||
|
// public UserEntity(String username, String password, String nickname, String email, Date createAt, Date updateAt) {
|
||||||
|
// super(createAt, updateAt);
|
||||||
|
// this.username = username;
|
||||||
|
// this.password = password;
|
||||||
|
// this.nickname = nickname;
|
||||||
|
// this.email = email;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 아이디
|
// 아이디
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
package com.totopia.server.modules.user.repository;
|
package com.totopia.server.modules.user.repository;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
import com.totopia.server.modules.user.entity.BankAccountEntity;
|
import com.totopia.server.modules.user.entity.BankAccountEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
public interface BankAccountRepository extends JpaRepository<BankAccountEntity, Long> {
|
public interface BankAccountRepository extends JpaRepository<BankAccountEntity, Long> {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.totopia.server.modules.user.repository;
|
package com.totopia.server.modules.user.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.user.entity.RoleEntity;
|
||||||
|
import com.totopia.server.modules.user.type.RoleName;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.totopia.server.modules.user.entity.RoleEntity;
|
|
||||||
import com.totopia.server.modules.user.type.RoleName;
|
|
||||||
|
|
||||||
public interface RoleRepository extends JpaRepository<RoleEntity, Long> {
|
public interface RoleRepository extends JpaRepository<RoleEntity, Long> {
|
||||||
Optional<RoleEntity> findByName(RoleName name);
|
Optional<RoleEntity> findByName(RoleName name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.totopia.server.modules.user.repository;
|
package com.totopia.server.modules.user.repository;
|
||||||
|
|
||||||
|
import com.totopia.server.modules.user.entity.UserEntity;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
@ -7,8 +8,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.totopia.server.modules.user.entity.UserEntity;
|
|
||||||
|
|
||||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||||
|
|
||||||
Optional<UserEntity> findByUsername(String username);
|
Optional<UserEntity> findByUsername(String username);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# Spring Boot configuration
|
# Spring Boot configuration
|
||||||
spring:
|
spring:
|
||||||
|
# autoconfigure:
|
||||||
|
# exclude: org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
|
||||||
application:
|
application:
|
||||||
name: totopia-server
|
name: totopia-server
|
||||||
datasource:
|
datasource:
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user