aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-07-01 05:36:42 +0300
committerGravatar Vitaly Takmazov2024-07-01 06:03:49 +0300
commit9c84e9ba60cce40f783a2d0bdde56dab96788b61 (patch)
tree4f421c628bc8a5d912bc0a12184f41de6287119b /src
parent9436d4927dc5035c83620bdd1dd34600370dce56 (diff)
JPA: code cleanup
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/data/EntityUtils.java39
-rw-r--r--src/main/java/com/juick/data/UsersRepository.java3
-rw-r--r--src/main/java/com/juick/data/entities/EmailEntity.java1
-rw-r--r--src/main/java/com/juick/data/entities/FacebookEntity.java1
-rw-r--r--src/main/java/com/juick/data/entities/TelegramEntity.java1
-rw-r--r--src/main/java/com/juick/data/entities/VKEntity.java1
6 files changed, 1 insertions, 45 deletions
diff --git a/src/main/java/com/juick/data/EntityUtils.java b/src/main/java/com/juick/data/EntityUtils.java
deleted file mode 100644
index 9f3a9f11..00000000
--- a/src/main/java/com/juick/data/EntityUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2008-2024, Juick
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.juick.data;
-
-import com.juick.model.User;
-import com.juick.data.entities.UserEntity;
-
-class EntityUtils {
- static User entityToUser(UserEntity entity) {
- User user = new User();
- user.setUid(entity.getId());
- user.setName(entity.getName());
- user.setBanned(entity.isBanned());
- return user;
- }
- static User entityToSecurityUser(UserEntity entity) {
- User user = new User();
- user.setUid(entity.getId());
- user.setName(entity.getName());
- user.setBanned(entity.isBanned());
- user.setCredentials(entity.getPassword());
- return user;
- }
-}
diff --git a/src/main/java/com/juick/data/UsersRepository.java b/src/main/java/com/juick/data/UsersRepository.java
index e2fcc0e8..d391d52d 100644
--- a/src/main/java/com/juick/data/UsersRepository.java
+++ b/src/main/java/com/juick/data/UsersRepository.java
@@ -26,8 +26,7 @@ import java.util.Optional;
import java.util.stream.Stream;
@Repository
-public interface UsersRepository extends JpaRepository<UserEntity, String> {
- Optional<UserEntity> findById(Integer uid);
+public interface UsersRepository extends JpaRepository<UserEntity, Integer> {
UserEntity findByName(String name);
Optional<UserEntity> findByNameAndPassword(String name, String password);
Optional<UserEntity> findByEmailsEmail(String email);
diff --git a/src/main/java/com/juick/data/entities/EmailEntity.java b/src/main/java/com/juick/data/entities/EmailEntity.java
index e13ca772..10c14c1e 100644
--- a/src/main/java/com/juick/data/entities/EmailEntity.java
+++ b/src/main/java/com/juick/data/entities/EmailEntity.java
@@ -24,7 +24,6 @@ import jakarta.persistence.*;
public class EmailEntity extends BaseUserPropertyEntity {
@Id
@Column(name = "email")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
private String email;
public String getEmail() {
diff --git a/src/main/java/com/juick/data/entities/FacebookEntity.java b/src/main/java/com/juick/data/entities/FacebookEntity.java
index 744848d9..6c6b4557 100644
--- a/src/main/java/com/juick/data/entities/FacebookEntity.java
+++ b/src/main/java/com/juick/data/entities/FacebookEntity.java
@@ -24,7 +24,6 @@ import jakarta.persistence.*;
public class FacebookEntity extends BaseUserPropertyEntity {
@Id
@Column(name = "fb_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long facebookId;
public Long getFacebookId() {
diff --git a/src/main/java/com/juick/data/entities/TelegramEntity.java b/src/main/java/com/juick/data/entities/TelegramEntity.java
index 453b8c11..ccb21022 100644
--- a/src/main/java/com/juick/data/entities/TelegramEntity.java
+++ b/src/main/java/com/juick/data/entities/TelegramEntity.java
@@ -24,7 +24,6 @@ import jakarta.persistence.*;
public class TelegramEntity extends BaseUserPropertyEntity {
@Id
@Column(name = "tg_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long identifier;
public Long getIdentifier() {
diff --git a/src/main/java/com/juick/data/entities/VKEntity.java b/src/main/java/com/juick/data/entities/VKEntity.java
index 5388c855..17840377 100644
--- a/src/main/java/com/juick/data/entities/VKEntity.java
+++ b/src/main/java/com/juick/data/entities/VKEntity.java
@@ -24,7 +24,6 @@ import jakarta.persistence.*;
public class VKEntity extends BaseUserPropertyEntity {
@Id
@Column(name = "vk_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long vkId;
public Long getVkId() {