From 9c84e9ba60cce40f783a2d0bdde56dab96788b61 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Mon, 1 Jul 2024 05:36:42 +0300
Subject: JPA: code cleanup
---
src/main/java/com/juick/data/EntityUtils.java | 39 ----------------------
src/main/java/com/juick/data/UsersRepository.java | 3 +-
.../java/com/juick/data/entities/EmailEntity.java | 1 -
.../com/juick/data/entities/FacebookEntity.java | 1 -
.../com/juick/data/entities/TelegramEntity.java | 1 -
.../java/com/juick/data/entities/VKEntity.java | 1 -
6 files changed, 1 insertion(+), 45 deletions(-)
delete mode 100644 src/main/java/com/juick/data/EntityUtils.java
(limited to 'src/main')
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 .
- */
-
-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 {
- Optional findById(Integer uid);
+public interface UsersRepository extends JpaRepository {
UserEntity findByName(String name);
Optional findByNameAndPassword(String name, String password);
Optional 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() {
--
cgit v1.2.3