forked from Hexlet/hexlet-correction
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hexlet#159] add table social link and check by id of github
- Loading branch information
Showing
11 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/io/hexlet/typoreporter/domain/AccountSocialLink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.hexlet.typoreporter.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIdentityInfo; | ||
import com.fasterxml.jackson.annotation.ObjectIdGenerators; | ||
import io.hexlet.typoreporter.domain.account.Account; | ||
import io.hexlet.typoreporter.domain.account.AuthProvider; | ||
import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import lombok.experimental.Accessors; | ||
import org.hibernate.annotations.Type; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
@NoArgsConstructor | ||
@Accessors(chain = true) | ||
@Entity(name = "account_social_links") | ||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") | ||
public class AccountSocialLink implements Identifiable<Long> { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "social_links_to_accounts_id_seq") | ||
@SequenceGenerator(name = "social_links_to_accounts_id_seq", allocationSize = 15) | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "account_id") | ||
@NotNull | ||
private Account account; | ||
|
||
@Column(name = "login") | ||
@NotNull | ||
private Integer login; | ||
|
||
@NotNull | ||
@Enumerated(EnumType.STRING) | ||
@Column(columnDefinition = "AUTH_PROVIDER") | ||
@Type(PostgreSQLEnumType.class) | ||
private AuthProvider authProvider; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/io/hexlet/typoreporter/repository/AccountSocialLinkRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.hexlet.typoreporter.repository; | ||
|
||
import io.hexlet.typoreporter.domain.AccountSocialLink; | ||
import io.hexlet.typoreporter.domain.account.AuthProvider; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface AccountSocialLinkRepository extends JpaRepository<AccountSocialLink, Long> { | ||
Optional<AccountSocialLink> findAccountSocialLinkByLoginAndAuthProvider(Integer login, AuthProvider authProvider); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...sources/db/changelog/changesets/2024/10/2024-10-06-add-table-social-links-to-accounts.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
|
||
<changeSet id="2024-10-06-add-table-social-links-to-accounts" author="d1z3d"> | ||
<comment>Таблица для хранения ID пользователя из социальной сети, т.к. пользователя можно идентифицировать только по нему</comment> | ||
<createTable tableName="account_social_links"> | ||
<column name="id" type="BIGINT"> | ||
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_SOCIAL_LINKS_OF_USERS" /> | ||
</column> | ||
<column name="account_id" type="BIGINT"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="login" type="BIGINT"> | ||
<constraints nullable="true" /> | ||
</column> | ||
<column name="auth_provider" type="AUTH_PROVIDER"> | ||
<constraints nullable="false" /> | ||
</column> | ||
</createTable> | ||
<addForeignKeyConstraint baseColumnNames="account_id" baseTableName="account_social_links" | ||
constraintName="FK_SOCIAL_LINKS_ON_ACCOUNT" referencedTableName="account" | ||
referencedColumnNames="id" /> | ||
<createSequence sequenceName="social_links_to_accounts_id_seq" startValue="1" incrementBy="15" /> | ||
</changeSet> | ||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters